-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking Issue: Typescript Type generation #15225
Comments
+1 on this one! I generate the typescript definitions from Strapi and import it in our NextJS frontend. The {
data: {
id: 1 // <-- this id is missing from the definition
attributes: {
...
relationField: { // <-- e.g. has type MediaAttribute, but needs to be wrapped in StrapiResponse
id: ...,
attributes: {
// field attributes
}
}
}
} Where my workaround is to define another type export interface StrapiResponse<T> {
id: number
attributes: T['attributes']
} I think the relational attribute should also be wrapped in such a 'StrapiResponse' to enfore the type is equal. |
@sjoukedv look into this package, I installed it as a global package and had pretty good results with it https://www.npmjs.com/package/strapi-generate-types |
Do you accept PRs for the sub issues? Something like this that is crashing the whole application for me because of the invalid types is something that seems like a pretty quick fix: strapi/packages/core/database/lib/index.d.ts Lines 44 to 57 in cf179e3
|
Hello, are there any workarounds or plans to fix these type issues? I know it may not be trivial but it's a rather big issue when trying to build reliable apps. I might be open to try and fix some issues in a PR if there's any follow-up. |
Only quick thing I was able to do is add |
Looks like a lot of tickets were closed but not merged as this is still an issue? |
@gregg-cbs Correct they where all closed in and this 1 tracking issue opened in its place. |
Bug report
Describe the bug
This is a tracking issue for all issues related to Typescript type generation issues (bugs, requests, enhancements, etc)
List of initial issues that contributed to creating this tracking issue:
only
property optional in the RouterConfig #14720schema.d.ts
can't be directly imported without errors? #14578Event
type missingresult
property for 11 Action types: eg:afterCreate
,afterCreateMany
, etc... #14167Subscriber
typing doesn't allowmodels
property. #14165Steps to reproduce the behavior
See various linked issues
Expected behavior
Various type issues and requests should be addressed at a later date
Additional context
Additional duplicate issues will be linked in the comments below:
The text was updated successfully, but these errors were encountered: