从导出的 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 = ...;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)