타입만 지움
JS 생성은 안 함
enum Color { Red, Blue } // 안 됨
namespace A { // 런타임 코드 있으면 안 됨
export const x = 1;
}
class User {
constructor(public name: string) {} // 안 됨
}
import foo = require('foo'); // 안 됨
export = foo; // 안 됨
const el = <div />; // 안 됨
import { User } from './types.ts'; // 타입이면 import type 필요
ts-node
ts-node app.ts ⇒ 타입체크 가능하고 느리지만 오래된 방법tsx
tsx app.ts ⇒ JS 로 바꾸고 실행만, 타입체크 xtsc + node 컴파일 후 실행
tsc
node dist/index.js
- 가장 정석
- 빌드 결과 생성
- 배포용
node dist/index.js