I'm developing an Angular 5 project. I have referenced a third party library downloaded from NPM (odata-v4-ng). I need to augment a class inside this library to add some methods. The class is declared like this.
export declare class ODataQuery extends ODataQueryAbstract {
// methods omitted for brevity
}
I have tried to augment the class this way:
import { ODataQuery } from 'odata-v4-ng';
declare module 'odata-v4-ng' {
interface ODataQuery {
test();
}
}
ODataQuery.prototype.test = () => { };
The problem is that compilers throws saying "'ODataQuery' only refers to a type, but is being used as a value here.". If I create a class in my Angular project and augment it this way, everything works fine.
Any idea?
That specific class is defined in another module and is only reexported by the main odata-v4-ng module. If you extends the actual module where the class is defined everything seems to work fine:
import { ODataQuery } from 'odata-v4-ng';
declare module './node_modules/odata-v4-ng/src/app/odata/odata-query/odata-query' {
export interface ODataQuery {
test():void
}
}
ODataQuery.prototype.test = () => { };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With