I just want to declare a static property in typescript interface? I have not found anywhere regarding this.
interface myInterface {
static Name:string;
}
Is it possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t define a static property on an interface in TypeScript.
Say you wanted to change the
Dateobject, rather than trying to add to the definitions ofDate, you could wrap it, or simply create your rich date class to do the stuff thatDatedoesn’t do.Because Date is an interface in TypeScript, you can’t extend it with a class using the
extendskeyword, which is a bit of a shame as this would be a good solution if date was a class.If you want to extend the Date object to provide a
MinValueproperty on the prototype, you can:Called using:
And if you want to make it available without an instance, you also can… but it is a bit fussy.
Called using: