React-aws-s3 installed but error ‘Could not find a declaration file for module ‘react-aws-s3”

I have ran yarn add react-aws-s3 several times and it is in my package.json file: "react-aws-s3": "^1.5.0",but for some reason I am still getting an error on this line: import S3 from 'react-aws-s3'; that reads:

Could not find a declaration file for module 'react-aws-s3'. 'c:/Users/e096752/Documents/Cole's Git Repos/CyberpunkAPI/frontend/node_modules/react-aws-s3/dist/react-aws-s3.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/react-aws-s3` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-aws-s3';`ts(7016)

So then I tried running yarn add @types/react-aws-s3 but got this error:

error An unexpected error occurred: "https://registry.yarnpkg.com/@types%2freact-aws-s3: Not found".
info If you think this is a bug, please open a bug report with the information provided in "C:\Users\e096752\Documents\Cole's Git Repos\CyberpunkAPI\frontend\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

It is also interesting to me that every time I have run either the install command or the add types command it has made me choose a version of react-router-dom which doesn’t make much sense to me.

What is happening and what can I do to fix this probelm?

Answer

There are no typings for the react-aws-s3 in the DefinitelyTyped repo, so you cannot use the suggested command, but you can try the second suggestion: add a new declaration (.d.ts) file containing "declare module 'react-aws-s3';"

or you can try disable noImplicitAny and/or strict options in your tsconfig.json, so compiler will not complain about it.