Remove generated types redundancy via field interfaces #5640
Closed
hdodov
started this conversation in
Feature Requests & Ideas
Replies: 1 comment 1 reply
-
Is |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We have a group of meta fields (under a
meta
field of typegroup
) that we have on all globals and on some collections, like this:However, this results in fields having the following types:
This means that every single global has a copy of the fields in
meta
, which are identical.Fields could have a separate
interface
attribute that could hint Payload to generate a separate TypeScript interface for it, like so:export const metaField = { name: "meta", type: "group", + interface: 'Meta', fields: [ // ... ], };
Then, the types could look like so:
This way,
payload-types.ts
will be shorter.Also, this offers users to import the field type for usage in other files. Otherwise, you have to import a global type and access the types this way. In this example, you have to import either
Global1
orGlobal2
and useGlobal1["meta"]
, which is confusing. Importing aMeta
interface would be much better.Beta Was this translation helpful? Give feedback.
All reactions