✊ 필오의 개발일지
Back to Posts
2017년 11월 15일

2/ Typescript_tsconfig.json 프로퍼티의 종류

2/ Typescript_tsconfig.json 프로퍼티의 종류

타입스크립트 정리 글은 이웅재님의 강의 강의록 을 참고하여 작성하였습니다. (짱짱) 오류가 있다면 언제든지 댓글 부탁드립니다.


컴파일러 옵션

실제 프로젝트에서는 컴파일러 옵션을 그렇게 많이 셋팅하진 않는다 . 옵션을 셋팅할 수 있는 전체 스펙은 이 링크 로 가면 확인가능하다 .


1. 최상위 프로퍼티

tsconfig.json 파일에서 제일 상위에 정의되어있는 컴파일 옵션들

2. compileOnSave

파일 변경 후 저장하면 바로 컴파일을 해준다 . 에디터마다 안될 수도 있다.

3. extends

보통 많이 사용하지 않는다 . 사용 예를 들면 , 클라이언트 타입스크립트와 서버사이드 타입스크립트가 있을 때, 설정이 비슷하다면 어떤 파일을 만든 후, 상속을 받아서 작은 부분만 바꿔서 쓰는 경우 사용 가능하다.

// in config/base.json { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true } } // in tsconfig.json { "extends": "./configs/base", "files": [ "main.ts", "supplemental.ts" ] }

4. files, include, exclude

5.@types (중요 !)

TypeScript 2.0 부터 사용 가능해진 내장 type definition 시스템

// compiileOptions : type { "type": "object", "description": "Instructs the TypeScript compiler how to compile .ts files.", "properties": { "typeRoots": { "description": "Specify list of directories for type definition files to be included. Requires TypeScript version 2.0 or later.", "type": "array", "items": { "type": "string" } }, "types": { "description": "Type declaration files to be included in compilation. Requires TypeScript version 2.0 or later.", "type": "array", "items": { "type": "string" } } } }

6. compileOptions

6-1. target과 lib

{ "type": "object", "description": "Instructs the TypeScript compiler how to compile .ts files.", "properties": { "target": { "description": "Specify ECMAScript target version. Permitted values are 'es3', 'es5', 'es2015', 'es2016', 'es2017' or 'esnext'.", "type": "string", "default": "es3", "anyOf": [ { "enum": [ "es3", "es5", "es2015", "es2016", "es2017", "esnext" // 확정은 아니지만 곧 확정될 것 같은 문법들을 모아둔 ] }, { "pattern": "^([eE][sS]([356]|(201[567])|[nN][eE][xX][tT]))$" } ] }, "lib": { "description": "Specify library file to be included in the compilation. Requires TypeScript version 2.0 or later.", "type": "array", "items": { "type": "string", "enum": [ "es5", "es6", "es2015", "es7", "es2016", "es2017", "esnext", "dom", "dom.iterable", "webworker", "scripthost", "es2015.core", "es2015.collection", "es2015.generator", "es2015.iterable", "es2015.promise", "es2015.proxy", "es2015.reflect", "es2015.symbol", "es2015.symbol.wellknown", "es2016.array.include", "es2017.object", "es2017.sharedmemory", "esnext.asynciterable" ] } }, "noLib": { "description": "Do not include the default library file (lib.d.ts).", "type": "boolean" } } }

target

lib

6-2. compileOptions: outDir, outFile

{ "type": "object", "description": "Instructs the TypeScript compiler how to compile .ts files.", "properties": { "outFile": { "description": "Concatenate and emit output to single file.", "type": "string" }, "outDir": { "description": "Redirect output structure to the directory.", "type": "string" }, "rootDir": { "description": "Specifies the root directory of input files. Use to control the output directory structure with --outDir.", "type": "string" } } }

6-3. compileOptions: module

module

moduleResolution

paths 와 baseUrl

rootDirs

{ "type": "object", "description": "Instructs the TypeScript compiler how to compile .ts files.", "properties": { "module": { "description": "Specify module code generation: 'none', 'CommonJS', 'Amd', 'System', 'UMD', or 'es2015'.", "enum": ["commonjs", "amd", "umd", "system", "es6", "es2015", "none"] }, "moduleResolution": { "description": "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) .", "type": "string", "pattern": "^(([Nn]ode)|([Cc]lassic))$", "default": "classic" }, "baseUrl": { "description": "Base directory to resolve non-relative module names.", "type": "string" }, "paths": { "description": "Specify path mapping to be computed relative to baseUrl option.", "type": "object" }, "rootDirs": { "description": "Specify list of root directories to be used when resolving modules.", "type": "array", "items": { "type": "string" } } } }

현재 플젝 tsconfig.json

처음보는 옵션들이 있어서 정리해보았다 . 참고 : 타입스크립트 공식 페이지 

allowSyntheticDefaultImports: true

noImplicitAny: false

preserveConstEnums: true

allowJs : false

sourceMap : true

noImplicitReturns : true

noUnusedParameters : true

noUnusedLocals : true


참고링크

  1. http://jaroinside.tistory.com/10 
  2. http://poiemaweb.com/typeScript-vscode 
  3. http://spectrumdig.blogspot.kr/2016/12/chrome-source-map-coffeescripttypescrip.html 
Previous2016년 A월 B일
Nextoverview

Related

© 2025 Felix