Arun Tyagi Arun Tyagi - 9 days ago 5
TypeScript Question

Static class in typescript

Is there any way to create an static class in typescript, node.js

I want to create an static class to keep all constants and string in that.

what could be the best way to do that ?

Answer

Sure you can define a class with static properties:

export class Constants {
    static MAX_VALUE = 99999;
    static MIN_VALUE = 0;
}

Then use it when you need:

import { Constants } from '../constants';
console.log(Constants.MAX_VALUE);