Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to make dynamic module import work with module esnext in tsconfig in Angular 5

I am trying to make dynamic import work in my angular 5 application. As per this github issue, the comment says that using module: esnext should make it work. This is my config

"compilerOptions": {
  "outDir": "./dist/out-tsc",
  "noEmitOnError": true,
  "target": "es2016",
  "module": "esnext",
  "experimentalDecorators": true,
  "emitDecoratorMetadata": true,
  "sourceMap": true,
  "moduleResolution": "node",
  "declaration": false,
  "lib": [
    "es2016",
    "dom"
  ]
}

Note: Not having es2016 in lib gives me errors because I am using .find() and .includes on Array's in my code.

I get this error when compiling

error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.

Not sure why it still says targeting ECMA2015 modules when I have module: esnext.

like image 526
Taher Avatar asked May 25 '18 09:05

Taher


1 Answers

I figured this out. Turns out that it was a silly mistake and I was editing tsconfig.json in the root folder and there was another tsconfig.app.json in src folder that was overriding my settings.

like image 154
Taher Avatar answered Oct 17 '22 02:10

Taher