Closed dor1202 closed 2 years ago
I had to add this to my types.d.ts to work around the issue:
declare module 'react-barcode';
@JeffreyStevens Hi!
Adding the declare module 'react-barcode';
doesn't seem to work for me, except creating a types file for the package, do you have more ideas?
@JeffreyStevens .
It looks like they added types about 6 months ago in This file and based on commit #27c they added the types but the types still not downloading from npm due to missing #64 , so adding only declare module 'react-barcode';
has no effect.
Did you add a custom file types? if so can you send it to me?
Ok, I was getting this error and the declare fixes it for our Typescript project. We do have a custom type.d.ts file for our project for this purpose.
ERROR in src/components/BarcodeLabel.tsx:2:21
TS7016: Could not find a declaration file for module 'react-barcode'. '/Users/m087610/tfs/STS-Cloud-UI/sts-react/node_modules/react-barcode/lib/react-barcode.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/react-barcode` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-barcode';`
1 | import React, {FC, MutableRefObject} from 'react';
> 2 | import Barcode from 'react-barcode';
| ^^^^^^^^^^^^^^^
This project has types but they are done incorrectly. The file needs to be renamed to index.d.ts instead of react-barcode.d.ts.
Literally just need to rename the react-barcode.d.ts in this project. Typescript types resolution uses a schema like this
So when importing Barcode from 'react-barcode' it can't find the index.d.ts.
@kciter fyi 1.4.4 doesn't resolve the issue. The problem is that the built package has a malformed types entry in package.json
- it refers to src/index.d.ts
which doesn't exist in the downloaded package.
I suggest moving index.d.ts
to the top level of the built package, which solves the problem. Not sure how to do that with your build system though.
Is there any types support plan in the future?