869: Node + TypeScript in 2025
· Summarized
Key takeaways
- Node.js now supports experimental type stripping for TypeScript, making it easier to execute TypeScript files without a compilation step.
- Type stripping removes type information but does not perform code transformations, which limits the features available when using TypeScript in Node.js.
- Best practices suggest avoiding TypeScript features that require compilation, like Enums, when aiming for compatibility between environments.
- Alternative tools and platforms such as tsx, ts-node, Deno, and Bun are emerging, offering first-class support for TypeScript.
- The evolving landscape of TypeScript in Node and its alternatives suggests a more seamless development experience compared to previous years.
Summary
Introduction to TypeScript in Node
Scott and Wes dive into using TypeScript within Node.js, highlighting its experimental type stripping capabilities. They express excitement about type stripping support that has recently become available, which simplifies the development process by eliminating the need for compiling TypeScript down to JavaScript before execution.
TypeScript Basics and Features
The hosts recap TypeScript's nature as a superset of JavaScript, focusing on the addition of type information to code. They discuss the distinction between type stripping and compiling in the context of TypeScript, clarifying that the current Node.js implementation uses type stripping, which does not include type checking or transformations of the code.
Limitations of Type Stripping in Node.js
While type stripping offers a streamlined approach for running TypeScript files, it comes with limitations. Notable features like Enums and parameter properties, which require compilation, are not supported, leading to discussions about best practices and alternatives such as using string literals and objects instead of Enums.
Future of TypeScript in Node and Tools
The potential future of type stripping in Node.js may evolve with upcoming experimental features and tools such as tsx and ts-node. Scott and Wes discuss the merits of these tools compared to the traditional build steps, positing that the removal of unnecessary complexity improves developer experience and workflow.
Introduction of Deno and Bun
The episode also explores Deno and Bun, alternatives to Node.js that treat TypeScript as a first-class citizen. Both platforms provide enhanced support for TypeScript, including JSX handling, which presents an exciting development compared to traditional Node.js practices.
Sponsors
- Sentry · Sentry helps you fix your code issues, whether it's slow or breaking. They provide robust tools for developers to enhance their code quality.
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 Welcome to Syntax!
00:41 Brought to you by Sentry.io.
01:29 Running TypeScript in Node.
01:45 Experimental Type Stripping.
03:17 TypeScript refresher.
04:05 TypeScript can be compiled and/or Type Stripped.
05:09 Current Node implementation is only type stripping.
05:40 Limitations of no compiling. 05:57 Enums.
08:30 Other issues.
08:35 Parameter properties.
09:20 Experimental transform types.
10:01 Importing types with type keyword.
11:17 No need for sourcemaps.
11:42 No dependencies. 13:08 Other tools.
13:25 tsx.
14:28 ts-node.
14:44 JSDoc.
16:30 Deno and Bun.
Hit us up on Socials! Syntax: X Instagram Tiktok LinkedIn Threads
Wes: X Instagram Tiktok LinkedIn Threads
Scott: X Instagram Tiktok LinkedIn Threads
Randy: X Instagram YouTube Threads
Follow this show on AudioBrevity and new episodes get summarized for you. Create a free account