Skip to content
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

Descendants of 'Model' cannot be upcast #9513

Open
MathieuCouette opened this issue Jul 17, 2024 · 1 comment
Open

Descendants of 'Model' cannot be upcast #9513

MathieuCouette opened this issue Jul 17, 2024 · 1 comment

Comments

@MathieuCouette
Copy link

Reproduction

  1. Clone https://github.com/MathieuCouette/ember-data-issues
  2. Check out model-upcasting-issue
  3. Run npm install && npm run lint

Description

Implicit upcasting of indirect descendants of Model does not work when the child has an attribute or relationship that the parent does not.

image

Source file: https://github.com/MathieuCouette/ember-data-issues/blob/d2b31433b1212b03879288990b763f9299c33e34/app/components/product.ts

Argument of type 'PaymentMethodCcModel' is not assignable to parameter of type 'PaymentMethodModel'.
  Types of property 'eachAttribute' are incompatible.
    Type '<T>(callback: (this: NoInfer<T> | undefined, key: "last4" | "obfuscatedIdentifier", meta: LegacyAttributeField) => void, binding?: T | undefined) => void' is not assignable to type '<T>(callback: (this: NoInfer<T> | undefined, key: never, meta: LegacyAttributeField) => void, binding?: T | undefined) => void'.
      Types of parameters 'callback' and 'callback' are incompatible.
        Types of parameters 'key' and 'key' are incompatible.
          Type 'string' is not assignable to type 'never'.
            Type 'string' is not assignable to type 'never'.

I am guessing that the cause is the same as #9405.

Versions

├── @babel/[email protected]
├── @ember-data-types/[email protected]
├── @ember-data-types/[email protected]
├── @ember-data-types/[email protected]
├── @ember-data-types/[email protected]
├── @ember-data-types/[email protected]
├── @ember-data-types/[email protected]
├── @ember-data-types/[email protected]
├── @ember-data-types/[email protected]
├── @ember-data-types/[email protected]
├── @ember-data-types/[email protected]
├── @ember/[email protected]
├── @ember/[email protected]
├── @ember/[email protected]
├── @glimmer/[email protected]
├── @glimmer/[email protected]
├── @glint/[email protected]
├── @glint/[email protected]
├── @tsconfig/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @typescript-eslint/[email protected]
├── @typescript-eslint/[email protected]
├── @warp-drive-types/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
@mkszepp
Copy link
Contributor

mkszepp commented Aug 30, 2024

we have in our project the same issue (more than one usecase with different models)... is there any workaround how we can fix it without adding // @ts-expect error ...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: needs triage
Development

No branches or pull requests

2 participants