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
Actual behavior:
Error TS7023: 'render' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
The problem does not happen if the onClick callback is given through an intermediary variable, instead of being inlined.
The compiler tries to figure out the return types of functions from the type of their return expressions. this can depend on figuring out other types. sometimes that could lead to cycles; the compiler breaks these by giving the type any. this can be solved by adding an explicit type annotation, something like render(): JSX.Element { .. }.
Activity
mhegazy commentedon May 10, 2016
The compiler tries to figure out the return types of functions from the type of their return expressions. this can depend on figuring out other types. sometimes that could lead to cycles; the compiler breaks these by giving the type
any. this can be solved by adding an explicit type annotation, something likerender(): JSX.Element { .. }.Please see my reply to a similar issue in #1146 (comment)