René's URL Explorer Experiment


Title: [Design Spec] ESNext import() · Issue #14495 · microsoft/TypeScript · GitHub

Open Graph Title: [Design Spec] ESNext import() · Issue #14495 · microsoft/TypeScript

X Title: [Design Spec] ESNext import() · Issue #14495 · microsoft/TypeScript

Description: import(specifier) is a newly proposed syntax for dynamically module loading. import(specifier) takes an assignment expression as an input (Note: unlike ES6 static import which only allow string literal as module specifier) and returns a ...

Open Graph Description: import(specifier) is a newly proposed syntax for dynamically module loading. import(specifier) takes an assignment expression as an input (Note: unlike ES6 static import which only allow string lit...

X Description: import(specifier) is a newly proposed syntax for dynamically module loading. import(specifier) takes an assignment expression as an input (Note: unlike ES6 static import which only allow string lit...

Opengraph URL: https://github.com/microsoft/TypeScript/issues/14495

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Design Spec] ESNext import()","articleBody":"`import(specifier)` is a newly proposed syntax for dynamically module loading. `import(specifier)` takes an assignment expression as an input (Note: unlike ES6 static import which only allow string literal as [module specifier](https://tc39.github.io/ecma262/#prod-ModuleSpecifier)) and returns a promise of [module namespace object](https://tc39.github.io/ecma262/#sec-module-namespace-objects).\r\n\r\nThe full proposal can be found [here](https://github.com/tc39/proposal-dynamic-import)\r\nOriginal issue: #12364\r\n\r\nThis issue will discuss design proposal for implementing `import()`: parsing, type-checking, and emitting. \r\n\r\nThe proposal will NOT include \"module namespace object\" type  and expressing the shape of the loaded module (To be able to express such type will allow users to cast the result instead of \"any\" to be what they expected at runtime)...The issue will be discussed and implemented separately.\r\n\r\n**Parsing**\r\n`import(specifier)` will be parsed as [CallExpression](https://tc39.github.io/proposal-dynamic-import/#prod-ImportCall). and `specifier` will be parsed as [AssignmentExpression](https://tc39.github.io/ecma262/#prod-AssignmentExpression)\r\n\r\n**Error**\r\n\r\n- Error if the `module` flag is ES2015.\r\n\r\n- Error if `specifier` is not assignable to string type\r\n\r\n**Type-checking**\r\n\r\n- `specifier` is type checked as string type. (Clarification: the only limitation for `specifier` in original proposal is that it can called `toString()`)\r\n- The return of `import(specifier)` will be as following\r\n-- if known module can be resolved from `specifier`, then we return Promise of module namespace object   \r\n-- if not known module, then we return Promise of any. ~~This will give an error in `noImplicitAny` mode and `import()` is used as an expression~~ After offline discussion with @mhegazy @bowdenk7 @DanielRosenwasser, we think reporting an error without providing a way to easily get out of it (see #14844 for more detail) is undesirable. By casting to `Promise\u003cany>` to satisfy the compiler will not provide users any benefit and arguably is a drawback because if in the future, there is a way to type the module easily, upgrading to use such syntax will not be convenient. Therefore, we will not issue an `noImplicitAny` error with this feature but with #14844 instead.\r\n\r\n- We will use existed module resolution logic to try to figure out the module of the dynamic import.\r\n\r\n**Emit**\r\nEmit for each different `module` kind emit is outlined below\r\n```typescript\r\nimport('blah');\r\n```\r\n- Node\r\n```js\r\nPromise.resolve().then(() => require('blah'));\r\n```\r\n\r\n- AMD\r\n```js\r\ndefine([\"require\", \"exports\"], function (require, exports) {\r\n    \"use strict\";\r\n    Object.defineProperty(exports, \"__esModule\", { value: true });\r\n    new Promise(resolve => require(['blah'], resolve));\r\n});\r\n```\r\n- UMD\r\n\r\n``` js\r\n(function (factory) {\r\n    if (typeof module === \"object\" && typeof module.exports === \"object\") {\r\n        var v = factory(require, exports);\r\n        if (v !== undefined) module.exports = v;\r\n    }\r\n    else if (typeof define === \"function\" && define.amd) {\r\n        define([\"require\", \"exports\"], factory);\r\n    }\r\n})(function (require, exports) {\r\n    \"use strict\";\r\n    Object.defineProperty(exports, \"__esModule\", { value: true });\r\n    require.length === 1 ?\r\n        /*CommonJs Require*/ Promise.resolve().then(() => require('blah'));\r\n        /*Amd Require*/ new Promise(resolve => require(['blah'], resolve));\r\n});\r\n```\r\n\r\n- System (Updated from [comment](https://github.com/Microsoft/TypeScript/issues/14495#issuecomment-285294096))\r\n```js\r\nSystem.register([], function (_export, _context) {\r\n  return {\r\n    setters: [],\r\n    execute: () => {\r\n      _context.import('dynamic');\r\n    }\r\n  };\r\n});\r\n```\r\n\r\n- ES2018 _new value_\r\n```js\r\nimport('blah')\r\n```\r\n","author":{"url":"https://github.com/yuit","@type":"Person","name":"yuit"},"datePublished":"2017-03-06T23:49:33Z","url":"https://github.com/microsoft/TypeScript/issues/14495"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:5bf33282-9f82-4c05-4f10-d91028c51e29
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8DD6:311EEE:DCF043:126883B:6B00FEE2
html-safe-nonce12cd9e5b7c8247d332b6b19c55807704260abf5d8c0acf64009143bf07574b9f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4REQ2OjMxMUVFRTpEQ0YwNDM6MTI2ODgzQjo2QjAwRkVFMiIsInZpc2l0b3JfaWQiOiIyMjgzNjMzODAzODQwNzgyMDUxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac91aa9e4137360c702f9071bfedbc6f44119a3850578485ad5b36a4d19abcb006
hovercard-subject-tagissue:212287038
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/14495/issue_layout
twitter:imagehttps://opengraph.githubassets.com/392ac1027c6cad042dc5017d9948643f6cfbe76b0e71ba67bb866a87c2c23d06/microsoft/TypeScript/issues/14495
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/392ac1027c6cad042dc5017d9948643f6cfbe76b0e71ba67bb866a87c2c23d06/microsoft/TypeScript/issues/14495
og:image:altimport(specifier) is a newly proposed syntax for dynamically module loading. import(specifier) takes an assignment expression as an input (Note: unlike ES6 static import which only allow string lit...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameyuit
hostnamegithub.com
expected-hostnamegithub.com
Nonecb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124
turbo-cache-controlno-preview
go-importgithub.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id20929025
octolytics-dimension-repository_nwomicrosoft/TypeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id20929025
octolytics-dimension-repository_network_root_nwomicrosoft/TypeScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/14495#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F14495
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F14495
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/14495
Reloadhttps://github.com/microsoft/TypeScript/issues/14495
Reloadhttps://github.com/microsoft/TypeScript/issues/14495
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests309 (309)https://github.com/microsoft/TypeScript/pulls
Actionshttps://github.com/microsoft/TypeScript/actions
Projectshttps://github.com/microsoft/TypeScript/projects
Wikihttps://github.com/microsoft/TypeScript/wiki
Security and qualityhttps://github.com/microsoft/TypeScript/security
Insightshttps://github.com/microsoft/TypeScript/insights
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/14495
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/14495
[Design Spec] ESNext import()https://github.com/microsoft/TypeScript/issues/14495#top
https://github.com/yuit
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
ES NextNew featurers for ECMAScript (a.k.a. ESNext)https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22ES%20Next%22
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
TypeScript 2.4.1https://github.com/microsoft/TypeScript/milestone/50
https://github.com/yuit
Yui (yuit)https://github.com/yuit
on Mar 6, 2017https://github.com/microsoft/TypeScript/issues/14495#issue-212287038
module specifierhttps://tc39.github.io/ecma262/#prod-ModuleSpecifier
module namespace objecthttps://tc39.github.io/ecma262/#sec-module-namespace-objects
herehttps://github.com/tc39/proposal-dynamic-import
#12364https://github.com/microsoft/TypeScript/issues/12364
CallExpressionhttps://tc39.github.io/proposal-dynamic-import/#prod-ImportCall
AssignmentExpressionhttps://tc39.github.io/ecma262/#prod-AssignmentExpression
Mohamed Hegazy (@mhegazy)https://github.com/mhegazy
Bowden Kelly (@bowdenk7)https://github.com/bowdenk7
Daniel Rosenwasser (@DanielRosenwasser)https://github.com/DanielRosenwasser
[Design] Syntax to represent module namespace object in dynamic import #14844https://github.com/microsoft/TypeScript/issues/14844
[Design] Syntax to represent module namespace object in dynamic import #14844https://github.com/microsoft/TypeScript/issues/14844
commenthttps://github.com/Microsoft/TypeScript/issues/14495#issuecomment-285294096
Nexthttps://github.com/microsoft/TypeScript/issues/14495?timeline_page=1
Yui (yuit)https://github.com/yuit
on Mar 6, 2017https://github.com/microsoft/TypeScript/issues/14495#event-988713015
Yui (yuit)https://github.com/yuit
TypeScript 2.3https://github.com/microsoft/TypeScript/milestone/38
on Mar 6, 2017https://github.com/microsoft/TypeScript/issues/14495#event-988713071
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Mar 7, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-284575388
https://github.com/jods4
jods (jods4)https://github.com/jods4
on Mar 7, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-284583986
Mohamed Hegazy (@mhegazy)https://github.com/mhegazy
https://github.com/Igorbek
Igor Oleinikov (Igorbek)https://github.com/Igorbek
on Mar 7, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-284585835
https://github.com/Igorbek
Igor Oleinikov (Igorbek)https://github.com/Igorbek
on Mar 7, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-284586088
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Mar 7, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-284586660
Mohamed Hegazy (@mhegazy)https://github.com/mhegazy
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Mar 7, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-284587085
https://github.com/Jessidhia
Jessica Franco (Jessidhia)https://github.com/Jessidhia
on Mar 7, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-284589366
https://github.com/Jessidhia
Jessica Franco (Jessidhia)https://github.com/Jessidhia
on Mar 7, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-284589956
Mohamed Hegazy (@mhegazy)https://github.com/mhegazy
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Mar 7, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-284590235
https://github.com/Jessidhia
Jessica Franco (Jessidhia)https://github.com/Jessidhia
on Mar 7, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-284590622
https://github.com/mohsen1
Mohsen Azimi (mohsen1)https://github.com/mohsen1
on Mar 7, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-284622136
#12364https://github.com/microsoft/TypeScript/issues/12364
https://github.com/jods4
jods (jods4)https://github.com/jods4
on Mar 7, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-284705594
Mohamed Hegazy (@mhegazy)https://github.com/mhegazy
https://github.com/bmeck
Bradley Farias (bmeck)https://github.com/bmeck
on Mar 7, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-284732294
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
TypeScript 2.3https://github.com/microsoft/TypeScript/milestone/38
on Apr 4, 2017https://github.com/microsoft/TypeScript/issues/14495#event-1029170067
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
TypeScript 2.4https://github.com/microsoft/TypeScript/milestone/43
TypeScript 2.3.1https://github.com/microsoft/TypeScript/milestone/42
on Apr 13, 2017https://github.com/microsoft/TypeScript/issues/14495#event-1042636558
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
ES NextNew featurers for ECMAScript (a.k.a. ESNext)https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22ES%20Next%22
on Apr 13, 2017https://github.com/microsoft/TypeScript/issues/14495#event-1042636736
https://github.com/saschanaz
Kagami Sascha Rosylight (saschanaz)https://github.com/saschanaz
on Apr 18, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-294879961
#12473https://github.com/microsoft/TypeScript/issues/12473
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
on Jun 6, 2017https://github.com/microsoft/TypeScript/issues/14495#event-1110954528
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
TypeScript 2.4https://github.com/microsoft/TypeScript/milestone/43
TypeScript 2.4.1https://github.com/microsoft/TypeScript/milestone/50
on Jun 8, 2017https://github.com/microsoft/TypeScript/issues/14495#event-1114871433
Yui (yuit)https://github.com/yuit
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jun 8, 2017https://github.com/microsoft/TypeScript/issues/14495#event-1115795277
https://github.com/olmobrutall
Olmo del Corral (olmobrutall)https://github.com/olmobrutall
on Jun 29, 2017https://github.com/microsoft/TypeScript/issues/14495#issuecomment-311948968
#16820https://github.com/microsoft/TypeScript/issues/16820
microsofthttps://github.com/microsoft
on Jun 19, 2018https://github.com/microsoft/TypeScript/issues/14495#event-1689931640
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/14495
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/14495
Yui (yuit)https://github.com/yuit
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
ES NextNew featurers for ECMAScript (a.k.a. ESNext)https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22ES%20Next%22
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
TypeScript 2.4.1https://github.com/microsoft/TypeScript/milestone/50
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.