react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

Could not find a declaration file for module 'react-datepicker'.

Open matheusisquierdo opened this issue 2 years ago • 6 comments

Describe the bug

TS7016: Could not find a declaration file for module 'react-datepicker'. ..../node_modules/react-datepicker/dist/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/react-datepicker if it exists or add a new declaration (.d.ts) file containing declare module 'react-datepicker';

To Reproduce Steps to reproduce the behavior:

  1. yarn add react-datepicker
  2. yarn add -D react-datepicker

package.json

{ "name": "saida-livre-schools", "version": "0.1.0", "private": true, "dependencies": { "@azure/msal-browser": "^2.23.0", "@azure/msal-react": "^1.3.2", "@microsoft/microsoft-graph-client": "^3.0.2", "@testing-library/jest-dom": "^5.16.2", "@testing-library/react": "^12.1.4", "@testing-library/user-event": "^13.5.0", "@types/jest": "^27.4.1", "@types/node": "^16.11.26", "@types/react": "^17.0.40", "@types/react-dom": "^17.0.13", "axios": "^0.26.1", "bootstrap": "^5.1.3", "react": "^17.0.2", "react-bootstrap": "^2.2.1", "react-datepicker": "4.6.0", "react-dom": "^17.0.2", "react-hook-form": "^7.28.1", "react-icons": "^4.3.1", "react-router-dom": "6", "react-scripts": "5.0.0", "styled-components": "^5.3.3", "web-vitals": "^2.1.4" }, "devDependencies": { "@microsoft/microsoft-graph-types": "^2.18.0", "@types/react-router-dom": "^5.3.3", "@types/styled-components": "^5.1.24", "@typescript-eslint/eslint-plugin": "^5.10.1", "@typescript-eslint/parser": "^5.10.1", "eslint": "^8.8.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-prettier": "^8.3.0", "eslint-plugin-import": "^2.25.4", "eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-react": "^7.28.0", "eslint-plugin-react-hooks": "^4.3.0", "miragejs": "^0.1.43", "prettier": "^2.5.1", "typescript": "^4.4.2" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, "eslintConfig": { "extends": [ "react-app", "react-app/jest" ] }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] } }

File Tsx:

`import DatePicker from 'react-datepicker';

`

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows
  • Browser chrome

matheusisquierdo avatar Apr 25 '22 23:04 matheusisquierdo

Seems like this is obviously needed!

mschwartz avatar Apr 28 '22 21:04 mschwartz

Just run yarn -D @types/react-datepicker

jorgerodrigues avatar May 10 '22 21:05 jorgerodrigues

Bump, I also got this error Module not found: Can't resolve 'react-datepicker'

hebbian avatar Jun 09 '22 12:06 hebbian

I encountered the same problem, to fix it you have to open the project on Visual Studio Code then hover on the missing module "react-datepicker", then a "quick fix" message will apprear, just click on it and it will install it automatically

imenelhakim avatar Oct 24 '22 21:10 imenelhakim

Add to package.json devDependencies manually and then run yarn

Adreier27 avatar Jan 03 '24 22:01 Adreier27

use this npm install --save @types/react-datepicker

AbhiSmith avatar Jan 26 '24 18:01 AbhiSmith

The problem appears to have already been resolved. If there are no other problems, please close the issue. ( cc: @martijnrusschen )

yuki0410-dev avatar Mar 26 '24 15:03 yuki0410-dev