0

Today I've updated Angular/material to 9.2.4 from 9.2.0-next, and after ng serve I've got this:

platform.js:78 Uncaught TypeError: Class constructor Platform cannot be invoked without 'new'
    at Module../node_modules/@angular/cdk/__ivy_ngcc__/fesm2015/platform.js (platform.js:78)
    at __webpack_require__ (bootstrap:84)
    at Module../node_modules/@angular/cdk/__ivy_ngcc__/fesm2015/a11y.js (a11y.js:1)
    at __webpack_require__ (bootstrap:84)
    at Module../node_modules/@angular/material/__ivy_ngcc__/fesm2015/core.js (core.js:1)
    at __webpack_require__ (bootstrap:84)
    at Module../node_modules/@angular/material/__ivy_ngcc__/fesm2015/icon.js (icon.js:1)
    at __webpack_require__ (bootstrap:84)
    at Module../src/app/home/home.component.ts (home.component.ts:1)
    at __webpack_require__ (bootstrap:84)

Tried to delete node_modules folder and reinstall it, what can I do?

ng --version

Angular CLI: 9.1.8 Node: 12.8.1 OS: win32 x64

Angular: 9.1.11 ... animations, common, compiler, compiler-cli, core, forms ... language-service, localize, platform-browser ... platform-browser-dynamic, router, service-worker Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------ 
@angular-devkit/architect          0.901.8

@angular-devkit/build-angular      0.901.8 

@angular-devkit/build-optimizer    0.901.8 

@angular-devkit/build-webpack      0.901.8 

@angular-devkit/core           9.1.8 

@angular-devkit/schematics         9.1.8 

@angular/cdk                       10.0.0-rc.1-sha-a3dabc93d 

@angular/cli                       9.1.8 

@angular/material                  9.2.4 

@angular/material-moment-adapter   9.2.4 

@ngtools/webpack                 9.1.8 

@schematics/angular                9.1.8 

@schematics/update                 0.901.8 

rxjs                               6.5.5 

typescript                         3.7.5 

webpack                            4.42.0

ts.config

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "allowSyntheticDefaultImports": true
  }
}

ts.config.app

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": []
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ],
  "exclude": [
    "src/test.ts",
    "src/**/*.spec.ts"
  ]
}
Nemus
  • 1,322
  • 2
  • 23
  • 47
  • 1
    Can you please add the tsConfig file? This error is related to the fact that something is using the ES6 syntax (most likely material), while Angular is transpiling using ES5. Actually, es2015 preset is responsible for this behaviour. – Jacopo Sciampi Jun 15 '20 at 08:46
  • @JacopoSciampi But isn't ES2015 actually ES6? – Nemus Jun 15 '20 at 08:54
  • Yes, Es2015 is ES6. In your `tsConfig.json` file the `target` prop what value is holding? – Jacopo Sciampi Jun 15 '20 at 08:58
  • @JacopoSciampi as I posted, target": "es2015" – Nemus Jun 15 '20 at 09:00
  • Oh, Ok. I understand. I believe downgrading to ES5 will solve your issuse. `"target": "es2015" -> "es5"`. I mistyped before, I meant that something is using ES5 and not es2015. – Jacopo Sciampi Jun 15 '20 at 09:01
  • @JacopoSciampi Error: Error on worker #4: Error: getInternalNameOfClass() called on a non-ES5 class: expected UniqueSelectionDispatcher to have an inner class declaration after switching to es5 – Nemus Jun 15 '20 at 09:13
  • Mh, that's strange. Have you tried updating all the dependencies to their latest verion? https://flaviocopes.com/update-npm-dependencies/ – Jacopo Sciampi Jun 15 '20 at 09:17

1 Answers1

1

Solved by updating @angular/cdk to 9.2.4 too (ot was stucked to github:angular/cdk-builds), then re-installed everything with a clean npm i

Nemus
  • 1,322
  • 2
  • 23
  • 47