개발 공부/typescript

typescript 파일 실행시키기.

억만장작 2021. 9. 12. 19:39

적당히 typescript 파일을 하나 만들자.

// study.ts
const arrow2 = (a: number, b: number) => {
    console.log(a);
    console.log(b);
};

arrow2(1, 2);
npm install -g @types/node typescript ts-node

를 통해 node와 typescript, ts-node를 받는다.

ts-node study.ts로 실행시킨다.

tsc study.ts를 통해 js로 컴파일한 후
node study.js로 실행 시키는 방법도 있다.