Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeScript 3.3.3] The inferred type of 'styles' cannot be named without a reference to @material-ui/core/styles/withStyles #14487

Closed
2 tasks done
screendriver opened this issue Feb 11, 2019 · 6 comments

Comments

@screendriver
Copy link

screendriver commented Feb 11, 2019

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior 馃

Should compile.

Current Behavior 馃槸

Does not compile. I get the error message The inferred type of 'MyComponent' cannot be named without a reference to 'myProject/node_modules/@material-ui/core'. This is likely not portable. A type annotation is necessary.

Steps to Reproduce 馃暪

I followed the guide in your official docs. Just create a new simple component like this to see the error:

const styles = createStyles({});

interface Props extends WithStyles<typeof styles> {
    foo: string;
}

export const MyComponent = withStyles(styles)((props: Props) => <div>{props.foo}</div>);

With TypeScript 3.1.6 everything works as expected.

Context 馃敠

Your Environment 馃寧

Tech Version
Material-UI v3.9.2
React v16.6.3
Browser
TypeScript v3.3.3
etc.
@eps1lon
Copy link
Member

eps1lon commented Feb 11, 2019

Is this error message generated for the file that includes that code? The error message references the name MyComponent which does not appear in your provided code.

@eps1lon eps1lon added status: waiting for author Issue with insufficient information typescript labels Feb 11, 2019
@screendriver
Copy link
Author

This is just a copy and paste mistake. Sorry. It complains about that component that you can see in my code snippet.

@eps1lon eps1lon removed the status: waiting for author Issue with insufficient information label Feb 11, 2019
@eps1lon
Copy link
Member

eps1lon commented Feb 11, 2019

Is this similar to microsoft/TypeScript#29221? @screendriver What filesystem are you using (what OS for starters)?

@screendriver
Copy link
Author

What filesystem are you using (what OS for starters)?

I'm using macOS 10.14.2 as my working machine and I'm using NixOS in our CI/CD pipeline. It breaks on both machines.

microsoft/TypeScript#29221 is about symlinks. I'm not using any symlink.

@eps1lon
Copy link
Member

eps1lon commented Feb 12, 2019

Created a repro that is working on codesandbox and locally (ubuntu 18.04 + yarn). Could you provide your own repro?

@screendriver
Copy link
Author

Ah! I created a minimal small fresh repo from scratch. In this repository everything works. I tried to reproduce everything in our product repository and now I believe you were right: there are some symlinks and with them the compiler breaks 馃槼 I don't know why but I did the same things when I created this issue but with a different result. So your referenced issue is now exactly our problem.

I will close this one because it is luckily not related to material-ui (though I just see errors from there and not from any other dependency 馃). Thanks @eps1lon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants