I've created a custom Knockout extender, and I'm having trouble extending the existing interface provided by a definition file for Knockout.
Extenders/Numeric.ts
import * as ko from "knockout";
function Extender(target: KnockoutObservable<number>, options: IOptions = {}): KnockoutObservable<number> {
// ...
};
interface IOptions {
// ...
}
export {Extender as NumericExtender, IOptions as INumericExtenderOptions}
Boot.ts
import * as ko from "knockout";
import {NumericExtender} from "./Extenders/Numeric";
class Boot {
public constructor() {
ko.extenders.numeric = NumericExtender;
}
}
To let the compiler about ko.extenders.numeric
, I need to extend the existing interface:
interface KnockoutExtenders {
numeric(target: KnockoutObservable<number>, options?: INumericExtenderOptions): KnockoutObservable<number>;
}
Now here I run into trouble. In order to access INumericExtenderOptions
, I need an import
statement:
import {INumericExtenderOptions} from "./Extenders/Numeric";
But when an import statement is added, the file is considered to be a module, which makes it impossible to extend an existing interface.
Is there a way to do this, or will I need to move IOptions
to the definition file in order to avoid an import
?