It is far that you just presumably can imagine to enact TypeScript files by environment the experimental flag --experimental-strip-forms
.
Node.js will transpile TypeScript supply code into JavaScript supply code.
Throughout the transpilation process, no form checking is done, and forms are discarded.
Roadmap
Refs: nodejs/loaders#217
Motivation
I maintain enabling users to enact TypeScript files is needed to circulate the ecosystem forward, it has been requested on the general surveys, and it simply can now no longer be overlooked. We must acknowledge users wish to traipse node foo.ts
with out installing external dependencies or loaders.
There might be a TC39 proposal for form annotations
Why form stripping
Form stripping because the establish imply, device laying aside the general forms
, severely change the input in a JavaScript module.
const foo: string = "foo";
Turns into:
Various runtimes also draw transformation of some TypeScript most optimistic parts into JavaScript, as an instance enums, which attain now no longer exists in JavaScript.
No now no longer as a lot as originally in this PR no trasformation is done, that device that the utilization of Enum
, namespaces
and many others… would per chance per chance now no longer be that you just presumably can imagine.
Why I selected @swc/wasm-typescript
On story of of simplicity.
I even maintain thought to be other tools however they require either rust or mosey to be added to the toolchain.
@swc/wasm-typescript
its a runt equipment with a wasm and a js file to bind it.
Swc is for the time being broken-down by Deno for the identical motive, or now no longer it is fight tested.
Sooner or later I explore this being implemented in native layer.
Large shoutout to @kdy1 for releasing a swc model for us.
typescript.md
for implementation particulars and barriers.