Sometimes, we want to define static property in TypeScript interface.
In this article, we’ll look at how to define static property in TypeScript interface.
How to define static property in TypeScript interface?
To define static property in TypeScript interface, we should put the static property in a class instead.
For instance, we write
class RichDate {
public static minValue = new Date();
}
to add the minValue
static property to the RichDate
class with the static
keyword.
Then we can access the property by writing
RichDate.minValue
Conclusion
To define static property in TypeScript interface, we should put the static property in a class instead.
One reply on “How to define static property in TypeScript interface?”
the word “interface” means something specific in Typescript. smh