Skip to content

Commit 6f4e06a

Browse files
authored
fix(tsconfig): type fixes and implement ci check (#337)
* fix(tsconfig): type fixes and implement ci check * fix(helpers): getCollectionConfig now throws instead of undefined * fix(tsconfig): install @types/nodemailer to restore type safety
1 parent ff3b56a commit 6f4e06a

26 files changed

Lines changed: 157 additions & 70 deletions

.github/workflows/node.js.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ jobs:
2424
node-version: ${{ matrix.node-version }}
2525
cache: "npm"
2626
- run: npm install
27+
- name: Typecheck (plugin build)
28+
run: npx nx run plugin:build
29+
- name: Typecheck (plugin unit tests)
30+
run: npx tsc -p plugin/tsconfig.spec.json --noEmit
2731
- run: npm run test

dev-alternative-config/tsconfig.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"baseUrl": ".",
4+
"ignoreDeprecations": "6.0",
45
"lib": ["DOM", "DOM.Iterable", "ES2022"],
56
"allowJs": true,
67
"skipLibCheck": true,
@@ -19,9 +20,9 @@
1920
}
2021
],
2122
"paths": {
22-
"@/*": ["./src/*"],
23-
"@payload-config": ["./src/payload.config.ts"],
24-
"payload-crowdin-sync": ["./../plugin/src/index.ts"]
23+
"@/*": ["src/*"],
24+
"@payload-config": ["src/payload.config.ts"],
25+
"payload-crowdin-sync": ["../plugin/src/index.ts"]
2526
},
2627
"target": "ES2022"
2728
},
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../dist/out-tsc/dev-alternative-config",
5+
"rootDir": ".",
6+
"declaration": true,
7+
"declarationMap": true,
8+
"sourceMap": true,
9+
"noEmit": false,
10+
"types": ["node"]
11+
},
12+
"include": ["src/**/*.ts", "src/**/*.tsx"],
13+
"exclude": [
14+
"node_modules",
15+
"**/*.spec.ts",
16+
"**/*.test.ts",
17+
"**/*.spec.tsx",
18+
"**/*.test.tsx",
19+
"src/tests/**"
20+
]
21+
}

dev/src/payload.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default buildConfig({
6262
'posts',
6363
{
6464
slug: 'localized-posts-with-condition',
65-
condition: ({ doc }) => doc.translateWithCrowdin,
65+
condition: ({ doc }: { doc: any }) => doc.translateWithCrowdin,
6666
},
6767
'tags',
6868
'users',

dev/src/payloadcms-next-css.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare module '@payloadcms/next/css'
2+

dev/src/type-checkers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Field, RichTextField } from 'payload/types'
1+
import type { Field, RichTextField } from 'payload'
22

33
export const isRichTextField = (val: Field | string | undefined | null): val is RichTextField => {
44
return val !== undefined && val !== null && typeof val !== 'string'

dev/tsconfig.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"baseUrl": ".",
4+
"ignoreDeprecations": "6.0",
45
"lib": ["DOM", "DOM.Iterable", "ES2022"],
56
"allowJs": true,
67
"skipLibCheck": true,
@@ -19,9 +20,9 @@
1920
}
2021
],
2122
"paths": {
22-
"@/*": ["./src/*"],
23-
"@payload-config": ["./src/payload.config.ts"],
24-
"payload-crowdin-sync": ["./../plugin/src/index.ts"]
23+
"@/*": ["src/*"],
24+
"@payload-config": ["src/payload.config.ts"],
25+
"payload-crowdin-sync": ["../plugin/src/index.ts"]
2526
},
2627
"target": "ES2022"
2728
},

dev/tsconfig.lib.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../dist/out-tsc/dev",
5+
"rootDir": ".",
6+
"declaration": true,
7+
"declarationMap": true,
8+
"sourceMap": true,
9+
"noEmit": false,
10+
"types": ["node"]
11+
},
12+
"include": ["src/**/*.ts", "src/**/*.tsx"],
13+
"exclude": [
14+
"node_modules",
15+
"**/*.spec.ts",
16+
"**/*.test.ts",
17+
"**/*.spec.tsx",
18+
"**/*.test.tsx",
19+
"src/tests/**"
20+
]
21+
}

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@types/deep-equal": "^1.0.4",
4949
"@types/express": "^5.0.6",
5050
"@types/node": "^25.6.0",
51+
"@types/nodemailer": "^7.0.4",
5152
"@types/react": "19.2.14",
5253
"@types/react-dom": "19.2.3",
5354
"@typescript-eslint/eslint-plugin": "8.58.2",

0 commit comments

Comments
 (0)