TypeScript Version: 2.4.0
Code
import('./utils')
.then(({ sum }) => {
console.log(sum(1, 2))
})
.catch(console.error)
tsconfig.json (short version)
{
"compilerOptions": {
"moduleResolution": "node",
"module": "es2015"
}
}
Expected behavior:
No errors
Actual behavior:
Dynamic import cannot be used when targeting ECMAScript 2015 modules. with non-obvious reasons why.
Example repository
I get error Dynamic import cannot be used when targeting ECMAScript 2015 modules.
when I try to use dynamic import inside typescript project with "module": "es2015"
in configuration. The error message makes it clear that I can't use import() with
es modules but it doesn't make sense because import() is part of es modules.
However, it compiles correctly but throw annoing error.
I created a repository to reproduce an error.
npm run build-ts: compile ts files into build/ folder.
npm run build-webpack: compile js into dist/. (Then open index.html to see that everything works fine)
TypeScript Version: 2.4.0
Code
tsconfig.json (short version)
{ "compilerOptions": { "moduleResolution": "node", "module": "es2015" } }Expected behavior:
No errors
Actual behavior:
Dynamic import cannot be used when targeting ECMAScript 2015 modules.with non-obvious reasons why.Example repository
I get error
Dynamic import cannot be used when targeting ECMAScript 2015 modules.when I try to use dynamic import inside typescript project with
"module": "es2015"in configuration. The error message makes it clear that I can't use
import()withes modules but it doesn't make sense because
import()is part of es modules.However, it compiles correctly but throw annoing error.
I created a repository to reproduce an error.
npm run build-ts: compile ts files intobuild/folder.npm run build-webpack: compile js intodist/. (Then openindex.htmlto see that everything works fine)