TS2688: Cannot find type definition file for 'howler'.
See original GitHub issueAfter I npm install use-sound
, my gatsby build is complaining about this line:
node_modules/use-sound/dist/types.d.ts:1:23 - error TS2688: Cannot find type definition file for 'howler'.
1 /// <reference types="howler" />
~~~~~~
node_modules/use-sound/dist/types.d.ts:20:12 - error TS2304: Cannot find name 'Howl'.
20 sound: Howl | null;
~~~~
I think perhaps you need to move @types/howler
from devDependencies to just plain old dependencies?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
ERROR TS2688: Cannot find type definition file for 'keyv'
I found that the keyv library is not in my packages json, but some other packages that are listed in package. json are...
Read more >How to fix error TS7016: Could not find a declaration file for ...
Try `npm install @types/XYZ` if it exists or add a new declaration (.d.ts) file containing `declare module 'XYZ';. If XYZ is a direct...
Read more >@types/howler - npm
Installation. npm install --save @types/howler · Summary. This package contains type definitions for howler. · Details. Files were exported from ...
Read more >What do "Cannot find type definition file for x" errors even mean?
npm i @types/x. And It solves this issue, but today I get the error: error TS2688: Cannot find type definition file for 'jsonwebtoken...
Read more >Error TS2688: Cannot find type definition file for 'node'
If am receiving this error when running the vtex link command: Webpack for react@3.x builder finished in 464ms with errors: [at-loader] ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, this is actually a slightly old-fashioned way of importing a module in TypeScript:
The more modern way would be to just do:
Which should be pretty familiar synatax, even if you don’t know TS. The problem is that a little lower down, we’re doing:
So because
sound
is of typeHowl
, any typescript user using this library would need the howler type definitions, otherwise they won’t know what properties are available on “sound”. If you are exporting a type from a library (like you are here), it would be customary to put @types/howler in your dependencies (it’s true the non-TS people don’t need it, but at least it’s not a very large dependency, since it’s just type definitions).Since TypeScript is duck typed, we could just copy the definition of Howl from @types/howler into this file, and then we don’t need the dependency anymore. There’s two reasons that’s not a great idea; first if Howl changes, we’d need to update it, which doesn’t sound fun. 😛 Second, the Howl interface is 71 lines long - about 50% of the Howl type definitions - and longer than your whole .d.ts file.
Lemme look a little deeper into this. I’ll see if I can figure out a way to just remove that line. 😛
On Thu, May 28, 2020, 12:01 Joshua Comeau notifications@github.com wrote: