4 ms·
Is TypeScript a superset of JavaScript? Or is there valid JavaScript that doesn't compile in TS?
by pavlov 13y ago
Is TypeScript a superset of JavaScript? Or is there valid JavaScript that doesn't compile in TS?
- michielvoo 13y agoSuperset[1] [1] http://www.typescriptlang.org/ http://www.typescriptlang.org/
- pavlov 13y agoThanks! Is there a guarantee that TS will remain a strict superset? Looking at the syntax, it reminds me of Flash ActionScript, which started out as an ECMAScript implementation but became an incompatible superset that pretended to be JavaScript compatible but would whine endlessly about untyped var declarations... Hopefully ActionScript and C++ will serve as warnings to TypeScript designers: if you're ever thinking about disrupting code compatibility with the original language in the name of added type safety, don't do it.
- johnny_reilly 13y agoMy understanding is that the TypeScript team intend to TypeScript to always remain a superset. If you watch the various videos with Anders talking about it then that comes across pretty clearly.
- deleted 13y ago[deleted]
- johnsoft 13y agoThere are a few language corners that don't translate, such as: var x = "".constructor(5); // The property 'constructor' does not exist on value of type 'String'. The exceptions make sense if you dig into how the type system works. AFAIK these can always be worked around with an explicit cast to any: var x = (<any>"").constructor(5); I've found TypeScript to be a huge win for maintainability, and can't imagine going back to raw JS for an app of any complexity. I'd love to have a chance to pair it with Node for something.