logoalt Hacker News

tresiltoday at 10:12 AM1 replyview on HN

I show people coming from object oriented backgrounds this page first in order to correct the perception that TypeScript is best used with that programming paradigm.

https://www.typescriptlang.org/docs/handbook/typescript-in-5...


Replies

locknitpickertoday at 10:48 AM

> I show people coming from object oriented backgrounds this page first in order to correct the perception that TypeScript is best used with that programming paradigm.

I think you're confusing things. Languages like Java or C# impose an artificial constraint that free functions don't exist and functions can only exist as members of a class. You don't see this constraint in OO languages such as C++.

Also, it's a simplistic assertions to claim that classes have no place in TypeScript or aren't idiomatic. That's just nonsense based on specious reasoning. Classes/objects with function members are still the best way to implement some features. I'm seeing too many people writing absurd typescript code who go through great lengths to avoid a class because they think a class is taboo. They pull out convoluted stunts like passing closures as object members, just to avoid the sin of rolling out a class.

show 1 reply