Import module to namespace class

82 views Asked by At

I need to import external library to namespace class

app.ts:

namespace GlobNS {
   class A {}
}

mod.ts:

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

ext-lib.d.ts:

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

But compiler says: 'Property 'ISMTH' does not exist on type 'typeof 'ExtLib''

Also, why it does not works? Typescript Playground

1

There are 1 answers

1
shadeglare On BEST ANSWER

Seems you misplaced implements with extends keyword. Try to change your code to:

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

It should work.