data
data copied to clipboard
[5.4.0-alpha.91] Incorrect/Missing typings
I have recently updated in our app the native type packages from 5.4.0-alpha.49
to 5.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
- The option
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)
const users = await this.store.findAll<UserModel>('user', {
// Error "Type 'string' is not assignable to type 'undefined[]'.ts(2322)"
include: 'pets',
});
- When we a
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)
demo Expected:id
should bestring | number
, instead ofstring | null
user = await this.store.findRecord<UserModel>('user', firstUser.id, {
include: 'pets',
});
- We have used in some models
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 see
relationshipNames() {
// Error "Property 'relationshipsByName' does not exist on type 'Function'."
return this.constructor.relationshipsByName;
}
All TS errors you can find in this repo: https://github.com/mkszepp/ember-data-ts-errors