npm init => package.json 생성
entry point : app.ts
npm i typescript
npx tsc --init => tsconfig.json 생성
아래와 같이 활성화 되어있음.
target: es2016
module: commonjs
strict: true
esModuleInterop: true
skipLibCheck: true
forceConsistentCasingInFileNames: true
allowJs : true << js 프로젝트에서 ts 프로젝트로 넘어갈때 js + ts 같이 로딩 가능하도록
각 폴더에서 npx tsc --noEmit 실행해서 에러 찾기
npm i -D nodemon ts-node
package.json
...
"scripts": {
"start": "nodemon app"
},
...
npm i express
npm i -D @types/express
**Library가 TS가 아닌 DT일 경우 @types/라이브러리명 설치해줘야함. **
이제
import from
export
export default
ES module을 사용할 수 있다.
TIP : VSCODE에서 이름 입력후 자동으로 import하고 싶다면
ctrl + i
ctrl + .(콤마)
단축키로 불러오자. 편하게
> prettier
npm i -D prettier
command + p => ">settings"
Format On Paste / Save / Type 모두 체크표시
default formatter => prettier - Code formatter 지정
> eslint
npm i -D eslint
npm i -D eslint-plugin-import
npm i -D eslint-config-airbnb-base
npm i -D eslint-config-prettier
npm i -D eslint-plugin-node
폴더에 .eslintrc.js파일을 생성
module.exports = {
extends: ["airbnb-base", "plugin:node/recommended", "prettier"],
}