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.96k stars 32.27k forks source link

[system] TypeScript compose error #17836

Closed sunshixiong789 closed 4 years ago

sunshixiong789 commented 5 years ago

Current Behavior 😯

Capture d’écran 2019-12-01 aΜ€ 17 18 19

Types of parameters 'props' and 'props' are incompatible. Type '{ theme: DefaultTheme; }' …

Expected Behavior πŸ€”

No errors

Steps to Reproduce πŸ•Ή

https://codesandbox.io/s/create-react-app-with-typescript-02vx8

Context πŸ”¦

Your Environment 🌎

Tech Version
Material-UI v4.7.1
React 16.12.0
Browser
TypeScript 3.7.2
etc.
eps1lon commented 5 years ago

@sunshixiong789 Please provide a full reproduction test case. This would help a lot πŸ‘· . A live example would be perfect. This codesandbox.io template may be a good starting point. Thank you!

sunshixiong789 commented 5 years ago

https://codesandbox.io/embed/create-react-app-with-typescript-i5sp7

I used the demo, can't find error. but use IDE, throw the typescript error

eps1lon commented 5 years ago

I can reproduce it in the codesandbox (you have to force it to evaluate the expression).

Can't confirm if it's an actual bug though.

sunshixiong789 commented 5 years ago

I use the typescript3.5.2, it's a right,but I use the typescript3.6.3. throw the Error:(24, 3) TS2345: Argument of type 'StyleFunction<Partial<Record<"border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop", any>> & Partial<Record<"display" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "displayPrint", any>> & ... 6 more ... & Partial<...>>' is not assignable to parameter of type 'CreateCSSProperties | ((props: { theme: DefaultTheme; }) => CreateCSSProperties)'. Type 'StyleFunction<Partial<Record<"border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop", any>> & Partial<Record<"display" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "displayPrint", any>> & ... 6 more ... & Partial<...>>' is not assignable to type '(props: { theme: DefaultTheme; }) => CreateCSSProperties'. Types of parameters 'props' and 'props' are incompatible. Type '{ theme: DefaultTheme; }' has no properties in common with type 'Partial<Record<"border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop", any>> & Partial<Record<"display" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "displayPrint", any>> & ... 6 more ... & Partial<...>'.

coder2000 commented 5 years ago

This sandbox seems to have the same issue: https://codesandbox.io/s/k10p4yj8zr. This only happens when methods are used to interpolate a value. It looks like a method is not an accepted type which include 'string | number | CSSProperties | JSSFontface | JSSFontface[] | undefined'.

sunshixiong789 commented 5 years ago

It's not the same problem,you shoud use createStyles image

sunshixiong789 commented 5 years ago

I find the error image

https://codesandbox.io/s/create-react-app-with-typescript-02vx8

oliviertassinari commented 4 years ago

I have updated the issue description. The problem seems reproducible with the latest version.

oliviertassinari commented 4 years ago

I can't reproduce with the latest version (v5.0.0-alpha.13): https://codesandbox.io/s/create-react-app-with-typescript-forked-h8z1s?file=/src/Box.tsx.