material-ui: TS errors with styled-engine-sc and skipLibCheck: false

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Steps:

git clone https://github.com/jscheid/mui-sc-lib-check
cd mui-sc-lib-check
yarn
yarn tsc

Current behavior 😯

TS compilation errors: https://gist.github.com/jscheid/c2debf024f6683153de705520e8f5ca6

Expected behavior 🤔

No errors.

Context 🔦

This is only an issue with skipLibCheck: false in tsconfig.json. When skipping lib checks, no errors appear.

It could be something I’m doing wrong? Specifically I’m not sure about including @types/styled-components, which I didn’t see recommended anywhere. However, when I leave it out I’m getting a different set of errors.

Obviously this is easy to work around by setting skipLibCheck but I’d prefer to be able to enable these checks.

Your environment 🌎

See repo.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 20 (9 by maintainers)

Most upvoted comments

The same error occurs when running npx tsc --noEmit (or npm run tsc) in https://github.com/mui/material-ui/tree/master/examples/material-ui-cra-styled-components-ts - I’m not sure if that is the same example, the old links posted here don’t seem to be working anymore.

But this means this error is still occurring in an official demo project. I’m not sure why this is closed to be honest. Am I missing something? (Genuine question, I don’t mean to be sarcastic or snarky or anything.) I’m kinda surprised this issue was pretty hard for me to find, I would have expected more traction on this issue considering it’s so simple to reproduce and appears to happen in the official demo. So I’m really not convinced I’m not just missing something essential here.

For now, we are using the skipLibCheck = true, but if there are other ways to mitigate this issue, I’d love to hear about them.

After consulting with my co-workers, we are now in the process of migrating to styled-components and styled-engine-sc v6, so no backport needed for us.

Thanks again for your support!

Okay. I’ll discuss with my co-workers on Monday but after looking into said libraries, I’m optimistic that we can use styled-components/styled-engine-sc v6 and won’t need a backport.

I am reopening and opening a pull request. Seems like we missed some types in this package that existed in the @mui/styled-engine. We also had some issues with mismatch of the generic types.

If it doesn’t happen here https://github.com/mui/material-ui/blob/master/examples/create-react-app-with-styled-components-typescript/tsconfig.json then there is nothing left I can do. Just follow the example. The instructions there are for scenarios where we don’t have example project

@mnajdova I just downloaded the example you mentioned, did npm install and npm run tsc and got the same errors I am getting in my project (and the same that @jscheid reported):

image

Any suggestion on how to solve this (having skipLibCheck = true) ?

@mnajdova thanks!

@vanyaxk thanks but this issue is specifically about typings with @mui/styled-engine-sc as described here, sorry if I haven’t made that clear enough.