Reputation: 19987
I am trying to load the nouislider module in my project: Angular 2 beta-0, Typescript 1.7 using SystemJs 0.19.4.
I have it working with a work-around: by changing the .d.ts file tsd
has installed for me. I would like to know what, if anything, I can do to load the module without altering the original typescript definition file: nouislider.d.ts.
With my changes I can currently load nouislider
and use it in my Typescript project with SystemJs like so:
import {create as createSlider} from 'noUiSlider/distribute/nouislider';
createSlider(document.getElementById('test-slider'), {
start: 40, connect: "lower",
range: { 'min': 0, 'max': 100 }
});
What I did to get it working was change these two lines at the top in nouislider.d.ts
:
declare module noUiSlider {
function create(target: HTMLElement, options: Options): void;
into
declare module 'noUiSlider/distribute/nouislider' {
export function create(target : HTMLElement, options : Options) : void;
I set the module's name to 'noUiSlider/distribute/nouislider', otherwise System.js does not load the module from the right path. And I export the create function, since otherwise I have no way of loading it
How can I prevent making these two changes? I would be quite content creating an external module definition myself that references the internal module definition or achieve the same result some other way without changing nouislider.d.ts. I've tried a bunch of things, but couldn't make it work, and seem to be getting lost in all the docs. Your help is much appreciated.
Upvotes: 1
Views: 662
Reputation: 29814
No much you can do I am afraid other than creating a pull request on DefinitelyTyped and propose adding
declare module 'noUiSlider/distribute/nouislider' {
export = noUiSlider;
}
This should simply add the possibility to use it as an external module without breaking any existing use
Upvotes: 2