I have a library with type definitions structured like this:
declare global {
interface Array<T> {
addRange<T>(elements: T[]): void;
aggregate<U>(accumulator: (accum: U, value?: T, index?: number, list?: T[]) => any, initialValue?: U): any;
}
}
This library is then packaged as an NPM module, but how can I utilize it in another project?
If I attempt to use:
['a', 'b'].addRange(['c', 'd']);
I receive the error message:
Property 'addRange' does not exist on type
Importing just addRange
directly won't work because they are extensions of Array.
What is the proper way to import this library so that Typescript recognizes its additions?