Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Are there any engines to execute TypeScript code directly?

When I first studied TypeScript, I found that node.js doesn’t execute TypeScript, so you need to install a TypeScript compiler that converts your TypeScript code into JavaScript.

I searched until I found ts-node (TypeScript execution and REPL for node.js), but when I read the documentation I found that they do the same (here). Even deno (A modern runtime for JavaScript and TypeScript), is doing the same (here).

So my question is: are there any engines to execute TypeScript code without converting it to JavaScript?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

No, TypeScript is not a "standalone" language in that sense. It is and always will be a superset of JavaScript. This is why the TypeScript Compiler is often referred to as a transpiler: it doesn’t compile to a lower-level language. After tsc has run its checks it transforms existing source to JavaScript by simply stripping out all the TypeScript constructs.

From the intro of the official TypeScript Handbook:

The goal of TypeScript is to be a static typechecker for JavaScript programs – in other words, a tool that runs before your code runs (static) and ensures that the types of the program are correct (typechecked).

So in order to execute TypeScript, you will always need a JavaScript engine. You could adapt an existing JavaScript engine (or build your own) to understand TypeScript as well, but still it would always first have to be an engine conforming to the ECMAScript specification.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading