Flow中TypeScript表达式的等价物是什么?
React.HTMLAttributes<HTMLElement>
例如,我想定义一个继承div
元素属性的类型。
虽然我没有在流程中面对确切的HTML元素类型声明(如果不是这样,请纠正我),有引用JSX元素的泛型类型:
import * as React from 'react'
const test: React.Element<*> = <div />
这将被flow
理解为Type of a React element. React elements are commonly created using JSX literals, which desugar to React.createElement calls
(基于文档)。
你在寻找的是:
type Props = HTMLDivElement & { myOwnProp: string }