diff --git a/packages/db-mongodb/src/init.ts b/packages/db-mongodb/src/init.ts index 86a1fc519d..4b4f4a92bd 100644 --- a/packages/db-mongodb/src/init.ts +++ b/packages/db-mongodb/src/init.ts @@ -79,7 +79,6 @@ export const init: Init = async function init(this: MongooseAdapter) { // TS expect error only needed until we launch 2.0.0 // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error this.payload.collections[collection.slug] = { config: collection, } diff --git a/packages/db-mongodb/src/queries/sanitizeQueryValue.ts b/packages/db-mongodb/src/queries/sanitizeQueryValue.ts index 243e19bc60..1210c4b922 100644 --- a/packages/db-mongodb/src/queries/sanitizeQueryValue.ts +++ b/packages/db-mongodb/src/queries/sanitizeQueryValue.ts @@ -1,4 +1,4 @@ -import type { Field, TabAsField } from 'payload/dist/fields/config/types' +import type { Field, TabAsField } from 'payload/types' import mongoose from 'mongoose' diff --git a/packages/db-mongodb/src/transactions/beginTransaction.ts b/packages/db-mongodb/src/transactions/beginTransaction.ts index 2941389a8a..9af96ea96d 100644 --- a/packages/db-mongodb/src/transactions/beginTransaction.ts +++ b/packages/db-mongodb/src/transactions/beginTransaction.ts @@ -1,3 +1,4 @@ +// @ts-expect-error // TODO: Fix this import import type { TransactionOptions } from 'mongodb' import type { BeginTransaction } from 'payload/database' diff --git a/packages/db-mongodb/tsconfig.json b/packages/db-mongodb/tsconfig.json index 6d1756c1e2..3120f08405 100644 --- a/packages/db-mongodb/tsconfig.json +++ b/packages/db-mongodb/tsconfig.json @@ -1,16 +1,11 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "composite": true, - "declaration": true /* Generates corresponding '.d.ts' file. */, - "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, - "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, - "module": "Node16", - "moduleResolution": "Node16" /* Required for exports to work */, + "composite": true, // Make sure typescript knows that this module depends on their references + "noEmit": false /* Do not emit outputs. */, + "emitDeclarationOnly": true, "outDir": "./dist" /* Specify an output folder for all emitted files. */, - "resolveJsonModule": true, - "rootDir": "./src" /* Specify the root folder within your source files. */, - "skipLibCheck": true /* Skip type checking all .d.ts files. */, - "target": "ESNext" + "rootDir": "./src" /* Specify the root folder within your source files. */ }, "exclude": [ "dist", @@ -19,9 +14,11 @@ "test", "node_modules", ".eslintrc.js", - "**/*.spec.js", - "**/*.spec.jsx", - "**/*.spec.ts", - "**/*.spec.tsx" - ] + "src/**/*.spec.js", + "src/**/*.spec.jsx", + "src/**/*.spec.ts", + "src/**/*.spec.tsx" + ], + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"], + "references": [{ "path": "../payload" }] // db-mongodb depends on payload } diff --git a/packages/db-postgres/tsconfig.json b/packages/db-postgres/tsconfig.json index 6d1756c1e2..8aa2b21021 100644 --- a/packages/db-postgres/tsconfig.json +++ b/packages/db-postgres/tsconfig.json @@ -1,16 +1,11 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "composite": true, - "declaration": true /* Generates corresponding '.d.ts' file. */, - "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, - "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, - "module": "Node16", - "moduleResolution": "Node16" /* Required for exports to work */, + "composite": true, // Make sure typescript knows that this module depends on their references + "noEmit": false /* Do not emit outputs. */, + "emitDeclarationOnly": true, "outDir": "./dist" /* Specify an output folder for all emitted files. */, - "resolveJsonModule": true, - "rootDir": "./src" /* Specify the root folder within your source files. */, - "skipLibCheck": true /* Skip type checking all .d.ts files. */, - "target": "ESNext" + "rootDir": "./src" /* Specify the root folder within your source files. */ }, "exclude": [ "dist", @@ -19,9 +14,11 @@ "test", "node_modules", ".eslintrc.js", - "**/*.spec.js", - "**/*.spec.jsx", - "**/*.spec.ts", - "**/*.spec.tsx" - ] + "src/**/*.spec.js", + "src/**/*.spec.jsx", + "src/**/*.spec.ts", + "src/**/*.spec.tsx" + ], + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"], + "references": [{ "path": "../payload" }] // db-postgres depends on payload } diff --git a/packages/payload/package.json b/packages/payload/package.json index 396f35ccaa..d9e6fbb9b4 100644 --- a/packages/payload/package.json +++ b/packages/payload/package.json @@ -282,7 +282,7 @@ "build": "pnpm copyfiles && pnpm build:swc && pnpm build:types && pnpm build:components", "build:components": "webpack --config dist/bundlers/webpack/components.config.js", "build:swc": "swc ./src -d ./dist --config-file .swcrc", - "build:types": "tsc --emitDeclarationOnly --outDir dist -p tsconfig.build.json", + "build:types": "tsc --emitDeclarationOnly --outDir dist", "build:watch": "nodemon --watch 'src/**' --ext 'ts,tsx' --exec \"pnpm build:tsc\"", "clean": "rimraf dist", "clean:cache": "rimraf node_modules/.cache", diff --git a/packages/payload/tsconfig.build.json b/packages/payload/tsconfig.build.json deleted file mode 100644 index 5e019be986..0000000000 --- a/packages/payload/tsconfig.build.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "compilerOptions": { - "allowJs": true /* Allow javascript files to be compiled. */, - "checkJs": false /* Report errors in .js files. */, - "composite": true, - "declaration": true /* Generates corresponding '.d.ts' file. */, - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, - "jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */, - "module": "Node16", - "moduleResolution": "Node16" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, - /* Do not emit comments to output. */ - "noEmit": false /* Do not emit outputs. */, - /* Concatenate and emit output to single file. */ - "outDir": "./dist" /* Redirect output structure to the directory. */, - "paths": { - "payload/auth": ["./src/auth/types.ts"], - "payload/config": ["./src/config/types.ts"], - "payload/generated-types": ["./src/generated-types.ts"], - "payload/types": ["./src/types/index.ts"] - }, - "resolveJsonModule": true, - "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, - "skipLibCheck": true /* Skip type checking of declaration files. */, - "sourceMap": true, - "strict": false /* Enable all strict type-checking options. */, - "target": "ESNext", - "types": ["node"] - }, - "exclude": [ - "dist", - "build", - "tests", - "test", - "node_modules", - ".eslintrc.js", - "**/*.spec.js", - "**/*.spec.jsx", - "**/*.spec.ts", - "**/*.spec.tsx", - "temp" - ], - "extends": "../../tsconfig.json", - "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"], - "ts-node": { - "esm": true, - "experimentalSpecifierResolution": "node", - "swc": true - } -} diff --git a/packages/payload/tsconfig.json b/packages/payload/tsconfig.json index 96a6fcc996..44b325b0a9 100644 --- a/packages/payload/tsconfig.json +++ b/packages/payload/tsconfig.json @@ -1,18 +1,10 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "allowJs": true /* Allow javascript files to be compiled. */, - "checkJs": false /* Report errors in .js files. */, - "composite": true, - "declaration": true /* Generates corresponding '.d.ts' file. */, - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, - "jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */, - "lib": ["dom", "dom.iterable", "esnext"], - "module": "Node16", - "moduleResolution": "Node16" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, - /* Do not emit comments to output. */ - "noEmit": true /* Do not emit outputs. */, - /* Concatenate and emit output to single file. */ + "composite": true, // Required for packages/db-mongodb to build + "noEmit": false /* Do not emit outputs. */, + "emitDeclarationOnly": true, + "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, "outDir": "./dist" /* Redirect output structure to the directory. */, "paths": { "payload/auth": ["./src/auth/types.ts"], @@ -20,28 +12,25 @@ "payload/generated-types": ["./src/generated-types.ts"], "payload/types": ["./src/types/index.ts"] }, - "resolveJsonModule": true, - "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, - "skipLibCheck": true /* Skip type checking of declaration files. */, - "sourceMap": true, - "strict": false /* Enable all strict type-checking options. */, - "target": "ESNext", - "types": ["jest", "node", "@types/jest"] + "types": ["jest", "node", "@types/jest"], + "lib": ["dom", "dom.iterable", "esnext"] }, - "exclude": ["dist", "build", "temp", "node_modules"], - /* Like tsconfig.build.json, but includes test directory and doesnt emit anything */ - "include": [ - "src/**/*.ts", - "src/**/*.tsx", - "src/**/*.d.ts", - "src/**/*.json", - "test/**/*.ts", - "test/**/*.tsx", - "test/**/*.d.ts" + "exclude": [ + "dist", + "build", + "tests", + "test", + "node_modules", + ".eslintrc.js", + "src/**/*.spec.js", + "src/**/*.spec.jsx", + "src/**/*.spec.ts", + "src/**/*.spec.tsx", + "temp" ], + /* Like tsconfig.build.json, but includes test directory and doesnt emit anything */ + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"], "ts-node": { - "esm": true, - "experimentalSpecifierResolution": "node", "swc": true } } diff --git a/test/.eslintrc.cjs b/test/.eslintrc.cjs index 9f064a7343..865656a50e 100644 --- a/test/.eslintrc.cjs +++ b/test/.eslintrc.cjs @@ -61,7 +61,7 @@ module.exports = { }, ], parserOptions: { - project: ['../tsconfig.json'], + project: ['./tsconfig.json'], tsconfigRootDir: __dirname, }, root: true, diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 0000000000..2618a58833 --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "noEmit": false /* Do not emit outputs. */, + "emitDeclarationOnly": true, + "outDir": "./dist" /* Specify an output folder for all emitted files. */, + "rootDir": "../" /* Specify the root folder within your source files. */ + }, + "exclude": ["dist", "build", "node_modules", ".eslintrc.js"], + "include": [ + "src/**/*.ts", + "src/**/*.tsx", + "src/**/*.d.ts", + "src/**/*.json", + "**/*.ts", + "test/**/*.tsx", + "../packages/**/src/**/*.ts" + ] +} diff --git a/tsconfig.json b/tsconfig.json index ea91b53ef9..42ea9f77ec 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,45 +1,39 @@ { "compilerOptions": { + "declaration": true /* Generates corresponding '.d.ts' file. */, + "declarationMap": true, // This will allow code navigation between projects. + "target": "ESNext", + "module": "Node16", + "moduleResolution": "Node16" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, + /* Do not emit comments to output. */ "allowJs": true /* Allow javascript files to be compiled. */, "checkJs": false /* Report errors in .js files. */, - "composite": true, - "declaration": true /* Generates corresponding '.d.ts' file. */, "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, "jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */, "lib": ["dom", "dom.iterable", "esnext"], - "module": "Node16", - "moduleResolution": "Node16" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, - /* Do not emit comments to output. */ "noEmit": true /* Do not emit outputs. */, /* Concatenate and emit output to single file. */ "outDir": "./dist" /* Redirect output structure to the directory. */, - "paths": { - "payload/auth": ["./src/auth/types.ts"], - "payload/config": ["./src/config/types.ts"], - "payload/generated-types": ["./src/generated-types.ts"], - "payload/types": ["./src/types/index.ts"] - }, "resolveJsonModule": true, "rootDir": "." /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, "skipLibCheck": true /* Skip type checking of declaration files. */, "sourceMap": true, "strict": false /* Enable all strict type-checking options. */, - "target": "ESNext", "types": ["jest", "node", "@types/jest"] }, "exclude": ["dist", "build", "temp", "node_modules"], /* Like tsconfig.build.json, but includes test directory and doesnt emit anything */ - "include": [ - "packages/**/*.ts", - "packages/**/*.tsx", - "packages/**/*.d.ts", - "packages/**/*.json", - "test/**/*.ts", - "test/**/*.tsx", - "test/**/*.d.ts" - ], + "include": [], + "files": [], "ts-node": { "swc": true - } + }, + "composite": true, // Required for references to work + "references": [ + { "path": "./packages/db-mongodb" }, + // if you tsconfig is something different + { "path": "./packages/db-postgres" }, + { "path": "./packages/payload" } + ] }