将模块导入命名空间 class

Import module to namespace class

我需要将外部库导入命名空间 class

app.ts:

namespace GlobNS {
   class A {}
}

mod.ts:

import VSTS = require('ExtLib');
namespace GlobNS {
   class B extends ExtLib.ISMTH{
      prop1: string;
      prop2: number;
   }
}

分机-lib.d.ts:

declare module ExtLib {
   interface ISMTH {
      prop1: string;
      prop2: number;
   }
}

但是编译器说:'属性 'ISMTH' 在类型 'typeof 'ExtLib''

上不存在

此外,为什么它不起作用? Typescript Playground

您似乎用 extends 关键字放错了 implements。尝试将您的代码更改为:

class B implements ExtLib.ISMTH {
    prop1: string;
    prop2: number;
}

应该可以。