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
typeFn=(...args: any[])=>any;typeArgumentTypes<TextendsFn>=Textends(...args: infer U)=>any ? U : never;functionbuildActionCreator<Textendsstring,Pextends(...args: any[])=>any>(type: T,payloadCreator?: P){return(...args: ArgumentTypes<P>)=>{constpayload=payloadCreator(...args)asReturnType<P>;return{
type,
payload,};};};// if you hover here on setAge, the inferred arguments// are spreaded and their names preserved: (age: number) => { ... }constsetAge=buildActionCreator("SET_AGE",(age: number)=>({ age }));// the toolip showing function signatures when typing the open parenthesis// do not spread arguments, the arguments names are lost: (...args: [number]) => { ... } // note that the hover on function tooltip still works oksetAge(10);
Expected behavior:
When typing the opening parenthesis of setAge(, the tooltip showing function overloads should spread the inferred arguments and show the argument names like (age: number) => { ... }.
Actual behavior:
When typing the opening parenthesis of setAge(, the tooltip showing function overloads do not spread the inferred arguments and so the argument names are not visible (...args: [number]) => { ... }.
TypeScript Version: typescript@3.2.0-dev.20181025
Search Terms:
Code
Expected behavior:
When typing the opening parenthesis of
setAge(
, the tooltip showing function overloads should spread the inferred arguments and show the argument names like(age: number) => { ... }
.Actual behavior:
When typing the opening parenthesis of
setAge(
, the tooltip showing function overloads do not spread the inferred arguments and so the argument names are not visible(...args: [number]) => { ... }
.Playground Link:
http://www.typescriptlang.org/play/#src=type%20Fn%20%3D%20(...args%3A%20any%5B%5D)%20%3D%3E%20any%3B%0D%0Atype%20ArgumentTypes%3CT%20extends%20Fn%3E%20%3D%20T%20extends%20(...args%3A%20infer%20U)%20%3D%3E%20any%20%3F%20U%20%3A%20never%3B%0D%0A%0D%0Afunction%20buildActionCreator%3C%0D%0A%20%20T%20extends%20string%2C%0D%0A%20%20P%20extends%20(...args%3A%20any%5B%5D)%20%3D%3E%20any%0D%0A%3E(type%3A%20T%2C%20payloadCreator%3F%3A%20P)%20%7B%0D%0A%20%20%20%20return%20(...args%3A%20ArgumentTypes%3CP%3E)%20%3D%3E%20%7B%0D%0A%20%20%20%20%20%20%20%20const%20payload%20%3D%20payloadCreator(...args)%20as%20ReturnType%3CP%3E%3B%0D%0A%20%20%20%20%20%20%20%20return%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20type%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20payload%2C%0D%0A%20%20%20%20%20%20%20%20%7D%3B%0D%0A%20%20%20%20%7D%3B%0D%0A%7D%3B%0D%0A%0D%0A%2F%2F%20if%20you%20hover%20here%20on%20setAge%2C%20the%20inferred%20arguments%0D%0A%2F%2F%20are%20spreaded%20and%20their%20names%20preserved%3A%20(age%3A%20number)%20%3D%3E%20%7B%20...%20%7D%0D%0Aconst%20setAge%20%3D%20buildActionCreator(%22SET_AGE%22%2C%20(age%3A%20number)%20%3D%3E%20(%7B%20age%20%7D))%3B%0D%0A%0D%0A%2F%2F%20the%20toolip%20showing%20function%20signatures%20when%20typing%20the%20open%20parenthesis%0D%0A%2F%2F%20do%20not%20spread%20arguments%2C%20the%20arguments%20names%20are%20lost%3A%20(...args%3A%20%5Bnumber%5D)%20%3D%3E%20%7B%20...%20%7D%20%20%0D%0A%2F%2F%20note%20that%20the%20hover%20on%20function%20tooltip%20still%20works%20ok%0D%0AsetAge(10)%3B
Related Issues:
The text was updated successfully, but these errors were encountered: