Skip to content

Missing "@types/react" dependency #17121

@slavafomin

Description

@slavafomin

Hello!

Thank you for this great library!

You are referencing react in public type declarations of your components, however, the @types/react dependency is missing from the manifest of the @material-ui/core package.

This leads to type-checking errors, because the types for react package couldn't be resolved from your declarations:

ERROR in /node_modules/.registry.npmjs.org/@material-ui/core/[email protected][email protected]/node_modules/@material-ui/core/Avatar/Avatar.d.ts

ERROR in /node_modules/.registry.npmjs.org/@material-ui/core/[email protected][email protected]/node_modules/@material-ui/core/Avatar/Avatar.d.ts(1,24):
TS7016: Could not find a declaration file for module 'react'. '/node_modules/.registry.npmjs.org/react/16.9.0/node_modules/react/index.js' implicitly has an 'any' type.

This happens in projects, which use more strict dependency management tools, like rush / pnpm, because they block access to implicit dependencies (like in your case).

In order to fix this, I would suggest to add @types/react and @types/react-dom packages to the peerDependencies section of the @material-ui/core package manifest.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions