4 ms·
To be fair there is TypeScript code which is not idiomatic to JS. I at least remember the early namespace system. Not so sure about 2020 TypeScript. But I agre
by oaiey 6y ago
To be fair there is TypeScript code which is not idiomatic to JS. I at least remember the early namespace system. Not so sure about 2020 TypeScript.
But I agree with everything else you wrote.
- WorldMaker 6y ago2020 Typescript has very few non-idiomatic JS constructs left, most of which are left only for compatibility reasons with really old TS code, have deprecation markers or strict flag errors around their usage, and generally are frowned upon, with one odd exception that proves the rule. Almost all of them come from the early days of module development as ES2015 and ES2015 modules were finalized. Most of them resemble idiomatic JS of their time. There's an old import and export syntax that idiomatically looks and acts more like CommonJS (aka most older npm packages). That's been deprecated since 1.x and I believe an error or warning since 2.x. The "namespace" thing you are probably recalling is about the only surviving piece of that legacy, as the exception that proves the rule. It got renamed to "module" to at least sound more JS than C#, and while the syntax is still not entirely idiomatic, the concept that it has always wrapped and been mere syntactic sugar for is a classic (thankfully on life support more than not) pattern: the IIFE [Immediately Invoked Function Expression] module pattern.
- oaiey 6y agoThanks. Yeah, that is also my limited insight.