3 ms·
> then Flow and TypeScript Neither one is a different language. Both merely add type annotations to an otherwise pristine ECMAScript code base. Typescript has
by nosianu 4y ago
> then Flow and TypeScript
Neither one is a different language. Both merely add type annotations to an otherwise pristine ECMAScript code base.
Typescript has some very few and minor and no longer needed things, like enums or namespaces, that need to be transpiled and are not part of ECMAScript. But again, those are minor and you no longer need them (since ES 2015 one can use modules instead of namespaces, and marked "as const" object literals instead of enums).
I know some people want to argue definitions, "different language" etc., but it's really just a completely optional tooling layer that you can just strip. It's also evaluated purely during development time, for type checks, the actual code that gets executed remains the ECMAScript part.
Whenever there are changes in a new Typescript version it's either purely within the type system, or they add type support for new ECMAScript features, those proposals that reached stage 3.
You could just imagine the type annotations in a different layer than the actual code, like in Photoshop. A layer used only by the IDE and code checking tools.
Microsoft added greatly to the confusion by putting the type checker, like eslint usable standalone or continuously queried through the IDE, and the type annotation files (.d.ts) generation and the completely optional .js file transformation AND .js file transpilation - backwards compatible JS code for earlier runtimes - into one tool. But all of those are different things. If your traget is "esnext" or you don't use JS features that your target runtime does not yet support transpilation is just removal of type annotations (except, enums, namespaces, which are no longer necessary and only exist for historical pre ES2015 reasons).
- muglug 4y ago> Neither one is a different language. Both merely add type annotations to an otherwise pristine ECMAScript code base. This isn’t really a matter of debate — Microsoft describes TypeScript as a programming language distinct from JavaScript on its homepage. It’s a programming language with a trivial transpiration step to another language, but a separate language all the same.
- nosianu 4y agoYou completely ignored everything I wrote and merely responded with an assertion, ignoring all evidence. What a terrible way to have a discussion. Would you kindly not ignore the facts? Oh and here is what it ACTUALLY says on the Typescript page (https://www.typescriptlang.org/ https://www.typescriptlang.org/): > TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. None of that contradicts anything I wrote.