【发布时间】:2019-10-14 12:16:56
【问题描述】:
我想将reactstrap 与打字稿一起使用。
这些分型有分型:https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/reactstrap/index.d.ts
Reactstrap 在页面上作为Reactstrap 全局变量可用。我认为将它添加到环境模块中就像添加 react 和 react dom 一样简单
这是我的global.d.ts
import * as react from "react"
import * as react_dom from "react-dom"
import * as reactstrap from "reactstrap"
declare global {
type React = typeof react
type ReactDOM = typeof react_dom
type Reactstrap = typeof reactstrap
}
我可以在不导入的情况下使用React.Component 和 jsx,它在全球范围内可用。但我不能使用Reactstrap.Alert,tsc 说Reactstrap.Alert 是一种类型,但用作值。
我可以在 d.ts 文件中手动添加此字符串 export as namespace Reactstrap,但它看起来像 hack,并且此更改未存储在我的 git 存储库中。是否可以从一个 d.ts 导出所有类并将其放入另一个的命名空间?
【问题讨论】:
标签: typescript reactstrap