material-ui
material-ui copied to clipboard
[TypeScript] 'src/styles/index.d.ts' Declaration file defines mistake
src/styles/index.js and src/styles/index.d.ts these two documents are not consistent, This will cause the TypeScript environment to run well but in the browser environment will be an error
- [x] I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
import { createMuiTheme, createBreakpoints } from 'material-ui/styles';
const theme = createMuiTheme({
breakpoints: createBreakpoints({
values: {
xs: 360,
sm: 575,
md: 768,
lg: 991,
xl: 1199,
},
});
In the TypeScript environment is nothing wrong, but in the browser environment got a Uncaught TypeError: Object(createBreakpoints) is not a function.
Current Behavior
Now import it like this
import { createMuiTheme /*, createBreakpoints*/ } from 'material-ui/styles';
import createBreakpoints from 'material-ui/styles/createBreakpoints';
const theme = createMuiTheme({
breakpoints: createBreakpoints({
values: {
xs: 360,
sm: 575,
md: 768,
lg: 991,
xl: 1199,
},
});
Context
Your Environment
| Tech | Version |
|---|---|
| Material-UI | 1.0.0-beta.17 |
| React | 16 |
| browser | chrome 62 |
| TypeScript | 2.5.3 |
src/styles/index.js is the source of truth src/styles/index.d.t exposes some private modules. We need to remove those exports.
Regarding your example, it should work like this:
import { createMuiTheme } from 'material-ui/styles';
const theme = createMuiTheme({
breakpoints: {
values: {
xs: 360,
sm: 575,
md: 768,
lg: 991,
xl: 1199,
},
},
});
Thank you for the demo, I know how to do it