-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Master] wip-dynamic import #14774
[Master] wip-dynamic import #14774
Conversation
…onsistent with ECMA spec
…ypeScript into master-dynamicImport
@filipesilva thanks for the document!. For webpack users it will probably be best to have Correction: it will |
I did not know that was an option, and that indeed sounds like the better alternative 👍 |
@yuit so is this going to be forthcoming in the next TypeScript release? 2.3.4 complains about import() even with target of esnext. Not sure if I'm missing something. |
this will be in TS 2.4. you can give it a try today in |
Cool - thanks! |
My {
"compilerOptions": {
"module": "es6",
"target": "es6",
"moduleResolution": "node",
"baseUrl": "src",
"allowJs": true,
"allowSyntheticDefaultImports": true,
"jsx": "preserve",
"pretty": true,
"removeComments": true,
"sourceMap": true
},
"exclude": [
"node_modules"
]
} TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. const AsyncRoutes = Loadable({
loader: () => import('./Routes' /* webpackChunkName: "routes" */),
LoadingComponent: () => null,
}) That seems misleading. I'm not targetting ECMAScript 2015 modules anywhere, or am i? What are the correct settings? |
@codepunkt , you're using
See #14495 for more information. |
@trotyl Thanks. That helps me only to the extent that i know that i actually targetted ECMAScript 2015 modules. It doesn't tell me what my |
@codepunkt The option for leaving as-is is |
Thanks. That works 👍 |
Does anybody know whether there is synchronous import in ES? |
Synchronous import is done with regular import X from 'x' at the top of your file. Dynamic import() statements always return a promise and are async. |
@arackaf I want a conditional synchronous import. If I only could have import in the middle of the file. |
#14495
IncrementExpression
toUpdateExpression
(this is so that it is consistent with ES6 spec); small update on commentTODO
Address declaration emit.... Current it will be an error when emit .d.ts, users will have to explicitly specify type of the dynamic import
Add more tests for noImplicitAny, specifier not string type, more emit tests
Update baselines'
Update breaking change. https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes. Use termUpdateExpression
instead ofIncrementExpression
Document about how dynamic import behave with webpack and browserify
Note: this PR need #14692 so that baselines can be updated correctly..See (tests/cases/conformance/es2018/dynamicImport/importCallExpressionInAMD3.ts as example) compiler will throw exception when trying to write type of extendheritageclause
Note: ImportCallExpression is simply parse as CallExpression (similar to super call)
Also dynamic import can be parsed with type argument, it doesn't do anything at the moment (we can either error or that can be used for other purpose)