creativetimofficial / material-tailwind

@material-tailwind is an easy-to-use components library for Tailwind CSS and Material Design.
https://material-tailwind.com/
MIT License
3.51k stars 306 forks source link

TypeScript Error: Props Missing on Material-Tailwind Components #664

Closed drokbers closed 2 months ago

drokbers commented 2 months ago

Hi,

I've encountered an issue with the latest version of the Material-Tailwind library where TypeScript throws errors indicating that certain props are missing from the components, even when using them as documented. According to the TypeScript errors, props such as placeholder, onPointerEnterCapture, and onPointerLeaveCapture are missing from components like Typography, Button, Card, and TabsHeader.

I tried versions 2.1.9 and 2.1.4

For instance, when using the Typography component like so:

tsx
<Typography className="my-5 font-normal !text-gray-600">
text
</Typography>

TypeScript expects props that aren't typically required or documented, resulting in the following error:

Type '{ children: string; className: string; }' is missing the following properties from type 'Pick<TypographyProps, "id" | "children" | ... >': placeholder, onPointerEnterCapture, onPointerLeaveCapture

This issue is not isolated to Typography but extends to other components such as Button, Card, and TabsHeader, suggesting a broader issue with the TypeScript type definitions within the library.

Normally, these components don't require additional props for basic usage, as per the official documentation. This leads me to believe there might be an issue with the type definitions provided.

Could you please look into this? It's possible that the TypeScript definitions might need to be updated to reflect the actual required props for these components or to mark these additional props as optional if they are not intended to be mandatory.

drokbers commented 2 months ago

changing types/react version with "18.2.42", solve the problem

lukewealth commented 2 months ago

Thanks for this. it worked

jeevankc17 commented 2 months ago

No no its not working there is no issue but the warning is still there image image

drokbers commented 2 months ago

No no its not working there is no issue but the warning is still there image image

 "@material-tailwind/react": "^2.1.4",
"next": "v13.5.7-canary.25",
 "react": "^18",
    "react-dom": "^18",
 "devDependencies": {
    "@types/jsonwebtoken": "^9.0.4",
    "@types/node": "^20",
    "@types/react": "18.2.42",
    "@types/react-dom": "^18",
    "autoprefixer": "^10",
    "eslint": "^8",
    "eslint-config-next": "13.5.6",
    "postcss": "^8",
    "tailwindcss": "^3",
    "typescript": "^5"
  }