In this example, we have shared TypeScript static classes. Abstract classes have been a first-class citizen of TypeScript since TypeScript 1.6. You cannot instantiate an abstract class.
1 2 3 4 5 6 7 8 9 10 11 | export abstract class MyClass { public static myProp = "Hello"; public static doSomething(): string { return "World"; } } const okay = MyClass.doSomething(); //const errors = new MyClass(); // Error |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.