typescript - 从导出的 Typescript 命名空间导入接口
问题描述
我正在使用第三方库,它在其index.d.ts
文件中的名称空间内导出接口。
export namespace Ns {
interface Foo {
...
}
interface Bar {
...
}
export namespace AnotherNs {
interface Foo {
...
}
interface Bar {
...
}
如何将接口 Foo 从命名空间之一导入我的代码?
执行以下操作会产生 ts 错误Cannot use namespace 'Ns' as a value.
import { Ns } from "lib";
const foo: Ns.Foo = ...;
解决方案
推荐阅读
- python - 如何使用 pyspark 将 bz2 文件读入数据帧?
- ios - 是否可以使用 iOS12 发送 NFC APDU 命令
- css - 字体粗细覆盖我的自定义字体(wkhtmltopdf)
- linux - arch linux 上的 asp.net core 2.1 无法运行
- vba - Excel VBA 转到文件夹并将所有 Excel 文档另存为单独的 PDF 文件
- linux - cgroups v2 不支持 elasticsearch 2.2.x
- c++ - C++中相互调用的模板方法
- javascript - 如何使用正则表达式匹配javascript中的所有重复子字符串?
- haskell - Haskell,刚性类型错误
- python - Django:自然排序查询集