dimanche 6 mai 2018

How to add to typescript namespace?

I am currently using the casual library for my tests, which has been working wonderfully and I have defined several new methods for more complex objects and they are appearing as undefined on my linter. I am relatively new to typescript and can't seem to find the correct way to add these methods?

Currently the source code has an index.d.ts like so:

declare namespace Casual {
  interface Generators {
    // EMBEDDED GENERATORS
  }

  interface functions {
    // EMBEDDED GENERATORS
  }

  interface Casual {
    // EMBEDDED GENERATORS
    // GENERATORS functions
    functions(): functions;
  }
}
declare module "casual" {
  const casual: Casual.Generators & Casual.Casual;
  export = casual;
}

Now I have tried to add to this like so:

declare module 'casual' {
    export interface Casual extends Casual.Generators, Casual.Casual {
        DataPeriod(): IDataPeriod;
    }
}

However it doesn't seem to be working and errors with "Cannot augment module 'casual' because it resolves to a non-module entity."

I would greatly appreciate any help on this matter and you can find the github issue here.

Aucun commentaire:

Enregistrer un commentaire