TypeScript的新手,这感觉它应该非常简单,但我不能让语法快乐!
非常简单的组件:
import * as React from "react";
import ControlArea from "./ControlArea";
interface IControlAreaProps {
welcome?: any;
}
export class Layout extends React.Component<IControlAreaProps> {
public render() {
return (
<ControlArea welcome="This is the control area"/>
);
}
}
我收到TS错误Property 'welcome' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ControlArea> & Readonly<{ children?: ReactNode; }>...'.
非常感谢正确方向的任何一点。
答案 0 :(得分:2)
您的错误在于,当您将界面添加到ControlArea组件时,您需要将界面添加到Layout组件
interface IControlAreaProps {
welcome?: any
}
export default class ControlArea extends React.Component<IControlAreaProps> {
// Your ControlArea code
}