869: Node + TypeScript in 2025
Digest
This podcast discusses the evolving landscape of TypeScript within Node.js. It begins by introducing the simplified TypeScript integration in Node.js, often eliminating the need for a `tsc` config. The discussion then delves into how JavaScript engines handle TypeScript code, explaining the differences between compilation and type stripping. A refresher on TypeScript and type stripping follows, highlighting its impact on code execution and type checking. However, the podcast also addresses the limitations of Node.js's type stripping, particularly its incompatibility with features like enums and parameter properties. Alternatives to enums, such as string literals or objects, are suggested for better compatibility. The podcast explores the `import type` keyword and its importance for maintaining compatibility with type stripping. A comparison is made between Node.js's approach and that of Deno and Bun, which offer built-in TypeScript support. The podcast concludes by summarizing the upsides and downsides of type stripping and looking towards the future of TypeScript in Node.js, including the potential of "experimental transform types." The limitations of handling TypeScript files within `node_modules` are also addressed.
Outlines

TypeScript in Node.js: Integration and Type Stripping
Introduces TypeScript in Node.js, highlighting simplified integration and the use of type stripping. Explains how JavaScript engines handle TypeScript code via compilation or type stripping, detailing their differences and implications. Covers a TypeScript refresher and the concept of type stripping in Node.js.

Limitations and Alternatives in TypeScript/Node.js Development
Discusses limitations of Node.js type stripping (incompatibility with enums, parameter properties), explores alternatives (string literals, objects), and emphasizes writing type-stripping compatible code. Covers the use of `import type` and best practices for working with Node.js type stripping.

Node.js vs. Deno and Bun: TypeScript Support
Compares Node.js's approach to TypeScript with Deno and Bun, highlighting their built-in support for TypeScript and JSX, and summarizes the advantages and disadvantages of Node.js's type stripping approach. Includes concluding thoughts on the current state and future evolution of the TypeScript ecosystem.
Keywords
TypeScript
A superset of JavaScript adding optional static typing, improving code maintainability and catching errors during development. Compiles to JavaScript.
Node.js
A JavaScript runtime environment executing JavaScript code outside a web browser, popular for server-side applications.
Type Stripping
A process removing TypeScript type information, leaving only JavaScript code for execution. Used in Node.js for faster runtime.
Deno
A modern, secure runtime for JavaScript and TypeScript, built with V8 and Rust, offering improved performance and security features.
Bun
A fast, all-in-one JavaScript runtime combining features of Node.js, npm, and other tools for streamlined development.
JSX
A syntax extension to JavaScript allowing HTML-like syntax within JavaScript code, primarily used with React for building user interfaces.
`import type`
A TypeScript keyword importing only type definitions, not values, essential for compatibility with Node.js type stripping.
Q&A
What are the key advantages of Node.js's experimental type stripping support for TypeScript?
Eliminates the need for a separate compilation step, resulting in faster development cycles and simpler project setup. It also directly runs the authored code, improving debugging.
What are the limitations of Node.js's type stripping?
It doesn't support features requiring compilation, such as enums and parameter properties. It also has restrictions on handling TypeScript files within `node_modules`.
What are some alternatives to enums in TypeScript when using type stripping?
String literals, objects, or maps can effectively replace enums, providing similar functionality without the compilation dependency.
How does the `import type` keyword affect TypeScript code in Node.js?
The `import type` keyword is necessary when importing types to ensure compatibility with Node.js's type stripping mechanism. It prevents importing unnecessary runtime code.
How do Deno and Bun compare to Node.js in their handling of TypeScript?
Deno and Bun offer built-in, first-class support for TypeScript, including JSX, providing a more seamless and integrated development experience.
Show Notes
Scott and Wes explore the experimental world of running TypeScript in Node, breaking down the differences between type stripping and compiling. They cover the pros, cons, and quirks of the current implementation, plus explore tools like tsx, ts-node, and even alternatives like Deno.
Show Notes- 00:00 ">00:00 Welcome to Syntax!
- 00:41 ">00:41 Brought to you by Sentry.io.
- 01:29 ">01:29 Running TypeScript in Node.
- 01:45 ">01:45 Experimental Type Stripping.
- 03:17 ">03:17 TypeScript refresher.
- 04:05 ">04:05 TypeScript can be compiled and/or Type Stripped.
- 05:09 ">05:09 Current Node implementation is only type stripping.
- 05:40 ">05:40 Limitations of no compiling.
- 09:20 ">09:20 Experimental transform types.
- 10:01 ">10:01 Importing types with type keyword.
- 11:17 ">11:17 No need for sourcemaps.
- 11:42 ">11:42 No dependencies.
Syntax: X Instagram Tiktok LinkedIn Threads
Wes: X Instagram Tiktok LinkedIn Threads
























