【发布时间】:2019-10-20 16:02:26
【问题描述】:
当我使用来自react-router-dom v4.3.2 的withRouter 时,它会将三个道具传递给组件,history、match 和location。我在哪里可以找到这三个 TypeScript 对象的类型定义?
我检查了这个链接https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-router/v3/lib,但它没有第4版。另外,那里定义的类型不包括History location and match。
【问题讨论】:
-
repos 没有版本 4。
-
看起来他们搬到了github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/…,虽然奇怪的是v5又回到了
@types/react-router。无论如何,关键是您可以查看 DT 以了解您正在使用的@types包。 -
如何从这个包中导入类型?我试过从@types/node'import { History },但它不起作用
-
@jonrsharpe 我检查了代码
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router-dom/index.d.ts,但它没有history、match和`location 的任何类型。
标签: typescript react-router react-router-v4