npm install pnpm
pnpm create react-app <프로젝트 폴더경로>
pnpm add typescript@4 -D
pnpm tsc --init
// tsconfig.json
{
"compilerOptions": {
/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["ES2016","DOM", "DOM.Iterable", "ScriptHost"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"jsx": "preserve",
/* Modules */
"module": "ESNext", /* Specify what module code is generated. */
"rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
"baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
"paths": {
"@components/*": ["src/components/*"],
"@config/*": ["src/config/*"],
"@routes/*": ["src/routes/*"],
"@styles/*": ["src/styles/*"],
"@resource/*": ["src/resource/*"],
"@test/*": ["src/test/*"],
"@@types/*": ["src/types/*"],
"@src/*": ["src/*"]
}, /* Specify a set of entries that re-map imports to additional lookup locations. */
/* JavaScript Support */
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
"checkJs": true,
/* Emit */
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
"declarationMap": true, /* Specify an output folder for all emitted files. */
"removeComments": true, /* Disable emitting comments. */
"noEmit": true, /* Disable emitting files from a compilation. */
"importHelpers": true,
"sourceRoot": "./", /* Specify the root path for debuggers to find the reference source code. */
"inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
"inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"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. */
"strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
"noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
"noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
"noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
"noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
/* Completeness */
"skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"exclude": ["node_modules", "**/*.test.ts"]
}
💡 5버전이 아닌 4버전을 설치한 이유?
현재 날짜 기준(24.03.10)으로 typescript 5 버전은 react-scripts 5.0.1 버전과 unmet peer 충돌이 일어나는데, typescript 4버전 중 가장 최신 버전으로 설치하면 해당 충돌 이슈를 해결할 수 있기 때문이다.
pnpm add zustand
pnpm add @tanstack/react-query
pnpm add react-router-dom
pnpm add tailwindcss
pnpm add styled-components
pnpm add daisyui@latest -D
pnpm add react-icons
pnpm add jest-environment-jsdom -D
jest 버전이 >=28
일 경우, 아래와 같이 환경파일을 설정한다.
// jest.config.js
module.exports = {
testEnvironment: 'jsdom'
}
pnpm add @testing-library/react -D