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);