material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[TypeScript] 'src/styles/index.d.ts' Declaration file defines mistake

Open chilbi opened this issue 9 years ago • 3 comments

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

chilbi avatar Oct 22 '17 17:10 chilbi

src/styles/index.js is the source of truth src/styles/index.d.t exposes some private modules. We need to remove those exports.

oliviertassinari avatar Oct 22 '17 18:10 oliviertassinari

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,
    },
  },
});

oliviertassinari avatar Oct 22 '17 18:10 oliviertassinari

Thank you for the demo, I know how to do it

chilbi avatar Oct 23 '17 04:10 chilbi