mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.87k stars 32.26k forks source link

material-ui-1.0.0-beta.10 - Typings issues. #8255

Closed kvindascr closed 7 years ago

kvindascr commented 7 years ago

When trying to compile a react 15 project with Typescript and MaterialUI 1.0.0-beta, typescript found inconsistencies on typings defined.

Expected Behavior

Material-ui, react15 and typescript should be able to compile properly.

Current Behavior

Typescript is not able to compile due to several typing / descriptor inconsistencies. First according to material-ui package descriptor, material-ui should be compatible with both react 15 and react 16.

Some of typings for example of Table component seems to rely on react 16 definitions, and in order to be compatible with react 15 this should not occur.

Example errors:

.../material-ui/Tooltip/Tooltip.d.ts (4,18): error TS2430: Interface 'TooltipProps' incorrectly extends interface 'HTMLAttributes<HTMLDivElement>'. Types of property 'label' are incompatible. Type 'ReactNode' is not assignable to type 'string | undefined'. Type 'null' is not assignable to type 'string | undefined'.

.../material-ui/Table/TableCell.d.ts (17,11): error TS2694: Namespace 'React' has no exported member 'ThHTMLAttributes'.

.../material-ui/Table/Table.d.ts (5,17): error TS2694: Namespace 'React' has no exported member 'TableHTMLAttributes'.

.../material-ui/Snackbar/SnackbarContent.d.ts (5,18): error TS2430: Interface 'SnackbarContentProps' incorrectly extends interface 'PaperProps'. Types of property 'action' are incompatible. Type 'ReactElement<any> | undefined' is not assignable to type 'string | undefined'. Type 'ReactElement<any>' is not assignable to type 'string | undefined'. Type 'ReactElement<any>' is not assignable to type 'string'.

Steps to Reproduce (for bugs)

  1. create-react-app my-app --scripts-version=react-scripts-ts
  2. add material-ui
  3. add a component and try to compile

Context

Project do not build. ## Your Environment
Tech Version
Material-UI 1.0.0-beta10
React 15.3.0
typescript 2.3.4
kvindascr commented 7 years ago

Im closing this issue. Most of my issues have fixed by using @types/react@16.0.5 Although on runtime Im not running that version, which seems to the be the same configuration at the material-ui project. Seems that the typings rely heavily on react@16.0.x typings, which seems difficult to migrate them back to 15.x.