Итак, у меня есть класс TS:
export abstract class CPComponent<
P,
S = RootState
> extends React.Component<P, S> {
cpComponentDidCatch?(p: P, s?: S, t?: this): void;
constructor(p: P, s: any) {
super(p, s);
}
abstract cpRender(p: P, s: S, t?: this): ReactElement;
componentDidCatch() {
return (
this.cpComponentDidCatch &&
this.cpComponentDidCatch(this.props, this.state, this)
);
}
render() {
return this.cpRender(this.props, this.state, this);
}
}
, а затем я делю его на подклассы:
type State = {car: string};
type Props = {bug: string}
export class Foo extends CPComponent<Props,State> { // {bug: any},{car: any}
cpComponentDidCatch(p){
}
cpRender(){
return (
<div>
rendered
</div>
)
}
}
, но проблема в том, что я получаю ошибку компиляции:
не должен TS знать, что тип p
равен P
?
// он хочет мне добавить больше текста, поэтому здесь мы go