sequelize-typescript icon indicating copy to clipboard operation
sequelize-typescript copied to clipboard

$set returns Promise<unknown>

Open c-orter opened this issue 7 years ago • 3 comments

Versions

  • sequelize: 5.6.1
  • sequelize-typescript: 1.0.0-beta.1
  • typescript 3.4.3

I'm submitting a ... [x] bug report [ ] feature request

Actual behavior: The $set method on a model returns a promise of type unknown.

Expected behavior: According to sequelize's included types this method should return a promise of type ``

Steps to reproduce: Just peek into the model.ts file and also into sequelize's types

c-orter avatar Apr 18 '19 20:04 c-orter

Hey @c8r821, this is intentionally set to unknown. First, $set and set doesn't have the same purpose. $set is explicitly used for setting relational data (see this). Additionally I wasn't able to narrow down a specific type - Which means for one-to-one sequelize resolves with this type, for one-to-many with another and sometimes under specific circumstances with some unexpected type. That's why unknown is used.

What do you think? Have I overseen something? Thanks for your help

RobinBuschmann avatar Apr 18 '19 20:04 RobinBuschmann

Okay, I understand. Is the recommended way of dealing with this just to as MyType the result then?

Sorry for the misunderstanding!

c-orter avatar Apr 19 '19 16:04 c-orter

@c8r821 Yes, if you're sure with the type, just cast it like you mentioned :)

RobinBuschmann avatar Apr 19 '19 16:04 RobinBuschmann