๐งก 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 ๋ผ๊ณ ์๊ฐํ์๋ฉด ๋ฉ๋๋ค.