Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some type errors persist after loading masonry types #1167

Open
haydentech opened this issue Mar 8, 2022 · 1 comment
Open

Some type errors persist after loading masonry types #1167

haydentech opened this issue Mar 8, 2022 · 1 comment

Comments

@haydentech
Copy link

I'm attempting to convert a working JavaScript project using Masonry, ImagesLoaded, and InfiniteScroll over to TypeScript. The types for Masonry are available using "npm install --save @types/masonry-layout". After loading the types, many errors went away, but I'm still getting type errors for several places that appear to be working, correct code taken right from your sample code. Here are some examples:

$grid.masonry("destroy"); // https://masonry.desandro.com/methods.html#destroy

 Type '"destroy"' has no properties in common with type 'Options'.ts(2559)

$grid.masonry( 'remove', this ); // https://masonry.desandro.com/methods.html#remove

Expected 0-1 arguments, but got 2.ts(2554)

Basically any construct with .masonry(string) is not accepted. Is there a shortcoming in the types files, or am I doing something wrong?

@haydentech
Copy link
Author

haydentech commented Mar 8, 2022

Adding the specified line to index.d.ts seems to fix all the issues:

declare global {
    interface JQuery {
        masonry(options?: Masonry.Options): JQuery;
	masonry(selector: string | Element, options?: Masonry.Options | JQuery): JQuery;   // add this line
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant