{
"compileOnSave": false, // ํ์ผ ์ ์ฅ ์ ์๋์ผ๋ก ์ปดํ์ผํ์ง ์์
"compilerOptions": {
"rootDir": ".", // ํ๋ก์ ํธ์ ๋ฃจํธ ๋๋ ํ ๋ฆฌ ์ค์ (์ปดํ์ผ๋ .js ํ์ผ์ด ์์ฑ๋ ๊ธฐ์ค ๊ฒฝ๋ก)
"sourceMap": true, // .ts ํ์ผ์ ๋์๋๋ .js.map ํ์ผ์ ์์ฑํ์ฌ ๋๋ฒ๊น
๊ฐ๋ฅํ๊ฒ ํจ
"declaration": false, // .d.ts ํ์
์ ์ธ ํ์ผ ์์ฑ ์ฌ๋ถ (false๋ฉด ์์ฑํ์ง ์์)
"moduleResolution": "node", // ๋ชจ๋ ํด์ ๋ฐฉ์ ์ง์ (Node.js ๋ฐฉ์ ์ฌ์ฉ - node_modules ๊ธฐ์ค)
"emitDecoratorMetadata": true, // ๋ฐ์ฝ๋ ์ดํฐ ์ฌ์ฉ ์ ํ์
๋ฉํ๋ฐ์ดํฐ๋ฅผ ํจ๊ป ์์ฑ (Reflect.metadata ๋ฑ ๋ฐ์ฝ๋ ์ดํฐ์ ํจ๊ป ํ์
์ ๋ณด๋ฅผ runtime์ ์ ์งํ๊ธฐ์ํจ)
"experimentalDecorators": true, // ์คํ์ ์ธ ๋ฐ์ฝ๋ ์ดํฐ ๋ฌธ๋ฒ์ ์ฌ์ฉํ ์ ์๊ฒ ํจ (@ ๋ฐ์ฝ๋ ์ดํฐ)
"importHelpers": true, // TypeScript์ ์ค๋ณต๋๋ ํฌํผ ํจ์๋ค์ tslib์์ ๊ฐ์ ธ์ค๋๋ก ์ค์ . ์ค๋ณต์ฝ๋ ์ ๊ฑฐ, ๋น๋ํฌ๊ธฐ ์ถ์, ๊น๋ํ ๋ฒ๋ค ์์ฑ(tslibํจํค์ง๋ฅผ ์ค์นํด์ผํ๋ค.)
"target": "es2015", // TypeScript๋ฅผ ์ปดํ์ผํ ๋ ๋ณํ๋ JavaScript ๋ฒ์ (ES6)
"module": "esnext", // import/export ๋ฌธ๋ฒ์ ๋ชจ๋ ํ์ ์ง์ ('commonjs', 'amd', 'es2015', 'esnext' ๋ฑ)
"lib": ["es2017", "dom"], // ์ฌ์ฉ ๊ฐ๋ฅํ ๋ด์ฅ API๋ฅผ ์ ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํฌํจ (์: Promise, DOM ๋ฑ)
"skipLibCheck": true, // node_modules ๋ด์ .d.ts ํ์ผ ํ์
๊ฒ์ฌ ์๋ต (์ปดํ์ผ ์๋ ํฅ์)
"skipDefaultLibCheck": true, // ๊ธฐ๋ณธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ ๊ฒ์ฌ ์๋ต
"baseUrl": ".", // ๋ชจ๋์ importํ ๋ ๊ธฐ์ค์ด ๋๋ ๊ฒฝ๋ก ์ค์
"paths": {
"@dongsun/shared": ["libs/shared/src/index.ts"] // ๊ฒฝ๋ก ๋ณ์นญ ์ค์ (์: import from '@project/shared')
}
},
"exclude": ["node_modules", "tmp"] // ์ปดํ์ผ ๋์์์ ์ ์ธํ ๋๋ ํ ๋ฆฌ
}
{
"extends": "../../tsconfig.base.json", // ์์ ๋๋ ํ ๋ฆฌ์ ์๋ ๊ณตํต tsconfig ์ค์ ์ ๊ฐ์ ธ์์ ํ์ฅ
"compilerOptions": {
"jsx": "preserve", // JSX ๋ฌธ๋ฒ์ ๊ทธ๋๋ก ์ ์งํด์ Babel ๊ฐ์ ๋ค๋ฅธ ํธ๋์คํ์ผ๋ฌ๊ฐ ์ฒ๋ฆฌํ๊ฒ ํจ(React, Next.js์์ ์ฃผ๋ก ์ฌ์ฉ)
"allowJs": true, // .js ํ์ผ๋ TypeScript์์ import ํ์ฌ ์ฌ์ฉํ ์ ์๊ฒ ํ์ฉ
"esModuleInterop": true, // CommonJS ๋ชจ๋์ ES6 ๋ฐฉ์์ผ๋ก import ๊ฐ๋ฅํ๊ฒ ํด์ค (import fs from 'fs'), default export๊ฐ ์๋ ๋ชจ๋๋ default์ฒ๋ผ ์ฌ์ฉํ ์ ์๊ฒ ํด์ค
"allowSyntheticDefaultImports": true, // default export๊ฐ ์์ด๋ default import ๋ฌธ๋ฒ์ ํ์ฉ(esModuleInterop ์์ด๋ ์๋ํ๋, ๋ ๋ค true๊ฐ ์ผ๋ฐ์ )
"strict": false, // TypeScript์ strict ๋ชจ๋ (์๊ฒฉํ ํ์
๊ฒ์ฌ) ๋นํ์ฑํ(true๋ฉด null ์ฒดํฌ, ํ์
์ถ๋ก ๋ฑ ๋งค์ฐ ์๊ฒฉํด์ง)
"forceConsistentCasingInFileNames": true, // ํ์ผ import ์ ๋์๋ฌธ์ ์ผ์น ๊ฐ์ (ex: ์ค์ ํ์ผ์ `MyComponent.tsx`์ธ๋ฐ `myComponent`๋ก importํ๋ฉด ์ค๋ฅ)
"noEmit": true, // ์ค์ ๋ก JavaScript ํ์ผ(.js)๋ก๋ ์ถ๋ ฅํ์ง ์์ (๋น๋ ๊ฒฐ๊ณผ๋ฌผ ์์ฑ ์ ํจ)์ฃผ๋ก ํ์
๊ฒ์ฌ๋ง ํ ๋ ์ฌ์ฉ (Next.js์์๋ Babel์ด ์ปดํ์ผํ๋ฏ๋ก TS๊ฐ emitํ ํ์ ์์)
"resolveJsonModule": true, // .json ํ์ผ๋ import ๊ฐ๋ฅํ๊ฒ ํด์ค (ex: import config from './config.json')
"isolatedModules": true, // ๊ฐ ํ์ผ์ ๊ฐ๋ณ์ ์ธ ๋ชจ๋๋ก ์ทจ๊ธ (Next.js ๋ฑ์์ ํ์ ์ค์ ) Babel์ ์ฌ์ฉํด ํธ๋์คํ์ผ๋งํ ๋, TS ์ปดํ์ผ๋ฌ๊ฐ ์ ์ฒด ํ๋ก๊ทธ๋จ์ ์ ์ ์๊ธฐ ๋๋ฌธ์ ํ์
"incremental": true, // ์ด์ ์ปดํ์ผ ๊ฒฐ๊ณผ๋ฅผ ์ ์ฅํด์ ๋ค์ ์ปดํ์ผ ์ ์๋ ํฅ์ (์บ์ ๊ธฐ๋ฐ)
"types": ["jest", "node"] // ๊ธ๋ก๋ฒ ํ์
์ ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ง์ (jest ํ
์คํธ์ฉ, node.js ๊ด๋ จ ํ์
ํฌํจ)
},
"include": [
"**/*.ts", // ๋ชจ๋ .ts ํ์ผ ํฌํจ
"**/*.tsx", // ๋ชจ๋ .tsx (React ์ปดํฌ๋ํธ ๋ฑ) ํ์ผ ํฌํจ
"**/*.js", // .js ํ์ผ๋ ํฌํจ (allowJs: true์ผ ๊ฒฝ์ฐ ํ์)
"**/*.jsx", // .jsx ํ์ผ๋ ํฌํจ
"next-env.d.ts" // Next.js์์ ์๋ ์์ฑ๋๋ ํ์
์ ์ ํฌํจ
],
"exclude": [
"node_modules", // ์์กด์ฑ ํด๋ ์ ์ธ
"jest.config.ts", // Jest ์ค์ ํ์ผ ์ ์ธ
"src/**/*.spec.ts", // ํ
์คํธ ํ์ผ ์ ์ธ
"src/**/*.test.ts" // ํ
์คํธ ํ์ผ ์ ์ธ
]
}
{
"compilerOptions": {
"strict": true,
"strictNullChecks": true, // null/undefined์ ๋ํ ์๊ฒฉํ ์ฒดํฌ
"noImplicitAny": true, // ํ์
์ถ๋ก ์ any ๋ฐฉ์ง
"strictFunctionTypes": true, // ํจ์ ํ์
๋ ์๊ฒฉํ ์ฒดํฌ
"noUnusedLocals": true, // ์ ์ธ๋ง ๋๊ณ ์ฌ์ฉ๋์ง ์๋ ๋ณ์ ๊ฒฝ๊ณ
"noUnusedParameters": true // ์ฌ์ฉ๋์ง ์๋ ํจ์ ํ๋ผ๋ฏธํฐ ๊ฒฝ๊ณ
"noFallthroughCasesInSwitch": true //switch๋ฌธ ๋ ์๊ฒฉํ๊ฒ ๊ด๋ฆฌ. break๋ฅผ ๋น ๋จ๋ฆฌ๋ ์ค์ ๋ฐฉ์งํด์ค
"exactOptionalPropertyTypes": true //optional ํ๋กํผํฐ์์ "์์"๊ณผ "undefined"๋ฅผ ๊ตฌ๋ถ
"useUnknownInCatchVariables": true // ๊ธฐ๋ณธ์ ์ผ๋ก catch (e)๋ any ํ์
์ธ๋ฐ, ์ด๊ฑธ unknown์ผ๋ก ๋ฐ๊ฟ์ ํ์
๋จ์ธ์ ์ ๋
"checkJs": true, // ์ผ๋ฐ js ํ์ผ์์๋ ์๋ฌ์ฒดํฌ ์ฌ๋ถ
"declaration": true, //์ปดํ์ผ์ .d.ts ํ์ผ๋ ์๋์ผ๋ก ํจ๊ป์์ฑ (ํ์ฌ์ฐ๋ ๋ชจ๋ ํ์
์ด ์ ์๋ ํ์ผ)
"removeComments": true, //์ปดํ์ผ์ ์ฃผ์์ ๊ฑฐ
"strictPropertyInitialization": true, //class constructor ์์ฑ์ ํ์
์ฒดํฌ ๊ฐํ๊ฒ
"noImplicitThis": true, //this ํค์๋๊ฐ any ํ์
์ผ ๊ฒฝ์ฐ ๊ฒฝ๊ณ
"noImplicitReturns": true, //ํจ์์์ return ๋นผ๋จน์ผ๋ฉด ๊ฒฝ๊ณ
}
}
tsconfig.json
์ ์ฌ๋ฌ ๋ฒ์ ์ผ๋ก ๋ถ๋ฆฌํด์ ๋ชฉ์ ์ ๋ง๊ฒ ์ค์ ์ ๊ด๋ฆฌํ ์ ์๋ค.
๊ณต์์ ์ผ๋ก ํ์ผ ์ด๋ฆ์ ์ ์ฝ์ ์๊ณ , ๊ด๋ก์ ์ผ๋ก ์ฌ์ฉ๋๋ ์ด๋ฆ์ ๋ํด ์์๋ณด์!
์ด๋ ๊ฒ ์์ฑํด ๋์ ์ค์ ๋ค์ tsc -p tsconfig.build.json
์ผ๋ก ๋น๋ํ ๋ ์ง์ ํด์ฃผ๊ฑฐ๋ ๋น๋ ์คํฌ๋ฆฝํธ์ ๋ฑ๋กํด๋๋ฉด ๋๋ค.
{
"scripts": {
"build": "tsc -p tsconfig.build.json"
}
}
์ค์ ์ด ๋จ์ํ๊ฑฐ๋ ํ ๋ด ํฌ๋งท ์ผ๊ด์ฑ์ด ์ค์ํ ๋(์ฃผ์์ฌ์ฉ ๋ถ๊ฐ๋ฅ, ์ ์ ๊ตฌ์กฐ) โ .eslintrc.json
์กฐ๊ฑด๋ถ ์ค์ , ํ๊ฒฝ๋ณ ๋ถ๊ธฐ, ๋์ import๊ฐ ํ์ํ ๋(js์ฌ์ฉ ๊ฐ๋ฅ) โ .eslintrc.js
nx๊ธฐ๋ฐ ๋ชจ๋ ธ๋ ํฌ ๋ฃจํธ๋๋ ํ ๋ฆฌ