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
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-expect-error
|
||||
this.payload.collections[collection.slug] = {
|
||||
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'
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-expect-error // TODO: Fix this import
|
||||
import type { TransactionOptions } from 'mongodb'
|
||||
import type { BeginTransaction } from 'payload/database'
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": {
|
||||
"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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
parserOptions: {
|
||||
project: ['../tsconfig.json'],
|
||||
project: ['./tsconfig.json'],
|
||||
tsconfigRootDir: __dirname,
|
||||
},
|
||||
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": {
|
||||
"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" }
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user