jbetancur / react-data-table-component

A responsive table library with built-in sorting, pagination, selection, expandable rows, and customizable styling.
https://react-data-table-component.netlify.app
Apache License 2.0
2.03k stars 409 forks source link

Build issue with NextJS - Could not find a declaration file for module 'react-data-table-component' #1198

Closed rajexp closed 7 months ago

rajexp commented 7 months ago

Issue Check list

Describe the bug

Build Issues with next.js

Type error: Could not find a declaration file for module 'react-data-table-component'. 'D:/tathyaAPI/tathya/tathyaweb/node_modules/react-data-table-component/dist/index.cjs.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/react-data-table-component` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-data-table-component';`

  3 | import { getCloudData, updateCloudData } from "@api/api";
  4 | import { TCloudData, TDateRange, TImage, TPlant } from "@types";
> 5 | import DataTable, { ExpanderComponentProps, TableColumn } from 'react-data-table-component';

Versions (please complete the following information)

Additional context

package.json

{
    "name": "xxxx",
    "version": "0.2.3",
    "private": true,
    "homepage": "https://xxx.xxx",
    "dependencies": {
        "@ant-design/icons": "^5.2.6",
        "@date-io/date-fns": "1.3.13",
        "@unocss/postcss": "^0.57.3",
        "@unocss/preset-uno": "^0.57.3",
        "@unocss/reset": "^0.57.4",
        "antd": "^5.11.2",
        "axios": "^1.6.1",
        "chart.js": "^4.4.0",
        "date-fns": "^2.30.0",
        "next": "^14.0.1",
        "react": "^18.2.0",
        "react-bootstrap": "^1.3.0",
        "react-chartjs-2": "^5.2.0",
        "react-data-table-component": "^7.6.1",
        "react-dom": "^18.2.0",
        "react-ga": "^3.3.1",
        "react-ga4": "^2.1.0",
        "react-moment": "^1.1.3",
        "react-parallax": "^3.5.1",
        "react-redux": "^8.1.3",
        "react-scroll": "^1.9.0",
        "react-sticky": "^6.0.3",
        "react-tsparticles": "^2.12.2",
        "recoil": "^0.7.7",
        "redux": "^4.2.1",
        "redux-thunk": "^2.4.2",
        "scss": "^0.2.4",
        "slick-carousel": "^1.8.1",
        "style-loader": "^3.3.3",
        "styled-components": "^6.1.1",
        "swiper": "^11.0.3",
        "tiff": "^5.0.3",
        "tsparticles": "^2.12.0",
        "unocss": "^0.57.2",
        "xlsx": "^0.18.5"
    },
    "scripts": {
        "start": "next start",
        "dev": "next dev",
        "build": "next build",
        "test": "next test",
        "eject": "react-scripts eject",
        "predeploy": "npm run build",
        "deploy": "npm run build"
    },
    "browserslist": {
        "production": [
            ">0.2%",
            "not dead",
            "not op_mini all"
        ],
        "development": [
            "last 1 chrome version",
            "last 1 firefox version",
            "last 1 safari version"
        ]
    },
    "devDependencies": {
        "@babel/preset-env": "^7.23.3",
        "@types/react": "^18.2.0",
        "@types/react-sticky": "^6.0.6",
        "eslint": "^8.54.0",
        "typescript": "^5.3.3"
    }
}
HarikalarKutusu commented 7 months ago

I confirm this issue. I had to revert back to v7.5.4 to make it build. v7.6.0 has the same problem.

randydijkstra commented 7 months ago

The reference to the types in the package.json is wrong.

It points to dist/src/index.d.ts rather than dist/index.d.ts were it is now.

jbetancur commented 7 months ago

I can put a fix in for this today, unless someone wants to put up a PR for this sooner!

jbetancur commented 7 months ago

Fix is building - will cut a 7.6.2 shortly