
tsconfig.json 파일에 붙여 넣기
{
"compilerOptions": {
"target": "es5", // 'es3', 'es5', 'es2015', 'es2016', 'es2017','es2018', 'esnext' 가능
"module": "ESNext", //무슨 import 문법 쓸건지 'commonjs', 'amd', 'es2015', 'esnext'
"allowJs": true, // js 파일들 ts에서 import해서 쓸 수 있는지
"checkJs": true, // 일반 js 파일에서도 에러체크 여부
"jsx": "preserve", // tsx 파일을 jsx로 어떻게 컴파일할 것인지 'preserve', 'react-native', 'react'
"declaration": true, //컴파일시 .d.ts 파일도 자동으로 함께생성 (현재쓰는 모든 타입이 정의된 파일)
"outDir": "./", //js파일 아웃풋 경로바꾸기
"rootDir": "./", //루트경로 바꾸기 (js 파일 아웃풋 경로에 영향줌)
"removeComments": true, //컴파일시 주석제거
"strict": true, //strict 관련, noimplicit 어쩌구 관련 모드 전부 켜기
"noImplicitAny": true, //any타입 금지 여부
"strictNullChecks": true, //null, undefined 타입에 이상한 짓 할시 에러내기
"strictFunctionTypes": true, //함수파라미터 타입체크 강하게
"strictPropertyInitialization": true, //class constructor 작성시 타입체크 강하게
"noImplicitThis": true, //this 키워드가 any 타입일 경우 에러내기
"alwaysStrict": true, //자바스크립트 "use strict" 모드 켜기
"allowSyntheticDefaultImports": true, // TypeScript 컴파일러가 ES 모듈이 아닌 모듈에서 export = 문법을 허용
"moduleResolution": "node", //모듈 경로를 찾아가는 방식을 설정
"noUnusedLocals": true, //쓰지않는 지역변수 있으면 에러내기
"noUnusedParameters": true, //쓰지않는 파라미터 있으면 에러내기
"noImplicitReturns": true, //함수에서 return 빼먹으면 에러내기
"noFallthroughCasesInSwitch": true, //switch문 이상하면 에러내기
},
"include": ["src/**/*"], // 소스 경로를 'src/' 폴더로 변경
"exclude": ["node_modules"] // 'node_modules' 폴더를 제외
}
개발을 하면서 타입에러 이외에도 기타 다양한 에러를 잡기 위한 설정으로
아래 링크를 통해 더 많은 정보를 확인할 수 있다.
https://www.typescriptlang.org/tsconfig
TSConfig Reference - Docs on every TSConfig option
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
www.typescriptlang.org
'TypeScript' 카테고리의 다른 글
함수에 타입 지정하는 법 (0) | 2023.07.02 |
---|---|
타입을 미리 정하기 애매할 때 (union, any, unknown) (0) | 2023.07.02 |
타입스크립트 기본 타입 정리 (primitive types) (0) | 2023.07.02 |
React 프로젝트에서 TypeScript를 사용하려면 (0) | 2023.07.02 |
타입스크립트 쓰는 이유 (0) | 2023.07.01 |

tsconfig.json 파일에 붙여 넣기
{
"compilerOptions": {
"target": "es5", // 'es3', 'es5', 'es2015', 'es2016', 'es2017','es2018', 'esnext' 가능
"module": "ESNext", //무슨 import 문법 쓸건지 'commonjs', 'amd', 'es2015', 'esnext'
"allowJs": true, // js 파일들 ts에서 import해서 쓸 수 있는지
"checkJs": true, // 일반 js 파일에서도 에러체크 여부
"jsx": "preserve", // tsx 파일을 jsx로 어떻게 컴파일할 것인지 'preserve', 'react-native', 'react'
"declaration": true, //컴파일시 .d.ts 파일도 자동으로 함께생성 (현재쓰는 모든 타입이 정의된 파일)
"outDir": "./", //js파일 아웃풋 경로바꾸기
"rootDir": "./", //루트경로 바꾸기 (js 파일 아웃풋 경로에 영향줌)
"removeComments": true, //컴파일시 주석제거
"strict": true, //strict 관련, noimplicit 어쩌구 관련 모드 전부 켜기
"noImplicitAny": true, //any타입 금지 여부
"strictNullChecks": true, //null, undefined 타입에 이상한 짓 할시 에러내기
"strictFunctionTypes": true, //함수파라미터 타입체크 강하게
"strictPropertyInitialization": true, //class constructor 작성시 타입체크 강하게
"noImplicitThis": true, //this 키워드가 any 타입일 경우 에러내기
"alwaysStrict": true, //자바스크립트 "use strict" 모드 켜기
"allowSyntheticDefaultImports": true, // TypeScript 컴파일러가 ES 모듈이 아닌 모듈에서 export = 문법을 허용
"moduleResolution": "node", //모듈 경로를 찾아가는 방식을 설정
"noUnusedLocals": true, //쓰지않는 지역변수 있으면 에러내기
"noUnusedParameters": true, //쓰지않는 파라미터 있으면 에러내기
"noImplicitReturns": true, //함수에서 return 빼먹으면 에러내기
"noFallthroughCasesInSwitch": true, //switch문 이상하면 에러내기
},
"include": ["src/**/*"], // 소스 경로를 'src/' 폴더로 변경
"exclude": ["node_modules"] // 'node_modules' 폴더를 제외
}
개발을 하면서 타입에러 이외에도 기타 다양한 에러를 잡기 위한 설정으로
아래 링크를 통해 더 많은 정보를 확인할 수 있다.
https://www.typescriptlang.org/tsconfig
TSConfig Reference - Docs on every TSConfig option
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
www.typescriptlang.org
'TypeScript' 카테고리의 다른 글
함수에 타입 지정하는 법 (0) | 2023.07.02 |
---|---|
타입을 미리 정하기 애매할 때 (union, any, unknown) (0) | 2023.07.02 |
타입스크립트 기본 타입 정리 (primitive types) (0) | 2023.07.02 |
React 프로젝트에서 TypeScript를 사용하려면 (0) | 2023.07.02 |
타입스크립트 쓰는 이유 (0) | 2023.07.01 |