在打字稿中,我有一个React Component,Cell,
class Cell extends Component<void, void> {
...
}
Run Code Online (Sandbox Code Playgroud)
当我使用它时,即
<Cell />
Run Code Online (Sandbox Code Playgroud)
我得到的返回类型是JSX.Element.
相反,我试图断言返回值是一个实例Cell,而不是JSX.Element,我怎么能这样做呢?
它失败了,因为它说
Type `Element` is not assignable to type `Cell`
Run Code Online (Sandbox Code Playgroud)