-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Typescript] Invalid createStyles definition (v4 beta) #15532
Comments
For convenience we should just forward this to |
Aside: importing from |
Thanks for the quick response 👍 |
@eps1lon On a different point, I was under the assumption that createStyles is no longer needed for withStyles and soon for makeStyles. Should we reflect this fact in the upgrade guide? |
It was never needed for either one. It was and is a convenience helper. |
@eps1lon Rereading #15390 (comment), the important word is "immediate". This convenience helper is still needed. |
Correct. The main issue is type widening const someObject = { foo: 'literal' }; // typeof someObject = { foo: string }
takeSomeObject(someObject); // throws if it expects { foo: 'literal' | 'anotherLiteral' }
takeSomeObject({ foo: 'someLiteral' }): // works since typescript doesn't infer a type. it just checks if the expected type matches the given type |
So everybody who wants to create an intermediary variable for the styles(creator|object) still needs the helper. |
It seems the typings for
createStyles
are invalid in v4 beta 0. As you can see in the following snippet, Typescript will accept:import { createStyles } from '@material-ui/core';
but runtime, this will throw an error (
_core.createStyles is not a function
):https://codesandbox.io/s/wqqzkjvyx5
It seems like an attempt has been made to forward the definition to the styles package, but if I'm not missing something, this does not work.
The text was updated successfully, but these errors were encountered: