-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add types testing with
tstyche
(#9803)
As proposed here #9782 (comment) with additional testing of our types we can be more sure that we don't break them between updates. This PR already adds types testing for most Local API methods https://github.com/payloadcms/payload/blob/6beb921c2e232ab4edfa38c480af40a1bec1106e/test/types/types.spec.ts but new tests for types can be easily added, either to that same file or you can create `types.spec.ts` in any other test folder. The new test folder uses `strict: true` to ensure our types do not break with it. --------- Co-authored-by: Tom Mrazauskas <[email protected]>
- Loading branch information
1 parent
1fdc7cc
commit f09ee0b
Showing
11 changed files
with
452 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/media | ||
/media-gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { lexicalEditor } from '@payloadcms/richtext-lexical' | ||
import { fileURLToPath } from 'node:url' | ||
import path from 'path' | ||
|
||
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js' | ||
|
||
const filename = fileURLToPath(import.meta.url) | ||
const dirname = path.dirname(filename) | ||
|
||
export default buildConfigWithDefaults({ | ||
// ...extend config here | ||
collections: [ | ||
{ | ||
slug: 'posts', | ||
versions: true, | ||
fields: [ | ||
{ | ||
type: 'text', | ||
name: 'text', | ||
}, | ||
], | ||
}, | ||
], | ||
admin: { | ||
importMap: { | ||
baseDir: path.resolve(dirname), | ||
}, | ||
}, | ||
editor: lexicalEditor({}), | ||
globals: [ | ||
{ | ||
slug: 'menu', | ||
versions: true, | ||
fields: [ | ||
{ | ||
type: 'text', | ||
name: 'text', | ||
}, | ||
], | ||
}, | ||
], | ||
typescript: { | ||
outputFile: path.resolve(dirname, 'payload-types.ts'), | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { rootParserOptions } from '../../eslint.config.js' | ||
import { testEslintConfig } from '../eslint.config.js' | ||
|
||
/** @typedef {import('eslint').Linter.Config} Config */ | ||
|
||
/** @type {Config[]} */ | ||
export const index = [ | ||
...testEslintConfig, | ||
{ | ||
languageOptions: { | ||
parserOptions: { | ||
...rootParserOptions, | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
}, | ||
] | ||
|
||
export default index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,236 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* This file was automatically generated by Payload. | ||
* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config, | ||
* and re-run `payload generate:types` to regenerate this file. | ||
*/ | ||
|
||
export interface Config { | ||
auth: { | ||
users: UserAuthOperations; | ||
}; | ||
collections: { | ||
posts: Post; | ||
users: User; | ||
'payload-locked-documents': PayloadLockedDocument; | ||
'payload-preferences': PayloadPreference; | ||
'payload-migrations': PayloadMigration; | ||
}; | ||
collectionsJoins: {}; | ||
collectionsSelect: { | ||
posts: PostsSelect<false> | PostsSelect<true>; | ||
users: UsersSelect<false> | UsersSelect<true>; | ||
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>; | ||
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>; | ||
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>; | ||
}; | ||
db: { | ||
defaultIDType: string; | ||
}; | ||
globals: { | ||
menu: Menu; | ||
}; | ||
globalsSelect: { | ||
menu: MenuSelect<false> | MenuSelect<true>; | ||
}; | ||
locale: null; | ||
user: User & { | ||
collection: 'users'; | ||
}; | ||
jobs: { | ||
tasks: unknown; | ||
workflows: unknown; | ||
}; | ||
} | ||
export interface UserAuthOperations { | ||
forgotPassword: { | ||
email: string; | ||
password: string; | ||
}; | ||
login: { | ||
email: string; | ||
password: string; | ||
}; | ||
registerFirstUser: { | ||
email: string; | ||
password: string; | ||
}; | ||
unlock: { | ||
email: string; | ||
password: string; | ||
}; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "posts". | ||
*/ | ||
export interface Post { | ||
id: string; | ||
text?: string | null; | ||
updatedAt: string; | ||
createdAt: string; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "users". | ||
*/ | ||
export interface User { | ||
id: string; | ||
updatedAt: string; | ||
createdAt: string; | ||
email: string; | ||
resetPasswordToken?: string | null; | ||
resetPasswordExpiration?: string | null; | ||
salt?: string | null; | ||
hash?: string | null; | ||
loginAttempts?: number | null; | ||
lockUntil?: string | null; | ||
password?: string | null; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "payload-locked-documents". | ||
*/ | ||
export interface PayloadLockedDocument { | ||
id: string; | ||
document?: | ||
| ({ | ||
relationTo: 'posts'; | ||
value: string | Post; | ||
} | null) | ||
| ({ | ||
relationTo: 'users'; | ||
value: string | User; | ||
} | null); | ||
globalSlug?: string | null; | ||
user: { | ||
relationTo: 'users'; | ||
value: string | User; | ||
}; | ||
updatedAt: string; | ||
createdAt: string; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "payload-preferences". | ||
*/ | ||
export interface PayloadPreference { | ||
id: string; | ||
user: { | ||
relationTo: 'users'; | ||
value: string | User; | ||
}; | ||
key?: string | null; | ||
value?: | ||
| { | ||
[k: string]: unknown; | ||
} | ||
| unknown[] | ||
| string | ||
| number | ||
| boolean | ||
| null; | ||
updatedAt: string; | ||
createdAt: string; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "payload-migrations". | ||
*/ | ||
export interface PayloadMigration { | ||
id: string; | ||
name?: string | null; | ||
batch?: number | null; | ||
updatedAt: string; | ||
createdAt: string; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "posts_select". | ||
*/ | ||
export interface PostsSelect<T extends boolean = true> { | ||
text?: T; | ||
updatedAt?: T; | ||
createdAt?: T; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "users_select". | ||
*/ | ||
export interface UsersSelect<T extends boolean = true> { | ||
updatedAt?: T; | ||
createdAt?: T; | ||
email?: T; | ||
resetPasswordToken?: T; | ||
resetPasswordExpiration?: T; | ||
salt?: T; | ||
hash?: T; | ||
loginAttempts?: T; | ||
lockUntil?: T; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "payload-locked-documents_select". | ||
*/ | ||
export interface PayloadLockedDocumentsSelect<T extends boolean = true> { | ||
document?: T; | ||
globalSlug?: T; | ||
user?: T; | ||
updatedAt?: T; | ||
createdAt?: T; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "payload-preferences_select". | ||
*/ | ||
export interface PayloadPreferencesSelect<T extends boolean = true> { | ||
user?: T; | ||
key?: T; | ||
value?: T; | ||
updatedAt?: T; | ||
createdAt?: T; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "payload-migrations_select". | ||
*/ | ||
export interface PayloadMigrationsSelect<T extends boolean = true> { | ||
name?: T; | ||
batch?: T; | ||
updatedAt?: T; | ||
createdAt?: T; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "menu". | ||
*/ | ||
export interface Menu { | ||
id: string; | ||
text?: string | null; | ||
updatedAt?: string | null; | ||
createdAt?: string | null; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "menu_select". | ||
*/ | ||
export interface MenuSelect<T extends boolean = true> { | ||
text?: T; | ||
updatedAt?: T; | ||
createdAt?: T; | ||
globalType?: T; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "auth". | ||
*/ | ||
export interface Auth { | ||
[k: string]: unknown; | ||
} | ||
|
||
|
||
declare module 'payload' { | ||
// @ts-ignore | ||
export interface GeneratedTypes extends Config {} | ||
} |
Oops, something went wrong.