TypeScript Version: 3.3.0-dev.20190119
Search Terms:
Infering type from function return type
Infering from return type
Argument breaks return type inferring
Code
exportconstcreateStyles=<KextendsReturnType<T>,Textends(theme: {type: string})=>StyleSheet.NamedStyles<K>|StyleSheet.NamedStyles<any>,>(fn: T)=>fn;conststyles=createStyles(()=>({logo: {width: 70,height: 70,},}));// here logo type is properly inferred from objectstyles().logo.widthconststyles=createStyles((theme)=>({logo: {width: 70,height: 70,},}));// here styles function signature is (theme: { type: string }) => anystyles({type: 'dark'}).logo.widthExpected behavior:
It is possible to infer the return type of the function for both situations
Actual behavior:
Type inferring only for the function that doesn't have any parameters and falling to any if any parameters applied
Playground Link:
https://codesandbox.io/s/p3414yomnx
Related Issues:
TypeScript Version: 3.3.0-dev.20190119
Search Terms:
Infering type from function return type
Infering from return type
Argument breaks return type inferring
Code
Expected behavior:
It is possible to infer the return type of the function for both situations
Actual behavior:
Type inferring only for the function that doesn't have any parameters and falling to
anyif any parameters appliedPlayground Link:
https://codesandbox.io/s/p3414yomnx
Related Issues: