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
importReact,{useCallback}from'react';functionMyComponent(){// Using a simple hook to cause the problem (not a real code)// This worksconstpromisify=useCallback(// NOTE Current TypeScript version doesn't support generic in arrow functions in TSX filesfunction<R>(value: R): Promise<R>{returnPromise.resolve(value);},[]);// This does not work - it also happens when removing the useCallback and just defining a simple function too.constpromisify2=useCallback(// NOTE Current TypeScript version doesn't support generic in arrow functions in TSX files<R>(value: R): Promise<R>=>{returnPromise.resolve(value);},[]);returnnull;}
π Actual behavior
The compiler doesn't recognize the generic parameter when using an arrow function in a .tsx file and gives an error like if you are using a JSX element as a function.
π Expected behavior
I should be able to define generic arrow functions in .tsx files too (I guess ;) ).
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
π Search Terms
typescript, generic, .tsx, react, function
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
The compiler doesn't recognize the generic parameter when using an arrow function in a .tsx file and gives an error like if you are using a JSX element as a function.
π Expected behavior
I should be able to define generic arrow functions in .tsx files too (I guess ;) ).
The text was updated successfully, but these errors were encountered: