0
RouteComponentProps
을 포함하여 Component
의 반응을 위해 강력한 형식의 기본 클래스를 만들려고합니다. 내가 IComponentProps
내가 원했던 방식으로 TProps
을 연장 할 수 없기 때문에,typescript에서 반응 구성 요소를 강력하게 입력하는 방법은 무엇입니까?
import * as React from "react";
interface IDetailsModel {
show: string;
}
interface IComponentProps<TParams, TProps> extends ReactRouter.RouteComponentProps<TParams, {}>, TProps {
}
class ComponentBase<TParams, TProps> extends React.Component<IComponentProps<TParams, TProps>, {}> {
}
class Details extends ComponentBase<{ id: number }, { show: string; }> {
render() {
var show = this.props.show;
var id = this.props.params.id;
return (
<div className="container"></div>
);
}
}
이 작동하지 않습니다 : 내가 달성하고자하는 것은이 같은 것입니다. 나는이 같은 IComponentProps 정의에 구체적인 인터페이스 TProps를 대체 할 때
, 모든 작동이를 달성하기 위해 다른 방법이
interface IComponentProps<TParams, TProps> extends ReactRouter.RouteComponentProps<TParams, {}>, IDetailsModel{
}
있습니까?
그것은 일 않았고, 덕분에 많이. 재밌는 점은 이전에 해봤지만 ReSharper가이 사실을 잘못보고 한 것과 같은 문제가있는 것처럼 보입니다. 당신의 대답 후에 나는 ReSharper가 꺼져 있는지 확인해 봤고 효과가있었습니다. – mmoron