3 ms·
> The -only- difference between TS and JS is the type annotations. It should be perfectly readable JS aside from that. TypeScript has a few differences: Autom
by genuine_smiles 6y ago
> The -only- difference between TS and JS is the type annotations. It should be perfectly readable JS aside from that.
TypeScript has a few differences:
Automatic class properties from arguments:
class Foo {
constructor(
public bar: string,
) {}
}
Enums, and probably other stuff I've forgotten. I think they're avoiding adding any other differences though.
- timdaub 6y agoI find this argument weird. JS doesn't have Public Class fields yet [1] (stage 3), hence any TS or JS code making use of such concept will differ. Similarly, as reliance of types in JS is not guaranteed, as it may in TS, will produce code with different assumptions too. So while you may "easily" go from (1) JS => TS, it may be much harder going from (2) TS => JS, as in (1) you're preserving all information and in (2) you're losing information. My point being, TS !== JS. - [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Public_class_fields https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- virtue3 6y agoI mean, enums literally get compiled into an object at runtime so aside from the definition it's basically the same :/ They're definition avoiding anything different now: see goal 6: https://github.com/microsoft/TypeScript/wiki/TypeScript-Design-Goals#goals https://github.com/microsoft/TypeScript/wiki/TypeScript-Desi...