TypeScript levels up with type stripping
Briefly

TypeScript levels up with type stripping
"TypeScript is usually described as a superset of JavaScript, meaning all valid JavaScript is also valid TypeScript. With a few notable exceptions (like Enums and namespaces), it is possible to go through a program, delete the type information, and arrive at a perfectly legitimate JavaScript program. This is type stripping, an alternative to transpilation. Now there's a move to add type stripping to the core language, which would make it even easier to run your TypeScript programs as JavaScript."
"Similar to type erasure in Java, type stripping would make it possible to execute a cheap text replacement of type information at runtime, rather than a heavier compile step later. Modern runtimes like Deno and Bun have supported this capability natively for some time, but type stripping really hit the enterprise mainstream in Node.js. Starting in Node 22.6, released early last year, the JavaScript runtime can execute TypeScript directly."
Type information in TypeScript can be removed to produce valid JavaScript, a process called type stripping that functions as an alternative to transpilation. Type stripping mirrors Java's type erasure and enables cheap text replacement of types at runtime instead of heavier compile steps. Runtimes such as Deno, Bun, and now Node.js support executing TypeScript by erasing non-JavaScript-compatible parts on the fly. Node introduced an --experimental-strip-types flag in Node 22.6 to perform this removal and allow direct execution of .ts files. The approach reduces source-map reliance, eliminates build delays, and preserves accurate stack traces and simpler developer workflows.
Read at InfoWorld
Unable to calculate read time
[
|
]