Reputation: 3711
I'm trying to use History.js (https://github.com/browserstate/history.js) with TypeScript using the DefinitelyTyped declaration file (https://github.com/borisyankov/DefinitelyTyped/blob/master/history/history.d.ts)
Historyjs object is declared in History.d.ts, but when I try to use Historyjs object I get an error saying "Historyjs is not defined", I have search in history.js file and I can't find the javascript declaration for Historyjs object ...
What's happend? any ideas? thanks!!
Upvotes: 0
Views: 1262
Reputation: 8293
This problem is documented in the definition file. When your add the reference line,
/// <reference path="history.d.ts"/>
to the top of your file, you then have to "import" the variable like so:
// var Historyjs: Historyjs = <any>History;
You can see more about this here: https://github.com/borisyankov/DefinitelyTyped/issues/277
Upvotes: 2
Reputation: 276363
Reading https://github.com/browserstate/history.js/ it's supposed to be History
not Historyjs
Upvotes: 0
Reputation: 276363
Adding a TypeScript definition file does not cause the JavaScript to be automatically loaded. You still need to manually load history.js into your browser. PS: make sure you load history.js
before your file.
Upvotes: 0