DriteStudio
DRITESTUDIOクラウドインフラ
ホーム
記事会社情報お問い合わせステータス
0%
Node.js รัน TypeScript โดยตรง v23.6+: node app.ts ไม่ต้อง tsc/esbuild
記事一覧へ戻る

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-更新: February 24, 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 🚀
共有:
さらに記事を見る
D

DriteStudio

タイの Cloud・VPS・Hosting・Colocation プロバイダー

Craft Intertech (Thailand) Co., Ltd. が運営

DRITESTUDIOクラウドインフラ

タイ サムットサーコーン県 パンタイノラシン バンクンティアン-チャイタレー Delight Village ソイ17 100/280 74000

サービス

  • VPSホスティング
  • 専用サーバー
  • Webホスティング
  • セキュリティソリューション

会社

  • 会社情報
  • お問い合わせ
  • システムステータス

サポート

  • サポートチケット
  • ドキュメント
  • ヘルプセンター

© 2026 Craft Intertech (Thailand) Co., Ltd. 無断転載を禁じます。

プライバシーポリシー利用規約返金ポリシー

Cookieを使用しています

当サイトでは、ブラウジング体験の向上、サイトトラフィックの分析、コンテンツのパーソナライズのためにCookieを使用しています。「すべて受け入れる」をクリックすると、Cookieの使用に同意したことになります。 プライバシーポリシー