IScroll in Typescript

206 views Asked by At

I am rewriting javascript code into Typescript. The javascript code is using some IScroll's properties that look that are outdated. (wrapper and maxScrollY). I read somewhere that in Ver 5.2 those properties still work even though they are not on the documentation, so I am still using them, however, Typescript gives me an error saying that does properties do not exist on type IScroll although the code actually works!!

So how can I get rid of those errors?

I tried modifying the index.d.ts file of IScroll and added those properties in the interface and the class:

interface IScrollOptions {
    x?: number;
    y?: number;

    wrapper?: string;
    maxScrollY?: number;

...

declare class IScroll {
    constructor (element: string, options?: IScrollOptions);
    constructor (element: HTMLElement, options?: IScrollOptions);

    x: number;
    y: number;

wrapper: string;
maxScrollY: number;

....

And it looks like it is working and got rid of the error messages :).

Still I am not sure this is the best solution. Any better ideas?

0

There are 0 answers