'Typescript extend prototype of external library
Given a library l that exports a class C in the namespace N like this:
export namespace N {
export class C {
public function f1(){return true}
}
}
and can be used with
import {N} from 'l'
console.log(new N().C.f1())
I can easily do
//@ts-ignore
N.C.prototype.f2 = ()=>return false
//@ts-ignore
console.log(new N().C.f2()
But how can I tell typescript that I extended the prototype and get rid of the //@ts-ignore
All solutions I found described how to extend objects in the global namespace like Array or String
Additional Info
The actual library I want to extend is @js-temporal/polyfill because the Duration.compare() method which returns 1, 0 or -1 is fairly unreadable and I want to add a Duration.greaterThan() method
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
