3 ms·
The article is light on 'What is Typescript'. Can someone explain what TypeScript is?
by bprater 13y ago
The article is light on 'What is Typescript'. Can someone explain what TypeScript is?
- lmkg 13y agoIt's a compile-to-JavaScript language, like CoffeeScript. Differentiating features: - Strict superset of JS. All(?) JS is valid TS, making it easier to migrate to TS. - Many of the added features are from EcmaScript 6, i.e. JavaScript Of The Future. TS lets you use those today, instead of waiting for browsers to implement. - (Optional) type system, which some people are fans of. - Much stronger tooling & IDE support, in part due to the typing.
- mfn 13y agoAlso, compiling down to human-readable and well formatted JS has always been a priority. So it's never difficult to migrate away from typescript, since the typescript can simply be replaced by the compiler's javascript output. IIRC, this is actually one of the main reasons they're holding off on implementing async/await, since that would require the compiler to convert functions into unreadable state machines.
- elpool2 13y agoAnother feature that's not talked about much is its support for AMD and CommonJS modules. So you can easily just add an "import moduleName = require('my/module/path');" to the top of your typescript file. And you'll get full intellisense and type-checking on the referenced module in Visual Studio. This alone has made it worth using for me.
- nawitus 13y agoNot all valid JavaScript is valid TypeScript, e.g. you can't use undeclared variables. The compiler can still output the .js file, though.
- ternaryoperator 13y agoTypeScript also adds namespaces.