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
Not able to infer parameter type in a function (Due to: input parameter order) #48719
interfaceProps<Data,Render>{data: Data;extract: (data: Data)=>Render;renderItem: (item: Render)=>null;}functionfn<Data,Render>(_props: Props<Data,Render>){returnnull;}fn({data: [1,2,3,4],renderItem: i=>{// This is unknownreturnnull;},extract: (res)=>res[0],});// ----- below is working -------interfaceProps2<Data,Render>{extract: (data: Data)=>Render;renderItem: (item: Render)=>null;}functionfn2<Data,Render>(_props: Props2<Data,Render>){returnnull;}fn2({renderItem: i=>{// This is numberreturnnull;},extract: ()=>1,});
🙁 Actual behavior
in function fn1, parameter -> renderItem(i), " i " is inferred as unknown
🙂 Expected behavior
in function fn1, parameter -> renderItem(i), " i " should be inferred as number, as in fn2
changed the title [-]Not able to infer parameter type in a function thats inside a function param[/-][+]Not able to infer parameter type in a function (Due to: input parameter order)[/+]on Apr 15, 2022
Activity
RyanCavanaugh commentedon Apr 15, 2022
This logic is still order-sensitive;
extractmust come beforerenderItemfor this to workmfleungac commentedon Apr 15, 2022
I see Ryan Cavanaugh (@RyanCavanaugh) Many Thanks
[-]Not able to infer parameter type in a function thats inside a function param[/-][+]Not able to infer parameter type in a function (Due to: input parameter order)[/+]