I am working with a third-party library that has a namespace thisLibrary and within that namespace has an interface Options. I would like to add a property to the Options interface and then use the update version of Options within my code. The index.d.ts file for the library looks like this:
export = thisLibrary;
export as namespace thisLibrary;
declare function thisLibrary(elements: HTMLElement | HTMLElement[], options: thisLibrary.Options): void;
declare namespace thisLibrary {
const propA: boolean;
let propB: number;
interface Options{
list?: ListEntry[] | any[];
propC?: string;
propD?: string | number;
}
}
I would like to be able to import thisLibrary into my code and then add typing for propE?: boolean such that I can pass propE into my function call for thisLibrary and not raise errors.
I'm working within an Angular framework, and my code looks like this:
import * as thisLibrary from 'thisLibrary';
export class MyComponent implements OnInit {
constructor() {}
ngOnInit(): void {
this.doThis()
}
private doThis(): void {
const myHTML = this.getHTML()
thisLibrary(myHTML, {
list: [[a, 10], [b, 7]],
propC: 'blah blah',
propD: 10,
propE: true
}
}
At the moment, this code throws an error in my TS linter because propE "does not exist in type Options".
declare module 'thisLibrary' { namespace thisLibrary { interface Options … } }?propEis still undeclared.