S
S
Svyatoslav Khusamov2020-02-20 10:24:03
typescript
Svyatoslav Khusamov, 2020-02-20 10:24:03

How to properly merge interfaces from third-party NPM modules in TypeScript?

Hi

@types/yandex-maps package contains namespace ymaps

It has interface IEventManager

I want to add a new method to this interface.

I'm trying to do this in my .d.ts file

declare namespace ymaps {
  interface IEventManager {
    once(types: string[][] | string[] | string, callback: (event: object | IEvent) => void, context?: object, priority?: number): this;
  }
}


But it doesn't work, because the declare namespace ymaps statement overwrites namespace ymaps from @types/yandex-maps

How do I add the method I need correctly?

I am trying to use
https://www.typescriptlang.org/docs/handbook/decla...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question