-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[5.4.0-alpha.91] Incorrect/Missing typings #9502
Comments
these are all expected
|
Yes, when array will be joined to a string its okay for me. data/packages/store/src/-private/store-service.ts Line 1710 in 4badefd
Also this docs are saying that we should pass as string https://guides.emberjs.com/release/models/relationships/#toc_retrieving-related-records
Okay thanks
Thanks for info |
We do support string (we test, don't error for it), I guess I should just clarify that's not the intended way to use it and it was sort of an accident that it became possible (and got documented). Almost all of the code related to it treats it as an array which just happens to work because string and array APIs share a lot of overlap. We did eventually special case some handling of it as a string, typically to split it back into an array. For typescript, we are only going to type the array story, as the string based story is both largely un-typeable and makes a lot of the features around include not work as seamlessly.
unfortunately the guides are a separate project the data team doesn't directly maintain, though we have been working to clean them up. @Baltazore has been doing work in there recently and could probably fix that quickly. |
Thank you for the detailed explanation. It would also be good to get a codemode for the migration, because that would help everyone to correct existing code in project (whether TS or JS). Maybe the team behind lint rules, should also provide a lint rule for it, so that one day you can get rid of wrong code and support only string[] |
I have recently updated in our app the native type packages from
5.4.0-alpha.49
to5.4.0-alpha.91
After updating we have seen that there already fixed other incorrect types (thanks for that), but other types are now incorrect or maybe other improvements are bringing now incorrect TS errors
include
was defined asarray
. it should be astring
, otherwise the JSONAPI call is incorrect. Passing as array generates url&include[]=pets
, which is not correct. demo - JSON:API Specs. This error is infindAll
,findRecord
,query
... (i think in all legacy functions)findAll
returns a list of models and we take for example the first to make additional calls likefindRecord
, we see errorError Argument of type 'string | null' is not assignable to parameter of type 'string | number'. Type 'null' is not assignable to type 'string | number'.ts(2345)
demoExpected:
id
should bestring | number
, instead ofstring | null
this.constructor.relationshipsByName;
. In this case we get error "Property 'relationshipsByName' does not exist on type 'Function'.". This works in JS... but typing looks like incorrect or missing seeAll TS errors you can find in this repo: https://github.com/mkszepp/ember-data-ts-errors
The text was updated successfully, but these errors were encountered: