create-react-app-with-typescript ts compilation error
See original GitHub issueHi - I cloned the example from https://github.com/mui-org/material-ui/tree/next/examples/create-react-app-with-typescript-next and built it with yarn. I got a ts complation error:
/create-react-app-with-typescript-next/src/ProTip.tsx(17,13):
Object is of type 'unknown'. TS2571
15 | const useStyles = makeStyles(theme => ({
16 | root: {
> 17 | margin: theme.spacing(6, 0, 3),
| ^
18 | },
19 | lightBulb: {
20 | verticalAlign: 'middle',
Compiling...
Failed to compile.
I googled and found a fix in issue #15400 by @nareshbhatia in the PS in the description which solved my problem too. I just wanted to highlight this for other people using this demo code. Fix is to:
-
Import
import { Theme } from '@material-ui/core/styles' -
Change the code to type the Theme:
const useStyles = makeStyles((theme: Theme) => ({
root: {
margin: theme.spacing(6, 0, 3),
},
lightBulb: {
verticalAlign: 'middle',
marginRight: theme.spacing(1),
},
}));
I didn’t reproduce it as it was literally a cloned copy straight from the demo example on GitHub mentioned above. Thanks!
- This is not a v0.x issue.
- I have searched the issues of this repository and believe that this is not a duplicate.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:14 (10 by maintainers)
Top Results From Across the Web
create-react-app-with-typescript ts compilation error #15542
I got a ts complation error: /create-react-app-with-typescript-next/src/ProTip.tsx(17,13): Object is of type 'unknown'. TS2571 15 | const ...
Read more >Create-React-App with TypeScript failing to compile after ...
But when I add import 'semantic-ui-css/semantic.min.css'; to index.tsx as instructed, I get a failed to compile error .
Read more >Can I get Typescript to prevent compilation on errors?
I'm currently running TS Lint as a separate step to prevent this from ... Yeah somehow create react app with typescript will halt...
Read more >Adding TypeScript
Type errors will show up in the same console as the build one. You'll have to fix these type errors before you continue...
Read more >TypeScript
In this guide we will learn how to integrate TypeScript with webpack. Basic Setup. First install the TypeScript compiler and loader by running:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@emmtqg Thank you for reporting the problem! What do you think of this change?
cc @merceyz
The error was already fixed