TypeScript static classes

I wanted to move to TypeScript from traditional JS because I like the C#-like syntax.
My problem is that I can’t find out how to declare static classes in TypeScript.

In C#, I often use static classes to organize variables and methods, putting them together in a named class, without needing to instatiate an object.
In vanilla JS, I used to do this with a simple JS object:

var myStaticClass = {
    property: 10,
    method: function(){}

In TypeScript, I would rather go for my C-sharpy approach, but it seems that static classes don’t exist in TS.
What is the appropriate solution for this problem ?

15 Answers

Leave a Comment