Back to blog

Node.js Now Runs TypeScript Natively: What This Changes for Developers

Hello HaWkers, the development community just received one of the most awaited updates in recent years: Node.js 23.6 now runs TypeScript natively, without the need for extra configurations, transpilers, or experimental flags.

If you have ever lost hours configuring ts-node, ts-node-dev, or dealing with broken source maps, this news will completely change your workflow. Let's understand what this means in practice and how to take advantage of this revolution.

The Problem That Tormented Developers

Traditionally, running TypeScript in Node.js has always been a multi-step process. You needed to install extra dependencies, configure tsconfig.json, define build scripts, deal with source maps, and still face performance issues in development.

// package.json - The old way
{
  "scripts": {
    "dev": "ts-node-dev --respawn src/index.ts",
    "build": "tsc",
    "start": "node dist/index.js"
  },
  "devDependencies": {
    "typescript": "^5.0.0",
    "ts-node": "^10.9.0",
    "ts-node-dev": "^2.0.0",
    "@types/node": "^20.0.0"
  }
}

This setup worked, but it was verbose, slow, and prone to errors. Each project required the same repetitive configurations, and keeping everything updated was a constant headache.

Type Stripping: Node.js's Elegant Solution

Node.js 23.6 introduced an approach called "type stripping." Instead of transpiling all TypeScript code to JavaScript, Node.js simply removes type annotations and executes the resulting code.

// server.ts - Now works directly in Node.js!
interface User {
  id: number;
  name: string;
  email: string;
}

const users: User[] = [];

function addUser(user: User): void {
  users.push(user);
}

const newUser: User = {
  id: 1,
  name: "Jeff Bruchado",
  email: "jeff@example.com"
};

addUser(newUser);
console.log(users);

To run this code, now it's just:

# Node.js 23.6+
node server.ts

# No flags, no configuration, nothing!

That's right. Just node and the TypeScript file name. Node.js automatically detects that it's TypeScript and makes the magic happen.

Node.js TypeScript execution

How Type Stripping Works

The process is surprisingly simple: Node.js identifies all type annotations (interfaces, types, generics, etc.) and replaces them with whitespace. The resulting JavaScript code is then executed normally.

// Original TypeScript code
function calculate(a: number, b: number): number {
  return a + b;
}

// After type stripping (internally)
function calculate(a        , b        )         {
  return a + b;
}

This approach has huge advantages:

  1. Performance: No complete transpilation overhead
  2. Simplicity: No complicated source maps
  3. Compatibility: Works with most existing TypeScript code
  4. Speed: Almost instant initialization

Advanced Features with --experimental-transform-types

For more advanced TypeScript features that require code transformation (like enums, decorators, parameter properties), Node.js offers the --experimental-transform-types flag:

// advanced.ts
enum Status {
  Active = "ACTIVE",
  Inactive = "INACTIVE",
  Pending = "PENDING"
}

class UserService {
  constructor(
    private readonly apiUrl: string,
    private readonly apiKey: string
  ) {}

  async fetchUser(id: number): Promise<User> {
    const response = await fetch(`${this.apiUrl}/users/${id}`, {
      headers: { 'Authorization': `Bearer ${this.apiKey}` }
    });
    return response.json();
  }
}

const service = new UserService(
  "https://api.example.com",
  "secret-key-123"
);

To run this code with enums and parameter properties:

node --experimental-transform-types advanced.ts

This flag activates complete transpilation, automatically generating source maps and supporting the entire spectrum of TypeScript features.

Important Limitations to Consider

Although revolutionary, native support has some limitations you need to know:

1. tsconfig.json is Ignored

Node.js does not read your tsconfig.json. Features like path aliases, custom compiler options, and specific transformations do not work:

// tsconfig.json - These configs are NOT used by Node.js
{
  "compilerOptions": {
    "paths": {
      "@models/*": ["./src/models/*"],
      "@utils/*": ["./src/utils/*"]
    },
    "target": "ES2015"
  }
}

2. Only "Erasable" Syntax

In default mode (without flags), only syntax that can be removed is supported. Features like enums, namespaces, and decorators require --experimental-transform-types.

3. No Type Checking

Node.js does NOT check types. It just removes the annotations. For type checking, you still need to run tsc --noEmit:

# Check types without generating files
tsc --noEmit

# Then run the code
node server.ts

Modern Setup for TypeScript Projects in 2025

Here is how to set up a modern TypeScript project taking advantage of Node.js native support:

// package.json - Minimal setup in 2025
{
  "name": "modern-nodejs-typescript",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "dev": "node --watch src/index.ts",
    "typecheck": "tsc --noEmit",
    "test": "node --test src/**/*.test.ts"
  },
  "devDependencies": {
    "typescript": "^5.8.0",
    "@types/node": "^22.0.0"
  }
}
// tsconfig.json - Minimal configuration
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "skipLibCheck": true,
    "noEmit": true
  },
  "include": ["src/**/*"]
}

With this configuration:

  • node --watch src/index.ts: Runs TypeScript with native hot-reload
  • tsc --noEmit: Checks types without generating files
  • node --test: Runs TypeScript tests directly

Compatibility with TypeScript 5.8

TypeScript 5.8 was released with the --erasableSyntaxOnly flag specifically to support this Node.js workflow:

# Check if your code uses only erasable syntax
tsc --erasableSyntaxOnly --noEmit

This flag ensures that your TypeScript code is compatible with Node.js type stripping, warning about syntaxes that require transformation.

Impact on Development Productivity

The change is profound. Developers report savings of up to 8 hours per week just by removing configuration and build complexity. The almost instant server initialization in development eliminates the frustration of waiting for transpilation.

// Practical example: Express API with native TypeScript
import express, { Request, Response } from 'express';

interface CreateUserRequest {
  name: string;
  email: string;
}

const app = express();
app.use(express.json());

app.post('/users', (req: Request<{}, {}, CreateUserRequest>, res: Response) => {
  const { name, email } = req.body;

  // User creation logic
  const user = { id: Date.now(), name, email };

  res.status(201).json(user);
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`);
});

Save as server.ts and run: node --watch server.ts. Done. You don't need anything else.

The Future of Node.js + TypeScript Development

With Node.js 24 entering LTS (Long-Term Support) in October 2025, native TypeScript support will be stable and ready for production. This means that most new projects can completely abandon tools like ts-node.

The trend is clear: TypeScript has become so fundamental to the JavaScript ecosystem that even the most popular runtime on the market now supports it natively.

If you are starting a new project or refactoring an existing one, seriously consider taking advantage of this functionality. The reduction in complexity and the productivity gain are significant.

To deepen your knowledge about TypeScript and its best practices, I recommend checking out another article: TypeScript: The Most Used Language on GitHub in 2025 where you will discover why TypeScript surpassed JavaScript in popularity.

Let's go! 🦅

📚 Want to Master TypeScript for Real?

This article covered Node.js native TypeScript support, but there is much more to explore about modern backend development.

Developers who invest in solid knowledge about TypeScript and Node.js tend to have more opportunities in the market.

Complete Study Material

If you want to master JavaScript and TypeScript from basics to advanced, I have prepared a complete guide:

Investment options:

  • $4.90 (single payment)

👉 Learn About JavaScript Guide

💡 Material updated with industry best practices

Comments (0)

This article has no comments yet 😢. Be the first! 🚀🦅

Add comments