Typescript 可以推断和在函数上定义的属性, 这个特性在 Typescript 3.1开始支持.
import React, { PropsWithChildren } from 'react'...;
这种方式也非常简洁, 只不过 defaultProps 的类型和组件本身的 props 没有关联性, 这会使得 defaultProps 无法得到类型约束, 所以必要时进一步显式声明...)>, 只是因为React Babel插件无法从匿名函数中推导出displayName导致的....所有原生元素 props 都继承了React.HTMLAttributes, 某些特殊元素也会扩展了自己的属性, 例如InputHTMLAttributes....用起来, 应该始终开启 strict 模式, 避免使用 any 类型声明.
----
扩展资料
piotrwitek/react-redux-typescript-guide
TypeScript 如何完美地书写