chore: cleanup 2.0 tsconfigs, fix building types for db adapters (#3293)
* chore: cleanup tsconfigs and fix db-mongodb builds * chore: make the db adapters depend on payload * chore: fix tsconfig for test directory * chore: fix packages/db-mongodb not building
This commit is contained in:
@@ -79,7 +79,6 @@ export const init: Init = async function init(this: MongooseAdapter) {
|
|||||||
|
|
||||||
// TS expect error only needed until we launch 2.0.0
|
// TS expect error only needed until we launch 2.0.0
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-expect-error
|
|
||||||
this.payload.collections[collection.slug] = {
|
this.payload.collections[collection.slug] = {
|
||||||
config: collection,
|
config: collection,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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'
|
import mongoose from 'mongoose'
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// @ts-expect-error // TODO: Fix this import
|
||||||
import type { TransactionOptions } from 'mongodb'
|
import type { TransactionOptions } from 'mongodb'
|
||||||
import type { BeginTransaction } from 'payload/database'
|
import type { BeginTransaction } from 'payload/database'
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
"composite": true, // Make sure typescript knows that this module depends on their references
|
||||||
"declaration": true /* Generates corresponding '.d.ts' file. */,
|
"noEmit": false /* Do not emit outputs. */,
|
||||||
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
"emitDeclarationOnly": true,
|
||||||
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
||||||
"module": "Node16",
|
|
||||||
"moduleResolution": "Node16" /* Required for exports to work */,
|
|
||||||
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
||||||
"resolveJsonModule": true,
|
"rootDir": "./src" /* Specify the root folder within your source files. */
|
||||||
"rootDir": "./src" /* Specify the root folder within your source files. */,
|
|
||||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
|
|
||||||
"target": "ESNext"
|
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"dist",
|
"dist",
|
||||||
@@ -19,9 +14,11 @@
|
|||||||
"test",
|
"test",
|
||||||
"node_modules",
|
"node_modules",
|
||||||
".eslintrc.js",
|
".eslintrc.js",
|
||||||
"**/*.spec.js",
|
"src/**/*.spec.js",
|
||||||
"**/*.spec.jsx",
|
"src/**/*.spec.jsx",
|
||||||
"**/*.spec.ts",
|
"src/**/*.spec.ts",
|
||||||
"**/*.spec.tsx"
|
"src/**/*.spec.tsx"
|
||||||
]
|
],
|
||||||
|
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
|
||||||
|
"references": [{ "path": "../payload" }] // db-mongodb depends on payload
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
"composite": true, // Make sure typescript knows that this module depends on their references
|
||||||
"declaration": true /* Generates corresponding '.d.ts' file. */,
|
"noEmit": false /* Do not emit outputs. */,
|
||||||
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
"emitDeclarationOnly": true,
|
||||||
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
||||||
"module": "Node16",
|
|
||||||
"moduleResolution": "Node16" /* Required for exports to work */,
|
|
||||||
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
||||||
"resolveJsonModule": true,
|
"rootDir": "./src" /* Specify the root folder within your source files. */
|
||||||
"rootDir": "./src" /* Specify the root folder within your source files. */,
|
|
||||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
|
|
||||||
"target": "ESNext"
|
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"dist",
|
"dist",
|
||||||
@@ -19,9 +14,11 @@
|
|||||||
"test",
|
"test",
|
||||||
"node_modules",
|
"node_modules",
|
||||||
".eslintrc.js",
|
".eslintrc.js",
|
||||||
"**/*.spec.js",
|
"src/**/*.spec.js",
|
||||||
"**/*.spec.jsx",
|
"src/**/*.spec.jsx",
|
||||||
"**/*.spec.ts",
|
"src/**/*.spec.ts",
|
||||||
"**/*.spec.tsx"
|
"src/**/*.spec.tsx"
|
||||||
]
|
],
|
||||||
|
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
|
||||||
|
"references": [{ "path": "../payload" }] // db-postgres depends on payload
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -282,7 +282,7 @@
|
|||||||
"build": "pnpm copyfiles && pnpm build:swc && pnpm build:types && pnpm build:components",
|
"build": "pnpm copyfiles && pnpm build:swc && pnpm build:types && pnpm build:components",
|
||||||
"build:components": "webpack --config dist/bundlers/webpack/components.config.js",
|
"build:components": "webpack --config dist/bundlers/webpack/components.config.js",
|
||||||
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
|
"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\"",
|
"build:watch": "nodemon --watch 'src/**' --ext 'ts,tsx' --exec \"pnpm build:tsc\"",
|
||||||
"clean": "rimraf dist",
|
"clean": "rimraf dist",
|
||||||
"clean:cache": "rimraf node_modules/.cache",
|
"clean:cache": "rimraf node_modules/.cache",
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +1,10 @@
|
|||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"allowJs": true /* Allow javascript files to be compiled. */,
|
"composite": true, // Required for packages/db-mongodb to build
|
||||||
"checkJs": false /* Report errors in .js files. */,
|
"noEmit": false /* Do not emit outputs. */,
|
||||||
"composite": true,
|
"emitDeclarationOnly": true,
|
||||||
"declaration": true /* Generates corresponding '.d.ts' file. */,
|
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
||||||
"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. */,
|
"outDir": "./dist" /* Redirect output structure to the directory. */,
|
||||||
"paths": {
|
"paths": {
|
||||||
"payload/auth": ["./src/auth/types.ts"],
|
"payload/auth": ["./src/auth/types.ts"],
|
||||||
@@ -20,28 +12,25 @@
|
|||||||
"payload/generated-types": ["./src/generated-types.ts"],
|
"payload/generated-types": ["./src/generated-types.ts"],
|
||||||
"payload/types": ["./src/types/index.ts"]
|
"payload/types": ["./src/types/index.ts"]
|
||||||
},
|
},
|
||||||
"resolveJsonModule": true,
|
"types": ["jest", "node", "@types/jest"],
|
||||||
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
"lib": ["dom", "dom.iterable", "esnext"]
|
||||||
"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"],
|
"exclude": [
|
||||||
/* Like tsconfig.build.json, but includes test directory and doesnt emit anything */
|
"dist",
|
||||||
"include": [
|
"build",
|
||||||
"src/**/*.ts",
|
"tests",
|
||||||
"src/**/*.tsx",
|
"test",
|
||||||
"src/**/*.d.ts",
|
"node_modules",
|
||||||
"src/**/*.json",
|
".eslintrc.js",
|
||||||
"test/**/*.ts",
|
"src/**/*.spec.js",
|
||||||
"test/**/*.tsx",
|
"src/**/*.spec.jsx",
|
||||||
"test/**/*.d.ts"
|
"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": {
|
"ts-node": {
|
||||||
"esm": true,
|
|
||||||
"experimentalSpecifierResolution": "node",
|
|
||||||
"swc": true
|
"swc": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
project: ['../tsconfig.json'],
|
project: ['./tsconfig.json'],
|
||||||
tsconfigRootDir: __dirname,
|
tsconfigRootDir: __dirname,
|
||||||
},
|
},
|
||||||
root: true,
|
root: true,
|
||||||
|
|||||||
19
test/tsconfig.json
Normal file
19
test/tsconfig.json
Normal file
@@ -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"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,45 +1,39 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"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. */,
|
"allowJs": true /* Allow javascript files to be compiled. */,
|
||||||
"checkJs": false /* Report errors in .js files. */,
|
"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'. */,
|
"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. */,
|
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
|
||||||
"jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
|
"jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"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. */,
|
"noEmit": true /* Do not emit outputs. */,
|
||||||
/* Concatenate and emit output to single file. */
|
/* Concatenate and emit output to single file. */
|
||||||
"outDir": "./dist" /* Redirect output structure to the directory. */,
|
"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,
|
"resolveJsonModule": true,
|
||||||
"rootDir": "." /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
"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. */,
|
"skipLibCheck": true /* Skip type checking of declaration files. */,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"strict": false /* Enable all strict type-checking options. */,
|
"strict": false /* Enable all strict type-checking options. */,
|
||||||
"target": "ESNext",
|
|
||||||
"types": ["jest", "node", "@types/jest"]
|
"types": ["jest", "node", "@types/jest"]
|
||||||
},
|
},
|
||||||
"exclude": ["dist", "build", "temp", "node_modules"],
|
"exclude": ["dist", "build", "temp", "node_modules"],
|
||||||
/* Like tsconfig.build.json, but includes test directory and doesnt emit anything */
|
/* Like tsconfig.build.json, but includes test directory and doesnt emit anything */
|
||||||
"include": [
|
"include": [],
|
||||||
"packages/**/*.ts",
|
"files": [],
|
||||||
"packages/**/*.tsx",
|
|
||||||
"packages/**/*.d.ts",
|
|
||||||
"packages/**/*.json",
|
|
||||||
"test/**/*.ts",
|
|
||||||
"test/**/*.tsx",
|
|
||||||
"test/**/*.d.ts"
|
|
||||||
],
|
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
"swc": true
|
"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" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user