types/sequelize

Model.update should receive a Partial<T>

Closed this issue · 10 comments

Instead of receiveing IModelAttributes (which forces the interface to declare all fields as optional) the method should receive a Partial<IModelAttributes>

What's IEntityAttributes?

@felixfbecker Just an example of an interface defined to specify a model attributes. Oh... I see now why it didn't make sense. My message was incomplete. Look again

I still don't understand where you get IModelAttributes from:

sequelize/lib/model.d.ts

Lines 2566 to 2567 in 505b409

update<K extends keyof this>(key: K, value: this[K], options?: InstanceUpdateOptions): Promise<this>;
update(keys: object, options?: InstanceUpdateOptions): Promise<this>;

@svallory Are you referring to v3 typings?

Sorry @felixfbecker and @eseliger I have no idea where I saw an update receiving the attributes interface instead of object. But anyways, it could be updated to

update(keys: Partial<TAttributes>, options?: InstanceUpdateOptions): Promise<this>;

Same goes for updateAttributes, but that's another issue. Feel free to close this one or update to the suggestion above

Where does TAttributes come from?

@felixfbecker From here:

export interface Model<TInstance, TAttributes> extends Hooks<TInstance>, Associations {

@eseliger Yes, I'm talking about v3

Actually, I just update the package to 4.0.76 and I still see the same type definition in my project (interface Model...), but I couldn't find it in the repository. I can only find an abstract class Model

I think you are mixing up sequelize @types typings with the ones here?

@SimonSchick I was, I though this was the repository for @types/sequelize. Sorry guys!