Node.js 22.6.0 adds a new option for lightweight TypeScript support.
What's nice about this is that it lets you maintain a simple JavaScript-type of workflow (no explicit intermediate transpilation step to generate JavaScript files from TypeScript source code) while coding in TypeScript for the benefits of static typing.
Deno and Bun.js already provide a native TypeScript experience so that you can skip the explicit transpiling step. But if you're using or plan to use Node.js 22.6.0 or later, you can also take advantage of this feature.
With the --experimental-strip-types
option, you can skip the transpilation step and directly run your .ts files. But Node.js doesn't do any actual type checking — if you want those static typing benefits previously mentioned, that's the job of a type checking tool, like the TypeScript compiler (tsc).
I wrote a post on my personal blog that goes into more depth and walks through using the feature, while also supporting type checking and linting support as a developer dependency for coding.
https://codesnip.sh/posts/built-in-typescript-support-with-nodejs
Top comments (0)