4 ms·
So we can run unmodified TypeScript code without needing to bundle inside Node.JS and other implementations of JavaScript such as JS Core. By allowing but igno
by lstamour 4y ago
So we can run unmodified TypeScript code without needing to bundle inside Node.JS and other implementations of JavaScript such as JS Core.
By allowing but ignoring types, you get the best of both worlds - optional type checking and runtime compatibility - without further compilation.
Frankly I think of this feature as a Node.JS feature and a reduce-duplication feature. You can store and run the same TS syntax in a file with a .JS extension.
Today, I often find TypeScript samples that I copy into JS projects and then have to painfully remove the TypeScript bits to get it to run. This fixes that. Your IDE can benefit from reading the types and tell you about errors - that’s where you can fix them anyway.
If you want <script lang="TypeScript" … /> to work, with compile type checks and everything, that’s a different feature?
- krapp 4y agoWhy should javascript, as a language, care about Typescript? I know it's popular, but it isn't javascript, it's a completely separate language which just happens to compile to javascript. Why should javascript add syntax just to make users of another language more comfortable? >Today, I often find TypeScript samples that I copy into JS projects and then have to painfully remove the TypeScript bits to get it to run. This fixes that. The purpose of typescript is to be compiled into javascript, it isn't meant to be run in a browser. If you're going to use it, use it properly, otherwise, "picking out the typescript bits" makes about as much sense as "picking out the C#" parts of some .NET code to run it in a C compiler.