Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions types/lib/model.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2709,6 +2709,7 @@ export abstract class Model<TModelAttributes extends {} = any, TCreationAttribut
/**
* Returns the previous value for key from `_previousDataValues`.
*/
public previous(): Partial<TCreationAttributes>;
public previous<K extends keyof TCreationAttributes>(key: K): TCreationAttributes[K] | undefined;

/**
Expand Down
1 change: 1 addition & 0 deletions types/test/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,4 @@ expectTypeOf(modelWithAttributes.previous).parameter(0).toEqualTypeOf<keyof Mode
expectTypeOf(modelWithAttributes.previous).parameter(0).not.toEqualTypeOf<'unreferencedAttribute'>();
expectTypeOf(modelWithAttributes.previous).returns.toEqualTypeOf<string | number | undefined>();
expectTypeOf(modelWithAttributes.previous('name')).toEqualTypeOf<string | undefined>();
expectTypeOf(modelWithAttributes.previous()).toEqualTypeOf<Partial<CreationAttributes>>();