Material-ui: Cannot find name 'Map' error

Created on 19 Jan 2018  路  5Comments  路  Source: mui-org/material-ui

I get this error (shown in red text at bottom of image) when I hit compile. The error is only shown in the node module.

I did an npm install material-ui-next@latest just now to make sure I had the latest version.

I'm using TypeScript and Material-UI beta version.

Thanks
image

wontfix

Most helpful comment

Ok find it ! It is cause by tsconfig.json. we need to specified the es6 instead es5.

{
  "compilerOptions": {
    "outDir": "./dist/",
    "sourceMap": true,
    "noImplicitAny": true,
    "module": "commonjs",
    "target": "es6", <===  it was "es5" before : my bad
    "jsx": "react",
    "allowJs": true
  },
  "include": ["./src/**/*"]
}

All 5 comments

@mhafer From what I can understand, you are using an old browser than doesn't support the Map object. It's supported by the following browsers: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map. Here are the browsers we are supporting: https://material-ui-next.com/getting-started/supported-platforms/#browser

Hey, I got the same issue but my Chrome have the right version Version 64.0.3282.119 (Build officiel) (64 bits). Any Idea ?

I have no clue.

Ok find it ! It is cause by tsconfig.json. we need to specified the es6 instead es5.

{
  "compilerOptions": {
    "outDir": "./dist/",
    "sourceMap": true,
    "noImplicitAny": true,
    "module": "commonjs",
    "target": "es6", <===  it was "es5" before : my bad
    "jsx": "react",
    "allowJs": true
  },
  "include": ["./src/**/*"]
}

To solve this you only need to import map method in your ts file like this:
import { map } from 'rxjs/operators';

Was this page helpful?
0 / 5 - 0 ratings