不要怂,就是干,撸起袖子干!

Commit 5b16b322 by Daniel Schwartz Committed by GitHub

fix(types): fix `Model.prototype.previous()` (#13042)

1 parent 271c0816
Showing with 2 additions and 0 deletions
......@@ -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;
/**
......
......@@ -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>>();
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!