Hello. At my company, we are using Strapi version 4.1.11 in production and we want to upgrade to add Typescript to the project. I’ve been investigating how this could affect our project. One of the most important things is the idea of adding model typings. Currently, I can only see the schemas.d.ts generated but it contains the information of the schema.json file. Attributes of a collection type is there, but there is no specific type to import as a usual DTO or model type.
I’ve seen these utilities from Strapi core:
export type GetAttributesValues<T extends SchemaUID> = {
// Handle required attributes
[key in GetAttributesRequiredKeys<T>]-?: GetAttributeValueByKey<T, key>;
} &
{
// Handle optional attributes
[key in GetAttributesOptionalKeys<T>]?: GetAttributeValueByKey<T, key>;
};
export type GetAttributesRequiredKeys<T extends SchemaUID> = KeysBy<
GetAttributes<T>,
{ required: true }
>;
export type GetAttributesOptionalKeys<T extends SchemaUID> = keyof Omit<
GetAttributes<T>,
GetAttributesRequiredKeys<T>
>;
Are these meant to be used by the user and create types? If not, I cannot see documentation of how to create model types. Is there any plan to add this feature and document it?
Thank you!