Reputation: 1249
I have function take function as argument and return new function. Returned function called with options
params and call styleCallback
function.
I dont know how to pass options
type to styleCallback
const makeStyle = (styleCallback) => {
return (options) =>{
theme = getTheme();
return styleCallback(theme, options)
}
}
I tried with generics but it not worked
const makeStyle = (styleCallback: (theme: Theme, props: T) => any) => {
return <T>(options: T) =>{
theme = getTheme();
return styleCallback(theme, options)
}
}
Upvotes: 0
Views: 91
Reputation: 2552
Placing the type variable in the main function should resolve your issue.
const makeStyle = <T>(styleCallback: (theme: Theme, props: T) => any) => {
return (options: T) => {
let theme = getTheme();
return styleCallback(theme, options);
}
}
Upvotes: 1