You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Contextual typing doesn't work on method declaration parameters in object literals #4773
IntelliSense does not assume argument type in method1 and method2 here.
interfaceFoo{method1(arg: number): void;method2(arg: string): void;}functiongetFoo(): Foo{return{method1(arg){// arg is any},method2(arg){// arg is any}}}functiongetFoo2(): Foo{return{method1: (arg)=>{// arg is number},method2: (arg)=>{// arg is string}}}functiongetFoo3(): Foo{return{method1: function(arg){// arg is number},method2: function(arg){// arg is string}}}
changed the title [-]Type assumption is broken in ES6 object literal method shorthand[/-][+]Contextual typing doesn't work on method declarations in object literals[/+]on Sep 17, 2015
changed the title [-]Contextual typing doesn't work on method declarations in object literals[/-][+]Contextual typing doesn't work on method declaration parameters in object literals[/+]on Sep 18, 2015
Activity
[-]Type assumption is broken in ES6 object literal method shorthand[/-][+]Contextual typing doesn't work on method declarations in object literals[/+]DanielRosenwasser commentedon Sep 17, 2015
According to the tests I've written so far, this appears to be affected in the language service, not the compiler itself.This is a contextual typing bug.
[-]Contextual typing doesn't work on method declarations in object literals[/-][+]Contextual typing doesn't work on method declaration parameters in object literals[/+]