π§‘ typeRoots, types
{
...
"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"
}
}
...
}
π§‘ @types
- TypeScript 2.0 λΆν° μ¬μ© κ°λ₯ν΄μ§ λ΄μ₯ type definition μμ€ν
- μ무 μ€μ μ μνλ©΄ ?
- node_modules/@types λΌλ λͺ¨λ κ²½λ‘λ₯Ό μ°Ύμμ μ¬μ©
- typeRoots λ₯Ό μ¬μ©νλ©΄ ?
- λ°°μ΄ μμ λ€μ΄μλ κ²½λ‘λ€ μλμλ§ κ°μ Έμ΅λλ€.
- types λ₯Ό μ¬μ©νλ©΄ ?
- λ°°μ΄ μμ λͺ¨λ νΉμ ./node_modules/@types/ μμ λͺ¨λ μ΄λ¦μμ μ°Ύμμ΅λλ€.
- [] λΉ λ°°μ΄μ λ£λλ€λ건 μ΄ μμ€ν
μ μ΄μ©νμ§ μκ² λ€λ κ²μ
λλ€.
- typeRoots μ types λ₯Ό κ°μ΄ μ¬μ©νμ§ μμ΅λλ€.
π§‘ target κ³Ό lib
{
...
"target": {
"description": "Specify ECMAScript target version. Permitted values are 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018' or 'esnext'.",
"type": "string",
"default": "es3",
"anyOf": [
{
"enum": [
"es3",
"es5",
"es6",
"es2015",
"es2016",
"es2017",
"es2018",
"esnext"
]
}
{
"pattern": "^([eE][sS]([356]|(201[5678])|[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",
"es2018",
"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.intl",
"es2017.sharedmemory",
"es2017.string",
"es2017.typedarrays",
"es2018.intl",
"es2018.promise",
"es2018.regexp",
"esnext.asynciterable",
"esnext.array",
"esnext.intl",
"esnext.symbol"
]
},
...
}
- target
- λΉλμ κ²°κ³Όλ¬Όμ μ΄λ€ λ²μ μΌλ‘ ν κ²μ΄λ
- μ§μ μ μνλ©΄ es3 μ
λλ€.
- lib
- κΈ°λ³Έ type definition λΌμ΄λΈλ¬λ¦¬λ₯Ό μ΄λ€ κ²μ μ¬μ©ν κ²μ΄λ
- lib λ₯Ό μ§μ νμ§ μμ λ,
- target μ΄ 'es3' μ΄κ³ , λν΄νΈλ‘ lib.d.ts λ₯Ό μ¬μ©ν©λλ€.
- target μ΄ 'es5' μ΄λ©΄, λν΄νΈλ‘ dom, es5, scripthost λ₯Ό μ¬μ©ν©λλ€.
- target μ΄ 'es6' μ΄λ©΄, λν΄νΈλ‘ dom, es6, dom.iterable, scripthost λ₯Ό μ¬μ©ν©λλ€.β
- lib λ₯Ό μ§μ νλ©΄ κ·Έ lib λ°°μ΄λ‘λ§ λΌμ΄λΈλ¬λ¦¬λ₯Ό μ¬μ©νλλ€.
- βλΉ [] => 'no definition found μ΄μ©κ΅¬'
π§‘ outDir, outFile
{
...
"outFile": {
"description": "Concatenate and emit output to single file.",
"type": "string"
},
"outDir": {
"description": "Redirect output structure to the directory.",
"type": "string"
},
...
}
π§‘ module
{
...
"module": {
"description": "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015' or 'esnext'.",
"type": "string",
"anyOf": [
{
"enum": [
"commonjs",
"amd",
"umd",
"system",
"es6",
"es2015",
"esnext",
"none"
]
},
{
"pattern": "^([cC][oO][mM][mM][oO][nN][jJ][sS]|[aAuU][mM][dD]|[sS][yY][sS][tT][eE][mM]|[eE][sS]([356]|(201[567])|[nN][eE][xX][tT])|[nN][oO][nN][eE])$"
}
]
},
...
}
- module
- μ»΄νμΌ λ λͺ¨λμ κ²°κ³Όλ¬Όμ μ΄λ€ λͺ¨λ μμ€ν
μΌλ‘ ν μ§λ₯Ό κ²°μ
- target μ΄ 'es6' μ΄λ©΄ es6 κ° λν΄νΈμ΄κ³ ,
- target μ΄ 'es6' κ° μλλ©΄ commonjs κ° λν΄νΈ μ
λλ€.
- AMD λ System μ μ¬μ©νλ €λ©΄, outFile μ΄ μ§μ λμ΄μΌ ν©λλ€.
- ES6 λ ES2015 λ₯Ό μ¬μ©νλ €λ©΄, target μ΄ es5 μ΄νμ¬μΌ ν©λλ€.
- moduleResolution
- ts μμ€μμ λͺ¨λμ μ¬μ©νλ λ°©μμ μ§μ ν΄μΌ ν©λλ€.
- Classic μλλ©΄ Node μ
λλ€.
- CommonJS μΌλλ§ Node λΌκ³ μκ°νμλ©΄ λ©λλ€.