I'm trying to use 3rd-Party-Libraries such as Knockout in my TypeScript-project.
As of organising my code, I am using AMD (requireJS to be specific) and to use the libraries in my project, I load d.ts-files from the great definitelytyped-project.
Now while I can use my own modules and libraries - which are all built with TypeScript - with ththis e simple 1 liner:
import PeopleViewModel = require("../ViewModels/PeopleViewModel");
I can't do that with the d.ts-files supplied by definitelytyped.
Now I know about the amd-dependency-command, but I don't understand how that is useful. In my JS-code, I do get a reference to the path in the in the define-call, but not the variable in the created callback.
To "say" it in code:
My TS-File (removed the openening-tag from the ///-commands, otherwise it won't get shown here in stackoverflow):
/// reference path="../../../../Libs/Knockout/knockout.d.ts" />
/// amd-dependency path="../../../../Libs/Knockout/knockout-3.1.0" />
import PeopleViewModel = require("../ViewModels/PeopleViewModel");
var johnViewModel = new PeopleViewModel("john");
var exampleVar = ko.observable(johnViewModel);
That compiles to:
define(["require", "exports", "../ViewModels/PeopleViewModel", "../Libs/Knockout/knockout-3.1.0"], function(require, exports, PeopleViewModel) {
var johnViewModel = new PeopleViewModel("john"); var exampleVar = ko.observable(johnViewModel);
});
Now you can see, that the amd-dependency created the correct link to the knockout-js-file, but it does not yiel the "ko"-variable, which is declared in the d.ts-file.
How do I get this to work without touching the js-file?
Maybe there is an argument in the amd-dependency-command, but there is still no documentation about that.
Thank you all every much!