-
-
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
Possible typing issue w/ Entity Service API & populated relations #19252
Comments
I have also experience this issue on version 4.17.1 |
Note - I see that Hussain closed his issue above as it appears it was somewhat different - however the original issue here remains (as in #18784) with content types not working correctly at all when using the entity service API. |
Experiencing this issue on 4.20.4Trying to use:
works fine, however because the
throws:
|
Work around with the Entity Service API : type cast with any or unknown |
@MarijnFK would you mind sharing the definition for the task-status content-type? I would like to try and reproduce the issue. |
sure, but it's quite big / has alot of relations.
|
Hello @sopwerdna, Thank you for reporting this bug, however we are unable to reproduce the issue you described given the information we have on hand. Can you please create a fresh project that you are able to reproduce the issue in, provide clear steps to reproduce this issue, and either upload this fresh project to a new GitHub repo or compress it into a We would greatly appreciate your assistance with this, by working in a fresh project it will cut out any possible variables that might be unrelated. Thank you! |
@Convly @derrickmehaffy It does not appear you followed the reproduction steps in the original bug report. I still encounter the same problem with |
i'm trying to reproduce the error in a clean install i got as far that the plugin |
It's a dependencies conflict, please use VirtusLab-Open-Source/strapi-plugin-navigation#431 (comment) |
I've now tried adding However, after playing with removing node_modules, types, then re-installing/generating everything, I ended up with the "Object literal may only specify known properties..." error (even without the mentioned plugin installed) I've reloaded my vs-code and the error went away, and I now have access to everything again. Could it be that the error comes from an invalid vscode state? Do you have compilation errors when building/starting your application? Have you tried restarting/reloading your vscode? |
This occurs regardless of IDE in a fresh clone of a strapi typescript project that has a single content type with a relation to https://github.com/sopwerdna/strapi-19252-demo Clone the repo, go into the javascript project subfolder, and run
and additionally, trying to access a relation as an array
|
Thanks for the reproduction repo, it helps a lot! I can indeed see the issue (although I don't think #19252 (comment) is related) The only problem I can see here is the longhand notation with positional arguments that needs to have Once the |
@Convly it might not be related indeed. Sofar i have tested several repo's with the navigation-plugin and removed it (and clean cache, re-gen types), then it works again. Re-installing the plugin (again, clear cache and re-gen types) problem re-occurs. @cyp3rius can you verify if the problem could be related to the user-permissions plugin? |
That's the native plugin used in navigation plugin (checked at init if you got it enabled). You're the first person reporting that kind of issue and connecting it with plugin which does not interact at all. Have you checked clean repo with a plugin? My guess it's a "size" of collections you already got in your project and navigation plugin in it complexity doesn't help at all and connection implicates the issue. |
Thanks @Convly this definitely seems to be the solution. Last time I tried updating my actual project to the latest release, I ran into a few other related TS errors around handling populated relations from the entity service as arrays (off the top of my head, I am curious, is this a documentation issue (i.e. the position argument is meant to be required in the long hand version) or is the fix to update the types to reflect the documentation? Either way I think this resolves my immediate problem. Thank you! |
This is a bug, not a documentation issue, it's been fixed in #20370 and will be shipped Wednesday in v4.24.4 Sorry for the time it took to track down the issue, and thanks for the reproduction repo 🙂 |
Hey, since the issue seems to be unrelated to the original one, could you open a new one if you wish to continue the discussion on your problem? Thanks! (in your new issue it would be awesome if you could include a reproduction repo or example) |
Just as an update @Convly - I attempted to update our project to
I can't immediately see why this is the case looking through the |
Bug report
Required System information
Describe the bug
We've run into a typescript error upon setting up the project with new versions after the 4.14.x typescript migration changes. In short, I believe this is a result of incorrect or conflicting types coming from calls to the Entity Service API, or objects returned from those calls. Unsure if this is a regression or simply an existing issue that was uncovered by the changes in 4.14.x.
Steps to reproduce the behavior
api::post.post
)oneToMany
relation from the built in Users table to that content typeType '{ connect: ID[]; }' is not assignable to type 'XOneInput'. Object literal may only specify known properties, and 'connect' does not exist in type 'LongHand'.
Expected behavior
In previous versions, our input to the entity service
update(...., data: {...}...)
function was typed asXManyInput
which allows partial updates and thatconnect:
syntax. Now it's expectingXOneInput
even though that relation is definitely a one to many relation and likely should be treated as an array. We're also seeing some other related issues (similar to #18784) which may be a result of the same type conflicts.Looking closer at the types, I believe this is either a problem in the typescript types for Strapi's entity service API types (in the
@strapi/types
package), or possibly in the documentation (if there's really a different syntax now). It looks to me like the type on that particular one to many relation should beXManyInput
which allows partial updates and thatconnect:
syntax.Additional context
For further context, this seems to be the file in the strapi types package with the problematic types
Thanks in advance for your help in tracking down the problem here, and fixing the issue if it does turn out to be a problem with Strapi's types. As always, let me know if I can provide any further information or details on the problem here.
The text was updated successfully, but these errors were encountered: