DriteStudio
DRITESTUDIOCloud Infrastructure
Home
ArticlesAbout UsContact

Services

VPS CloudHigh-performance virtual servers with full root access
Web HostingManaged hosting with Plesk and free SSL
Dedicated ServerEnterprise hardware with IPMI access
ColocationSecure data center space for your servers
SecurityWAF, DDoS Protection & 24/7 SOC Monitoring
StatusCheck system uptime and service availability

Quick Links

View All ServicesDocumentationContact Sales
Home
VPS CloudHigh-performance virtual servers with full root access
Web HostingManaged hosting with Plesk and free SSL
Dedicated ServerEnterprise hardware with IPMI access
ColocationSecure data center space for your servers
SecurityWAF, DDoS Protection & 24/7 SOC Monitoring
StatusCheck system uptime and service availability
Articles
About Us
Contact
0%
Node.js รัน TypeScript โดยตรง v23.6+: node app.ts ไม่ต้อง tsc/esbuild
Back to articles

Node.js รัน TypeScript โดยตรง v23.6+: node app.ts ไม่ต้อง tsc/esbuild

Node.js 23.6+ รัน .ts/.mts/.cts native type stripping ESM/CommonJS production setup VS Code config migration guide performance vs tsx ts-node

Software-August 19, 2025-Updated: March 7, 2026

Node.js รัน TypeScript โดยตรงตั้งแต่ v23.6.0 - node app.ts ไม่ต้องคอมไพล์!

Node.js 23.6+ รองรับไฟล์ .ts/.mts/.cts แบบ native ด้วย type stripping ลบ type annotation รันทันที รองรับ ESM/CommonJS

Node.js TypeScript Support

ไฟล์รองรับหมายเหตุ
.ts✅Standard TypeScript
.mts✅ES Module TS
.cts✅CommonJS TS
.tsx❌React JSX

รัน TypeScript ทันที

# ง่ายสุด
node app.ts

# ESM project
node --loader tsx app.ts

# Experimental features
node --experimental-transform-types app.ts

ตัวอย่างใช้งานจริง

app.ts

// Type annotations ลบอัตโนมัติ
interface User {
  id: number;
  name: string;
}

async function getUser(id: number): Promise<User> {
  return { id, name: `User ${id}` };
}

// รันได้เลย node app.ts
const user = await getUser(1);
console.log(user);

package.json

{
  "type": "module",
  "scripts": {
    "dev": "node --watch app.ts",
    "start": "node app.ts"
  }
}

ESM Import ต้องระบุ .ts

// ✅ ถูกต้อง
import { handler } from './routes.ts';
import express from 'express';

// ❌ Error - ไม่รู้ extension
import { handler } from './routes';

ข้อจำกัดสำคัญ

❌ ไม่มี type checking (ต้อง tsc --noEmit)
❌ tsconfig.json ถูก ignore
❌ Decorators/JSX ต้อง flag
❌ ไม่แปลง const enum/private fields
✅ Syntax TS 99% รองรับ

Production Setup แนะนำ

// tsconfig.json (type check เท่านั้น)
{
  "tsBuildInfoFile": ".cache/tsbuildinfo",
  "noEmit": true,
  "strict": true
}
// package.json
{
  "scripts": {
    "typecheck": "tsc --noEmit",
    "dev": "tsx watch src/index.ts",
    "start": "node dist/index.js",
    "build": "tsc"
  }
}

Performance Comparison

MethodCold StartMemoryBuild Step
node app.ts25ms80MB❌ None
tsc → node35ms75MB✅ Type check
tsx45ms120MB⚠️ Runtime

VS Code Config

// settings.json
{
  "typescript.preferences.includePackageJsonAutoImports": "on",
  "typescript.suggest.autoImports": true,
  "node.experimentalTypeAcquisition": true
}

Migration Guide

1. Node.js >= 23.6.0 ✅
2. package.json "type": "module"
3. ระบุ .ts extension ทุก import
4. tsc --noEmit (type check)
5. node app.ts 🚀
Share article:
View more articles
D

DriteStudio | ไดรท์สตูดิโอ

Cloud, VPS, Hosting and Colocation provider in Thailand

Operated by Craft Intertech (Thailand) Co., Ltd.

DRITESTUDIO
DRITESTUDIOCloud Infrastructure

100/280 Soi 17, Delight Village, Bang Khun Thian - Chaitalay, Phanthai Norasing, Samut Sakhon 74000

Services

  • VPS Hosting
  • Web Hosting
  • Dedicated Server
  • Colocation
  • Security Solutions

Company

  • About Us
  • Contact Us
  • System Status

Resources

  • Documentation
  • Help Center
  • Articles

Legal

  • Terms of Service
  • Privacy Policy
  • Refund Policy

© 2026 Craft Intertech (Thailand) Co., Ltd. All rights reserved.

We use cookies

We use cookies to enhance your browsing experience, analyze site traffic, and personalize content. By clicking "Accept All", you consent to our use of cookies. Privacy Policy