1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| abstract class Component<T1, T2> { props: T1; state: T2; constructor(props: T1) { this.props = props; } abstract render(): string; } interface IMyComponentProps { val: number; } interface IMyComponentState { x: number; } class MyComponent extends Component<IMyComponentProps, IMyComponentState> { constructor(props: IMyComponentProps) { super(props); this.state = { x: 1 } } render() { this.props.val; this.state.x; return '<myComponent />'; } } let myComponent = new MyComponent({val: 1}); myComponent.render();
|