From c04e503e08fa28625f6b5e081bdb703459e3e05a Mon Sep 17 00:00:00 2001 From: Robby Helms Date: Fri, 17 Jan 2020 11:51:03 -0500 Subject: [PATCH] [parse] Fix typo in Parse.Object.save attrs type (#41623) * [parse] Fix typo in Parse.Object.save attrs type * [parse] Fix typo in Parse.Object.set attrs type --- types/parse/index.d.ts | 4 ++-- types/parse/parse-tests.ts | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 1ba9ef2051..9a8e103d16 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -412,7 +412,7 @@ namespace Parse { revert(...keys: Array>): void; save>( attrs?: (((x: T) => void) extends ((x: Attributes) => void) ? Partial : { - [key in K]: T[K]; + [key in K]: T[key]; }) | null, options?: Object.SaveOptions ): Promise; @@ -423,7 +423,7 @@ namespace Parse { ): Promise; set>( attrs: ((x: T) => void) extends ((x: Attributes) => void) ? Partial : { - [key in K]: T[K]; + [key in K]: T[key]; }, options?: Object.SetOptions ): this | false; diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index f91b42dba5..707bbf5b2b 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -1109,17 +1109,26 @@ function testObject() { objTyped.revert('other'); } - async function testSave(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: boolean }>) { + async function testSave( + objUntyped: Parse.Object, + objTyped: Parse.Object<{ example: boolean; someString: string }> + ) { // $ExpectType Object await objUntyped.save({ whatever: 100 }); // $ExpectType Object await objUntyped.save('whatever', 100); - // $ExpectType Object<{ example: boolean; }> + // $ExpectType Object<{ example: boolean; someString: string; }> await objTyped.save({ example: true }); - // $ExpectType Object<{ example: boolean; }> + // $ExpectType Object<{ example: boolean; someString: string; }> + await objTyped.save({ example: true, someString: 'hello' }); + + // $ExpectError + await objTyped.save({ example: 'hello', someString: true }); + + // $ExpectType Object<{ example: boolean; someString: string; }> await objTyped.save('example', true); // $ExpectError @@ -1145,6 +1154,12 @@ function testObject() { // $ExpectType false | Object<{ example: boolean; another: number; }> objTyped.set({ example: false }); + // $ExpectType false | Object<{ example: boolean; another: number; }> + objTyped.set({ example: true, another: 123 }); + + // $ExpectError + objTyped.set({ example: 123, another: true }); + // $ExpectType false | Object<{ example: boolean; another: number; }> objTyped.set('example', true);