Description
Reproduces on 2.8.0-dev.20180315
interface FooProps<T> {
callback: (input: T) => string;
value: T;
}
class Foo<T> extends React.Component<FooProps<T>> {
public render() {
return "baz";
}
}
const X = <Foo callback={test => test} value="asd"/>;
The bug is visible while using an IDE like visual code, but I expect the problem is in the language server, since from what I know it's the source for helper messages and the autocomplete functionality.
What happens is that the callback gets correctly inferred as (input: string) => string, in fact, you can write
callback={test => test.substring(0)}
without errors, as the compilers actually knows that test is a string.
and you cannot write
callback={test => 42}
or
callback={test => test.methodNotOnString()}
However, if in visual code you hover over the callback, it shows as a function T => any, instead of string => string. The return value of substring will be shown as any.
Moreover autocomplete won't work correctly when trying to access a property of test.
It seems like the compiler does everything correctly in inferring the correct type, but the helper messages and autocomplete functions are instead unable to access the same inferred type.