-
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.
perf: reduce generated types for select by respecting
interfaceName
(…
…#9870) This PR can significantly reduce your `payload-types.ts` file if you have sharable fields / blocks that use the `interfaceName` property. Previously we didn't respect it for select types. Before: ```ts export interface Collection1Select<T extends boolean = true> { testing?: T; title?: T; meta?: | T | { title?: T; description?: T; id?: T; }; blocks?: | T | { block1?: | T | { b1title?: T; b1description?: T; id?: T; blockName?: T; }; block2?: | T | { b2title?: T; b2description?: T; id?: T; blockName?: T; }; }; updatedAt?: T; createdAt?: T; } ``` After: ```ts export interface Collection1Select<T extends boolean = true> { testing?: T; title?: T; meta?: T | SharedMetaArraySelect<T>; blocks?: | T | { block1?: T | SharedMetaBlockSelect<T>; block2?: T | AnotherSharedBlockSelect<T>; }; updatedAt?: T; createdAt?: T; } /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "SharedMetaArray_select". */ export interface SharedMetaArraySelect<T extends boolean = true> { title?: T; description?: T; id?: T; } /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "SharedMetaBlock_select". */ export interface SharedMetaBlockSelect<T extends boolean = true> { b1title?: T; b1description?: T; id?: T; blockName?: T; } /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "AnotherSharedBlock_select". */ export interface AnotherSharedBlockSelect<T extends boolean = true> { b2title?: T; b2description?: T; id?: T; blockName?: T; } ``` Regenerated all the types in `/test`. The diff is noticeable for `fields` - https://github.com/payloadcms/payload/pull/9870/files#diff-95beaac24c72c7bd60933e325cdcd94a4c3630a1ce22fabad624ec80cc74fc8c
- Loading branch information
Showing
7 changed files
with
409 additions
and
652 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
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
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
Oops, something went wrong.