javascripttypescript1.7

Import module to namespace class


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


Solution

  • 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.