I want to extend an interface for React props. But I get TS error Error:(19, 35) TS2304: Cannot find name 'T'.
1) Why error? <T> is generic type. It can't be declared before usage.
2) Why TS throws error in my code but doesn't throw for DefinitelyTyped React types definitions here. Generic types <T> and many others are used everywhere in their code. Why they do not throw?
3) How to extend it the right way?
Here is my code.
I import interface Props from DefinitelyTyped for React:
import React, {Props, PureComponent} from 'react';
// TS throws Error:(20, 27) TS2304: Cannot find name 'T'.
interface IHomeProps extends Props<T> { }
class Home extends PureComponent<IHomeProps> {
render() {
...
}
}
// interface Props definition
interface Props<T> {
children?: ReactNode;
key?: Key;
ref?: LegacyRef<T>;
}