Skip to content

Fix shorthand property assignment type resolution #646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
2 changes: 1 addition & 1 deletion internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15027,7 +15027,7 @@ func (c *Checker) getTypeOfVariableOrParameterOrPropertyWorker(symbol *ast.Symbo
case ast.KindPropertyAssignment:
result = c.checkPropertyAssignment(declaration, CheckModeNormal)
case ast.KindShorthandPropertyAssignment:
result = c.checkExpressionForMutableLocation(declaration, CheckModeNormal)
result = c.checkExpressionForMutableLocation(declaration.Name(), CheckModeNormal)
case ast.KindMethodDeclaration:
result = c.checkObjectLiteralMethod(declaration, CheckModeNormal)
case ast.KindExportAssignment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ abstract class C1 {
>({ x, y: y1, "y": y1 } = this) : this
>{ x, y: y1, "y": y1 } = this : this
>{ x, y: y1, "y": y1 } : { x: string; y: string; }
>x : any
>x : string
>y : string
>y1 : string
>"y" : string
Expand Down Expand Up @@ -309,7 +309,7 @@ class C2 {
>({ x, y: y1, "y": y1 } = this) : this
>{ x, y: y1, "y": y1 } = this : this
>{ x, y: y1, "y": y1 } : { x: string; y: string; }
>x : any
>x : string
>y : string
>y1 : string
>"y" : string
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function foo() {
({ arguments });
>({ arguments }) : { arguments: IArguments; }
>{ arguments } : { arguments: IArguments; }
>arguments : any
>arguments : IArguments

({ arguments: arguments });
>({ arguments: arguments }) : { arguments: IArguments; }
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ var results: string[];
>{ a, b } : { a: string; b: string; }

a,
>a : any
>a : string

b
>b : any
>b : string
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,7 @@
>a : string
>results : string[]

@@= skipped -11, +9 lines =@@
>{ a, b } : { a: string; b: string; }

a,
->a : string
+>a : any

b
->b : string
+>b : any
}
}
@@= skipped -20, +18 lines =@@


function f([, a, , b, , , , s, , , ] = results) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,6 @@ const withIndexResult = await Array.fromAsync(["a", "b"], (str, index) => ({ ind
>index : number
>({ index, str }) : { index: number; str: string; }
>{ index, str } : { index: number; str: string; }
>index : any
>str : any
>index : number
>str : string

Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,3 @@
>["a", "b"] : string[]
>"a" : "a"
>"b" : "b"
@@= skipped -20, +20 lines =@@
>index : number
>({ index, str }) : { index: number; str: string; }
>{ index, str } : { index: number; str: string; }
->index : number
->str : string
+>index : any
+>str : any

Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ async function f17_usage() {

return { x };
>{ x } : { x: 123; }
>x : any
>x : 123
}

// https://github.com/microsoft/TypeScript/issues/47144
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,7 @@
>args : any[]
>fn : T

@@= skipped -33, +36 lines =@@

return { x };
>{ x } : { x: 123; }
->x : 123
+>x : any
}

// https://github.com/microsoft/TypeScript/issues/47144
@@= skipped -8, +8 lines =@@
@@= skipped -41, +44 lines =@@
>GenericStructure : GenericStructure<AcceptableKeyType>

AcceptableKeyType extends string = string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const c: C = isIt ? { isIt, text: 'hey' } : { isIt, value: 123 };
>isIt ? { isIt, text: 'hey' } : { isIt, value: 123 } : { isIt: true; text: string; } | { isIt: false; value: number; }
>isIt : boolean
>{ isIt, text: 'hey' } : { isIt: true; text: string; }
>isIt : any
>isIt : true
>text : string
>'hey' : "hey"
>{ isIt, value: 123 } : { isIt: false; value: number; }
>isIt : any
>isIt : false
>value : number
>123 : 123

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,7 @@
>isIt : false
>false : false
>value : number
@@= skipped -26, +28 lines =@@
>isIt ? { isIt, text: 'hey' } : { isIt, value: 123 } : { isIt: true; text: string; } | { isIt: false; value: number; }
>isIt : boolean
>{ isIt, text: 'hey' } : { isIt: true; text: string; }
->isIt : true
+>isIt : any
>text : string
>'hey' : "hey"
>{ isIt, value: 123 } : { isIt: false; value: number; }
->isIt : false
+>isIt : any
>value : number
>123 : 123

@@= skipped -42, +42 lines =@@
@@= skipped -68, +70 lines =@@
};

let Funk = (_props: ComponentProps) => <div>Hello</div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function foo4(y = {z}, z = 1) {
>foo4 : (y?: { z: number; }, z?: number) => void
>y : { z: number; }
>{z} : { z: number; }
>z : any
>z : number
>z : number
>1 : 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,3 @@
>a : any
>z : number
>1 : 1
@@= skipped -17, +16 lines =@@
>foo4 : (y?: { z: number; }, z?: number) => void
>y : { z: number; }
>{z} : { z: number; }
+>z : any
>z : number
->z : number
>1 : 1
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ for (const value of [1, 2, 3]) {
>() => ({ value }) : () => { value: number; }
>({ value }) : { value: number; }
>{ value } : { value: number; }
>value : any
>value : number
}
const result = fns.map(fn => fn());
>result : any[]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function M() {

return { t, x };
>{ t, x } : { t: T; x: X; }
>t : any
>x : any
>t : T
>x : X
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,3 @@

var t: T;
>t : T
@@= skipped -12, +14 lines =@@

return { t, x };
>{ t, x } : { t: T; x: X; }
->t : T
->x : X
+>t : any
+>x : any
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ function M() {

return { t, x };
>{ t, x } : { t: T; x: X; }
>t : any
>x : any
>t : T
>x : X
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,3 @@

var t: T;
>t : T
@@= skipped -12, +14 lines =@@

return { t, x };
>{ t, x } : { t: T; x: X; }
->t : T
->x : X
+>t : any
+>x : any
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Cls {
>this : this
>'y' : "y"
>{ seed } : { seed: number; }
>seed : any
>seed : number

this['z'] = `${seed}`;
>this['z'] = `${seed}` : string
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ function f(
>{ options, onChange, } : { options: SelectOptions<Thing>; onChange: (status: Thing | null) => void; }

options,
>options : any
>options : SelectOptions<Thing>

onChange,
>onChange : any
>onChange : (status: Thing | null) => void

});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
--- old.coAndContraVariantInferences5.types
+++ new.coAndContraVariantInferences5.types
@@= skipped -20, +20 lines =@@
>{ options, onChange, } : { options: SelectOptions<Thing>; onChange: (status: Thing | null) => void; }

options,
->options : SelectOptions<Thing>
+>options : any

onChange,
->onChange : (status: Thing | null) => void
+>onChange : any

});
}
@@= skipped -30, +30 lines =@@

declare function select<KeyT extends string>(props: SelectProps<KeyT>): void;
>select : <KeyT extends string>(props: SelectProps<KeyT>) => void
Expand All @@ -25,7 +13,7 @@

options?: SelectOptions<KeyT>;
>options : SelectOptions<KeyT> | undefined
@@= skipped -26, +28 lines =@@
@@= skipped -16, +18 lines =@@

type SelectOptions<KeyT extends string> =
>SelectOptions : SelectOptions<KeyT>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export function makeNewChannel<T extends ChannelType>(type: T): NewChannel<Chann

return { type, localChannelId };
>{ type, localChannelId } : { type: T; localChannelId: string; }
>type : any
>localChannelId : any
>type : T
>localChannelId : string
}

const newTextChannel = makeNewChannel('text');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,7 @@
>type : T

const localChannelId = `blahblahblah`;
@@= skipped -15, +17 lines =@@

return { type, localChannelId };
>{ type, localChannelId } : { type: T; localChannelId: string; }
->type : T
->localChannelId : string
+>type : any
+>localChannelId : any
}

@@= skipped -22, +24 lines =@@
const newTextChannel = makeNewChannel('text');
>newTextChannel : NewChannel<TextChannel>
>makeNewChannel('text') : NewChannel<TextChannel>
Expand All @@ -82,7 +73,7 @@
>'text' : "text"

// This should work
@@= skipped -21, +21 lines =@@
@@= skipped -14, +14 lines =@@
const newTextChannel2 : NewChannel<TextChannel> = makeNewChannel('text');
>newTextChannel2 : NewChannel<TextChannel>
>makeNewChannel('text') : NewChannel<TextChannel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ app.foo.bar = (function () {

return { someFun };
>{ someFun } : { someFun: (arg: number) => void; }
>someFun : any
>someFun : (arg: number) => void

})();

Expand Down
Loading