scrollyfills icon indicating copy to clipboard operation
scrollyfills copied to clipboard

Typescript import issue: no declaration file for module

Open djwashburn opened this issue 1 year ago • 1 comments

I'm trying to use the scrollend polyfill from TypeScript, and encountering this issue:

Could not find a declaration file for module 'scrollyfills'. '/path/to/module-name.js' implicitly has an 'any' type

For now, I am solving the issue by creating my own empty scrollyfills.d.ts in my project, which just types everything as 'any' by default and gets the TypeScript compiler to stop complaining. Ideally, we could create a proper type declaration file, but even just adding an empty one to the repo would avoid this error when trying to use the module from TypeScript code.

djwashburn avatar Mar 07 '24 13:03 djwashburn

Why not just this?

// eslint-disable-next-line import/no-extraneous-dependencies
require('scrollyfills').scrollend;

As it is a polyfill, it doesn't upset me.

gustaveWPM avatar Mar 12 '24 13:03 gustaveWPM