8
votes

I am trying install react-input-search. I have error:

Could not find a declaration file for module 'react-search-input'. '.../app/node_modules/react-search-input/lib/index.js' implicitly has an 'any' type. Try npm install @types/react-search-input if it exists or add a new declaration (.d.ts) file containing declare module 'react-search-input';ts(7016)

4
I just tried using react-search-input in a codesandbox and it appears to be functional. Do you mind sharing a bit of your package.json file and other project details?Drew Reese
Please provide a sandbox where the issue is reproducible ?Tarun Lalwani
Which library you want to use? react-input-search or react-search-input?ravibagul91
Make sure to use react-search-input and not react-input-search as in your question text.ssc-hrep3

4 Answers

15
votes

Typescript should go with Typescript NPM package, the Typescript NPM package had prefix @types/ on it name. The NPM package react-search-input do not had Typescript package for it yet, then you can simple fix by following

  1. Create file with name globals.d.ts and put on your source root of Typescript watcher folder
  2. Put declare module 'react-search-input' on that file

And it should working fine

1
votes

It's a typescript error. It means that there is no type declarations in 'react-input-search' library. There is no package 'react-input-search' with types for it, so you need to declare usage of these library in your project by creating a file with extension .d.ts (for example libraries.d.ts) and insert a line declare module 'react-search-input'; into it.

1
votes

You can always create the type definition library for this library react-search-input and put it on definitelytyped so now everyone including you can use it. Here is a guide with examples on how to create a type definition library.

1
votes

This is a common error that you can simply solve by creating an index.d.ts file and then add a declaration line like this:

declare module 'react-input-search';

You can save this file anywhere you wish but make sure to add the filepath to tsconfig.json like this "typeRoots": [ "types/index.d.ts" ],

This is assuming you saved it in types/index.d.ts