giphy-js icon indicating copy to clipboard operation
giphy-js copied to clipboard

@giphy/js-components throws error for throttle-debounce

Open MickL opened this issue 3 years ago • 9 comments

I followed the sdk and sandbox to simply render a single gif: https://codesandbox.io/s/1wq52x1w44?fontsize=14&file=/src/gif.ts

But when I import renderGif:

import { renderGif } from '@giphy/js-components';

It throws an error:

ERROR in /my-project-dir/node_modules/@giphy/js-components/dist/components/carousel.d.ts
ERROR in /my-project-dir/node_modules/@giphy/js-components/dist/components/carousel.d.ts(42,21):
TS7016: Could not find a declaration file for module 'throttle-debounce'. '/my-project-dir/node_modules/throttle-debounce/index.cjs.js' implicitly has an 'any' type.
  Try `npm install @types/throttle-debounce` if it exists or add a new declaration (.d.ts) file containing `declare module 'throttle-debounce';`

ERROR in /my-project-dir/node_modules/@giphy/js-components/dist/components/grid.d.ts
ERROR in /my-project-dir/node_modules/@giphy/js-components/dist/components/grid.d.ts(58,21):
TS7016: Could not find a declaration file for module 'throttle-debounce'. '/my-project-dir/node_modules/throttle-debounce/index.cjs.js' implicitly has an 'any' type.
  Try `npm install @types/throttle-debounce` if it exists or add a new declaration (.d.ts) file containing `declare module 'throttle-debounce';`

The docs do not state any dependency to throttle-debounce. If there are no dependencies but the types are needed in order @giphy/js-components to work, then they should be included in the package.json of @giphy/js-components imo.

MickL avatar Apr 14 '21 11:04 MickL

@MickL can you remove your node_modules dir and reinstall? This dependency is declared in our package.json, so not sure why the type declaration wouldn't be found

giannif avatar Apr 14 '21 22:04 giannif

I tried but it is not working without installing @types/throttle-debounce.

I see it is declared in you devDependencies but it seems like it is needed as a dependency instead.

MickL avatar Apr 15 '21 16:04 MickL

@MickL if you're using it in your code, you'll need to add @types/throttle-debounce to your package json. It is a dev dependency for our library, I'm pretty sure, since it's not part of an exported type.

I found this on stackoverflow and I don't think throttle debounce meets the below criteria of using it as a dependency.

import {SomeType} from 'some-module';
export default class APackageClass {
     constructor(private config: SomeType) {}
}

I might be wrong though, if it is exported somehow then yeah I'll move it. I'm using the SDK in two other giphy projects and neither one have to import themselves

giannif avatar Apr 22 '21 00:04 giannif

I am just importing import { renderGif } from '@giphy/js-components'; and it throws this error.

MickL avatar Apr 22 '21 13:04 MickL

@MickL okay, I will move it to dependencies in the next release 👍

giannif avatar Apr 26 '21 00:04 giannif

@MickL Are you still facing this problem? It seems that this issue is no longer relevant.

pshoniuk avatar Sep 28 '21 14:09 pshoniuk

This problem appears to still exist on your @giphy/js-components sandbox

q00u avatar Feb 07 '22 00:02 q00u

@q00u can you be more specific? I don't see any import errors here: https://codesandbox.io/s/1wq52x1w44?fontsize=14&file=/src/gif.ts

Also the sandbox needs to be updated, if you're seeing the error could you try updating @giphy/js-components to the latest which is 5.2.0? I don't see the error, so I can't test if the update fixes it

giannif avatar Feb 07 '22 21:02 giannif

The error still exists. (Grid component works fine but in the grid.tsx Vs code was showing the error)

Amirbarzegari avatar Feb 27 '22 00:02 Amirbarzegari