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

[@loopback/sequelize] Typescript error when using the "required" property with Sequelize #10193

Open
KalleV opened this issue Nov 16, 2023 · 2 comments

Comments

@KalleV
Copy link
Contributor

KalleV commented Nov 16, 2023

Describe the bug

When trying to use the new "required: true" to use an Inner Join instead of a Left Join, it leads to a Typescript error:

Type '{ relation: string; scope: { where: { id: number; }; }; required: true; }'
is not assignable to type 'InclusionFilter'.
  Object literal may only specify known properties, and 'required'
does not exist in type 'Inclusion'.

53           required: true

This also happens for nested relation operations such as:

myRepository(foreignKey).find({
  include: [
    {
      // ...
      required: true
    }
  ]
}

Logs

No response

Additional information

sequelize_extension_required_property_ts_error

Reproduction

https://codesandbox.io/p/devbox/loopback-sequelize-types-24l36w

@samarpanB
Copy link
Contributor

@KalleV is this fixed with #10192 or do we need any more update for this ? Can you please elaborate if anything is pending here ?

@KalleV
Copy link
Contributor Author

KalleV commented Dec 29, 2023

@samarpanB It is partially fixed by #10192. It will still give an error for the required property on nested relation operations like:

myRepository(foreignKey).find({
  include: [
    {
      // ...
      required: true
    }
  ]
}

Without global declaration merging or modifying the original Inclusion interface, I tried a couple of approaches for this, like defining a custom HasManyThroughFactory interface (e.g., #10192 (comment)).

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

No branches or pull requests

2 participants