流中的HTML属性?

问题描述 投票:0回答:2

Flow中TypeScript表达式的等价物是什么?

React.HTMLAttributes<HTMLElement>

例如,我想定义一个继承div元素属性的类型。

javascript flowtype
2个回答
0
投票

虽然我没有在流程中面对确切的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(基于文档)。

Related instantiationsSource code


0
投票

你在寻找的是:

type Props = HTMLDivElement & { myOwnProp: string }
© www.soinside.com 2019 - 2024. All rights reserved.