chore: make TypeScript strict by default in packages and 7 packages stricter (#10579)

This PR modifies `tsconfig.base.json` by setting the following
strictness properties to true: `strict`, `noUncheckedIndexedAccess` and
`noImplicitOverride`.

In packages where compilation errors were observed, these settings were
opted out, and TODO comments were added to make it easier to track the
roadmap for converting everything to strict mode.

The following packages now have increased strictness, which prevents new
errors from being accidentally introduced:

- storage-vercel-blob
- storage-s3*
- storage-gcs
- plugin-sentry
- payload-cloud*
- email-resend*
- email-nodemailer*

*These packages already had `strict: true`, but now have
`noUncheckedIndexedAccess` and `noImplicitOverride`.

Note that this only affects the `/packages` folder, but not
`/templates`, `/test` or `/examples` which have a different `tsconfig`.
This commit is contained in:
Germán Jabloñski
2025-01-14 18:39:40 -03:00
committed by GitHub
parent 61117ee5cb
commit 085c1d0cac
30 changed files with 147 additions and 17 deletions

View File

@@ -1,6 +1,8 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"strict": true /* TODO: remove the following lines */
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
}, },
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }, { "path": "../translations" }] "references": [{ "path": "../payload" }, { "path": "../translations" }]
} }

View File

@@ -1,5 +1,11 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [ "references": [
{ {
"path": "../payload" "path": "../payload"

View File

@@ -1,5 +1,11 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [ "references": [
{ {
"path": "../payload" "path": "../payload"

View File

@@ -1,5 +1,11 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [ "references": [
{ {
"path": "../payload" "path": "../payload"

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }, { "path": "../translations" }] "references": [{ "path": "../payload" }, { "path": "../translations" }]
} }

View File

@@ -1,7 +1,4 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
"strict": true
},
"references": [{ "path": "../payload" }] "references": [{ "path": "../payload" }]
} }

View File

@@ -1,7 +1,4 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
"strict": true
},
"references": [{ "path": "../payload" }] "references": [{ "path": "../payload" }]
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }] "references": [{ "path": "../payload" }]
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }] "references": [{ "path": "../payload" }]
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }] // db-mongodb depends on payload "references": [{ "path": "../payload" }] // db-mongodb depends on payload
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }] "references": [{ "path": "../payload" }]
} }

View File

@@ -1,5 +1,11 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [ "references": [
{ "path": "../payload" }, { "path": "../payload" },
{ "path": "../ui" }, { "path": "../ui" },

View File

@@ -1,7 +1,4 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
"strict": true
},
"references": [{ "path": "../payload" }] "references": [{ "path": "../payload" }]
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../translations" }] "references": [{ "path": "../translations" }]
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }] "references": [{ "path": "../payload" }]
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }, { "path": "../ui" }] "references": [{ "path": "../payload" }, { "path": "../ui" }]
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }] "references": [{ "path": "../payload" }]
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }] "references": [{ "path": "../payload" }]
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }, { "path": "../ui" }, { "path": "../next" }] "references": [{ "path": "../payload" }, { "path": "../ui" }, { "path": "../next" }]
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }, { "path": "../ui" }, { "path": "../next" }] "references": [{ "path": "../payload" }, { "path": "../ui" }, { "path": "../next" }]
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }, { "path": "../ui" }, { "path": "../next" }] "references": [{ "path": "../payload" }, { "path": "../ui" }, { "path": "../next" }]
} }

View File

@@ -1,9 +1,9 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"strictNullChecks": true, /* TODO: remove the following lines */
"noImplicitAny": true, "noUncheckedIndexedAccess": false,
"strict": true "noImplicitOverride": false
}, },
"references": [ "references": [
{ "path": "../payload" }, { "path": "../payload" },

View File

@@ -6,7 +6,12 @@
"emitDeclarationOnly": true, "emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */, "outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */, "rootDir": "./src" /* Specify the root folder within your source files. */,
"jsx": "react-jsx" "jsx": "react-jsx",
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
}, },
"exclude": [ "exclude": [
"dist", "dist",

View File

@@ -6,7 +6,10 @@
"emitDeclarationOnly": true, "emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */, "outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */, "rootDir": "./src" /* Specify the root folder within your source files. */,
"strict": true
/* TODO: remove the following lines */
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
}, },
"exclude": ["dist", "node_modules"], "exclude": ["dist", "node_modules"],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"], "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],

View File

@@ -6,7 +6,6 @@
"emitDeclarationOnly": true, "emitDeclarationOnly": true,
"outDir": "./dist" /* Specify an output folder for all emitted files. */, "outDir": "./dist" /* Specify an output folder for all emitted files. */,
"rootDir": "./src" /* Specify the root folder within your source files. */, "rootDir": "./src" /* Specify the root folder within your source files. */,
"strict": true
}, },
"exclude": ["dist", "node_modules"], "exclude": ["dist", "node_modules"],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"], "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }, { "path": "../plugin-cloud-storage" }] "references": [{ "path": "../payload" }, { "path": "../plugin-cloud-storage" }]
} }

View File

@@ -1,3 +1,9 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
}
} }

View File

@@ -1,4 +1,10 @@
{ {
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
},
"references": [{ "path": "../payload" }, { "path": "../translations" }] "references": [{ "path": "../payload" }, { "path": "../translations" }]
} }

View File

@@ -1,5 +1,10 @@
{ {
"compilerOptions": { "compilerOptions": {
/* Strictness */
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"composite": true, "composite": true,
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
@@ -21,7 +26,6 @@
"types": ["jest", "node", "@types/jest"], "types": ["jest", "node", "@types/jest"],
"incremental": true, "incremental": true,
"isolatedModules": true, "isolatedModules": true,
"strict": false,
"plugins": [ "plugins": [
{ {
"name": "next" "name": "next"