Hacker News new | ask | show | jobs
by Udik 2289 days ago
> Typescript aim to model a strongly typed, OPP language.

Do you think? I just take TS for what it gives me, documentation and static code analysis. I can write down my knowledge and expectations about the code and have the tool keep track of it for me, removing the cognitive load of doing it myself- which I'd have to otherwise.

Can you give me an example of a pattern that is "good" in JS and not in TS, or the other way round? I'm curious.

1 comments

A good indirect example is an actual feature added to JS recently, which are classes. Classes are the main unit of OOP, while functions are the main unit in the functional paradigm. The class syntax in JS is not a real new structure added to the language, but just syntax sugar. Underneath it all, the JS compiler just converts it to a regular JS function using a specific pattern. You could, if you wanted, save the compiler that work by just coding using that pattern to begin with.

When using TS the class syntax fits in perfectly for me, an in pure JS I'd stick to functions.

So you're giving a javascript feature as an example of a pattern that doesn't fit javascript. Then you claim to use an equivalent but syntactically different form in js? How does this constitute a different pattern?