tsc

Tony·2022년 12월 30일
0

typescript

목록 보기
13/21

tsc 를 빌드 스크립트에서 실행하게 되면
tsconfig.json에 있는 설정대로 타입스크립트를 컴파일해서 자바스크립트로 변환한다

// package.json
{
  // ...
  "scripts": {
    "build": "tsc"
  }
}

// tsconfig.json
{
  "compilerOptions": {
    /* Language and Environment */
    /* Modules */
    "module": "esnext" /* Specify what module code is generated. */,
    "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
    /* Emit */
    "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
    "outDir": "lib" /* Specify an output folder for all emitted files. */,

    /* Interop Constraints */
    "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
    "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,

    /* Type Checking */
    "strict": true /* Enable all strict type-checking options. */,
    "noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied `any` type.. */,
    "strictNullChecks": true /* When type checking, take into account `null` and `undefined`. */,
    "noImplicitThis": true /* Enable error reporting when `this` is given the type `any`. */,
    "noUnusedLocals": true /* Enable error reporting when a local variables aren't read. */,
    "noUnusedParameters": true /* Raise an error when a function parameter isn't read */,
    /* Completeness */
    "skipLibCheck": true /* Skip type checking all .d.ts files. */
  },
  "include": ["src"],
  "exclude": ["node_modules", "lib"]
}
  • src 안에 있는 typescript 파일 ("include": ["src"])을
  • lib 폴더안에 javascript파일로 변환 ("outDir": "lib")
profile
움직이는 만큼 행복해진다

0개의 댓글