4 ms·
> I don't want to use a language that changes my code to something else TypeScript doesn't change your code. If you're writing ES2015 code and targeting ES201
by RyanCavanaugh 10y ago
> I don't want to use a language that changes my code to something else
TypeScript doesn't change your code. If you're writing ES2015 code and targeting ES2015 emit, the output code is always exactly what you put in. There isn't any difference.
- Noseshine 10y agoI guess I'll have to look into that again then.
- WorldMaker 10y agoRight, most of the code changes Typescript performs are the equivalent of babel plugins: the closer you write to the target output version of the language the fewer changes there between the input/output. The further back compatible you try to target the more "polyfills" and reconfiguring Typescript needs to do to support the older versions of JS. Most of Typescript's output changes when you are writing for the same version of JS that you are outputting are simply just removing the type hints from the final output. That said, with allowJS "mixed" mode of Typescript now you can also try for a hybrid approach of JS and TS files in the same project and that hybrid approach gets more powerful and capable with each release. I think with some effort you can even get somewhat close enough to the point that you can have some Flow-like behavior by using JS for most files and .d.ts and .ts files for only the really type-dependent stuff.
- Noseshine 10y agoI hope that is going to be a major use case for TS (i.e. directly intended and supported by the makers), i.e. (guaranteed) "just types".
- wvenable 10y agoAlso you could just add types to your JavaScript code with TypeScript and nothing else; the result of running through the TS compiler is just the same code with the types removed.