I installed the knockout definitions using the documented method like this.
npm install @types/knockout
It works nicely, I could import it like this anywhere.
import * as ko from "knockout";
However, I'm stuck with extending KnockoutStatic interface with some custom stuff. I'm trying to migrate a <reference ... /> and namespace based huge TS application to use modules. Before, I easily declared the extension interface anywhere and the declarations got merged. Let's say my extension looks like this.
interface KnockoutStatic {
doSomething(): void;
}
I tried to create a KnockoutExtensions.d.ts file where I declared it like this.
import "knockout";
declare module "knockout" {
export interface KnockoutStatic {
doSomething(): void;
}
}
But when I import both knockout and my extension somewhere, TS still cannot resolve the doSomething calls.
import * as ko from "knockout";
import "./KnockoutExtensions";
ko.doSomething(); // error
What is the proper method of extending library interfaces using TypeScript 2.0 and the new d.ts subsystem?
I'm using Visual Studio 2015 Update 3 with TypeScript 2.0 installed.