3 ms·
Some comments and suggestions: - `importsNotUsedAsValues` is deprecated [0] since TypeScript 5.2, in favor of `verbatimModuleSyntax` [1]. - I could set `modul
by conaclos 3y ago
Some comments and suggestions:
- `importsNotUsedAsValues` is deprecated [0] since TypeScript 5.2, in favor of `verbatimModuleSyntax` [1].
- I could set `module` to `Node16`. This automatically set `esModuleInterop` to true.
- Also, to catch more issues, set `allowUnreachableCode` to false and set `strict`, `noImplicitReturns`, `noImplicitOverride`, `noFallthroughCasesInSwitch`, `exactOptionalPropertyTypes` to true.
- Set `types` to the empty array `[]` to avoid loading unwanted types.
- Enable `skipLibCheck` to avoid checking imported module types.
- Not sure that `declarationMap` is still useful nowadays. TypeScript is now able to match directly against source files.
- Enable `composite` that in turns enables `incremental` and `declaration` (declaration file emit). `composite` enables project references which is useful in a monorepo setting or to separate source and test files into two projects. See [2]
- Enable `checkJs` to type-check JavaScript files
To summarize:
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"lib": ["ES2022"],
"module": "Node16",
"target": "ES2022",
"outDir": "./dist",
"composite": true,
"sourceMap": true,
"types": [],
"isolatedModules": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"verbatimModuleSyntax": true,
"allowUnreachableCode": false,
"checkJs": true,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"strict": true
}
"include": ["./src/**/*.ts"],
"exclude": ["./src/specific-file.ts"]
}
[0] https://www.typescriptlang.org/tsconfig#importsNotUsedAsValues https://www.typescriptlang.org/tsconfig#importsNotUsedAsValu...
[1] https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax
[2] https://www.typescriptlang.org/docs/handbook/project-references.html https://www.typescriptlang.org/docs/handbook/project-referen...