Overview
This lecture discusses Node.js's major update: official, built-in TypeScript support via the new Amaro loader, making TypeScript development smoother and more integrated within Node.
TypeScript Adoption and Node.js
- TypeScript has become the standard in both frontend and backend development.
- Competing runtimes like Deno and Bun offer native TypeScript support.
- Node.js previously required complex tooling for TypeScript, lagging behind competitors.
Introduction of Amaro Loader
- Amaro is Node's new official loader for TypeScript files, enabling built-in type stripping.
- Its sole function is to remove TypeScript types at runtime, allowing TS files to run as JavaScript in Node.
- Amaro uses SWC, a fast Rust-based compiler, for the transformation process.
Amaro Loader Modes
- Default mode ("strip types") removes type annotations and executes the code as JavaScript.
- "Transform types" mode handles advanced TypeScript features like enums, removing previous barriers.
Expanded Support and Developer Experience
- Amaro works with TypeScript files in both user projects and in node_modules dependencies.
- Eliminates the need for pre-compiling or extensive rewriting of dependency code.
- Developers can use TypeScript in Node with no extra build steps; IDEs handle warnings and errors.
- Provides a near-native TypeScript experience similar to Deno and Bun, and is now officially supported by Node.
Future Directions and Limitations
- This update may soon move TypeScript support in Node from experimental to stable.
- Some environments and older Node versions may not support Amaro without backports.
- Efforts are ongoing to extend support to Node 22 and close gaps in adoption.
Key Terms & Definitions
- TypeScript (TS) — a superset of JavaScript adding static types.
- Amaro — Node's official loader that strips TypeScript types at runtime.
- SWC — a high-performance Rust-based compiler used for TypeScript transformations.
- Loader — a tool that processes files before execution in a runtime.
Action Items / Next Steps
- Update Node.js to the latest version to use Amaro loader for TypeScript support.
- Consider revisiting TypeScript in Node projects now that built-in support reduces tooling complexity.