From a304dc4b0152685263aeb78f5c1bf69bdb98a8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Jablo=C3=B1ski?= <43938777+GermanJablo@users.noreply.github.com> Date: Tue, 14 Jan 2025 20:00:00 -0300 Subject: [PATCH] chore: make TypeScript strict in test folder. Simplify tsconfig (#10582) This PR makes the "test" folder strict in typescript. `pnpm build:test` before: Found 3275 errors in 174 files. `pnpm build:test` after: Found 4912 errors in 268 files. At some point we should bring that number to 0 and make it a requirement in the CI. Currently `pnpm build:test` is not run anywhere in the CI. Additionally, I took the opportunity to combine the duplicate configurations from `tsconfig.json` and `tsconfig.typecheck.json` using "extend". declaration, declarationMap and sourceMap have been removed as they have no reason to exist in noEmit. The settings I left in `tsconfig.typecheck.json` are ones that I'm not sure why they are there. Perhaps the file could be removed or at least reduced further. --- test/tsconfig.json | 33 +++++++++------------------------ test/tsconfig.typecheck.json | 27 ++------------------------- test/types/tsconfig.json | 7 +------ 3 files changed, 12 insertions(+), 55 deletions(-) diff --git a/test/tsconfig.json b/test/tsconfig.json index 894286362b..c6e6077dfc 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -1,9 +1,12 @@ { "compilerOptions": { + /* Strictness */ + "strict": true, + "noUncheckedIndexedAccess": true, + "noImplicitOverride": true, + "noEmit": true, "rootDir": ".", - "declaration": true, - "declarationMap": true, "target": "ES2022", "module": "NodeNext", "moduleResolution": "NodeNext", @@ -12,20 +15,10 @@ "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "jsx": "preserve", - "lib": [ - "DOM", - "DOM.Iterable", - "ES2022" - ], + "lib": ["DOM", "DOM.Iterable", "ES2022"], "resolveJsonModule": true, "skipLibCheck": true, - "sourceMap": true, - "strict": false, - "types": [ - "jest", - "node", - "@types/jest" - ], + "types": ["jest", "node", "@types/jest"], "incremental": true, "isolatedModules": true, "plugins": [ @@ -35,9 +28,7 @@ ], "baseUrl": ".", "paths": { - "@payload-config": [ - "./_community/config.ts" - ] + "@payload-config": ["./_community/config.ts"] } }, "exclude": [ @@ -48,12 +39,6 @@ "dist/**/*.js", "**/dist/**/*.js" ], - "include": [ - "./**/*.ts", - "./**/*.tsx", - "next-env.d.ts", - ".next/types/**/*.ts", - "setup.js" - ], + "include": ["./**/*.ts", "./**/*.tsx", "next-env.d.ts", ".next/types/**/*.ts", "setup.js"], "references": [] } diff --git a/test/tsconfig.typecheck.json b/test/tsconfig.typecheck.json index b8b427da75..1f059a791b 100644 --- a/test/tsconfig.typecheck.json +++ b/test/tsconfig.typecheck.json @@ -1,30 +1,7 @@ { + "extends": "./tsconfig.json", "compilerOptions": { - "noEmit": true, - "rootDir": ".", - "baseUrl": ".", - "target": "esnext", - "module": "NodeNext", - "moduleResolution": "NodeNext", - "allowJs": true, - "checkJs": false, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "jsx": "preserve", - "lib": ["dom", "dom.iterable", "esnext"], - "resolveJsonModule": true, - "skipLibCheck": true, - "types": ["jest", "node", "@types/jest"], - // "incremental": true, - "isolatedModules": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@payload-config": ["./_community/config.ts"] - } + "incremental": false }, "exclude": ["dist", "build", "temp", "node_modules"], "include": [ diff --git a/test/types/tsconfig.json b/test/types/tsconfig.json index 72f71380b6..3c43903cfd 100644 --- a/test/types/tsconfig.json +++ b/test/types/tsconfig.json @@ -1,8 +1,3 @@ { - "extends": "../tsconfig.json", - "compilerOptions": { - "strict": true, - "exactOptionalPropertyTypes": true, - "noUncheckedIndexedAccess": true - } + "extends": "../tsconfig.json" }