[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
This commit is contained in:
Robby Helms
2020-01-17 11:51:03 -05:00
committed by Eli Barzilay
parent e6fb7b9391
commit c04e503e08
2 changed files with 20 additions and 5 deletions

View File

@@ -412,7 +412,7 @@ namespace Parse {
revert(...keys: Array<Extract<keyof T, string>>): void;
save<K extends Extract<keyof T, string>>(
attrs?: (((x: T) => void) extends ((x: Attributes) => void) ? Partial<T> : {
[key in K]: T[K];
[key in K]: T[key];
}) | null,
options?: Object.SaveOptions
): Promise<this>;
@@ -423,7 +423,7 @@ namespace Parse {
): Promise<this>;
set<K extends Extract<keyof T, string>>(
attrs: ((x: T) => void) extends ((x: Attributes) => void) ? Partial<T> : {
[key in K]: T[K];
[key in K]: T[key];
},
options?: Object.SetOptions
): this | false;

View File

@@ -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<Attributes>
await objUntyped.save({ whatever: 100 });
// $ExpectType Object<Attributes>
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);