Categories
TypeScript Answers

How to define static property in TypeScript interface?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

One reply on “How to define static property in TypeScript interface?”

Leave a Reply

Your email address will not be published. Required fields are marked *