Title: Import Attributes (Stage 3) · Issue #53656 · microsoft/TypeScript · GitHub
Open Graph Title: Import Attributes (Stage 3) · Issue #53656 · microsoft/TypeScript
X Title: Import Attributes (Stage 3) · Issue #53656 · microsoft/TypeScript
Description: Suggestion 🔍 Search Terms import attributes, import assertions, esnext ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScript code This wouldn't change the runtime...
Open Graph Description: Suggestion 🔍 Search Terms import attributes, import assertions, esnext ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScri...
X Description: Suggestion 🔍 Search Terms import attributes, import assertions, esnext ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/Java...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/53656
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Import Attributes (Stage 3)","articleBody":"# Suggestion\r\n\r\n## 🔍 Search Terms\r\n\r\nimport attributes, import assertions, esnext\r\n\r\n## ✅ Viability Checklist\r\n\r\n\u003c!--\r\n Suggestions that don't meet all these criteria are very, very unlikely to be accepted.\r\n We always recommend reviewing the TypeScript design goals before investing time writing\r\n a proposal for ideas outside the scope of the project.\r\n-->\r\nMy suggestion meets these guidelines:\r\n\r\n* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n* [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [x] This could be implemented without emitting different JS based on the types of the expressions\r\n* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)\r\n* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n\r\n## ⭐ Suggestion\r\n\r\nhttps://github.com/tc39/proposal-import-attributes\r\n\r\nIn January 2023, Import Assertions proposal was demoted back to Stage 2 to investigate a solution for the web platform's needs. In March 2023, the proposal was renamed to Import Attributes and moved back to Stage 3 (with conditional consensus - pending spec text review).\r\n\r\nTypeScript should support the new syntax. The most relevant change for TypeScript is that the keyword changed from `assert` to `with`.\r\n\r\n```ts\r\nimport json from \"./foo.json\" with { type: \"json\" };\r\n\r\nimport(\"foo.json\", { with: { type: \"json\" } });\r\n\r\nexport { val } from './foo.js' with { type: \"javascript\" };\r\n```\r\n\r\nThe minimal option here is just to add the `with` syntax. Ideally there would also be two enhancements:\r\n\r\n* **Deprecating `assert`:** For compatibility with existing implementations, the `assert` keyword is still allowed by the spec until it's safe to remove it. Chrome will explore removing it. Babel [is deprecating the syntax with a plan to eventually remove it in Babel 8](https://github.com/babel/babel/pull/15536). TypeScript could follow something similar to [the 5-release deprecation process](https://github.com/microsoft/TypeScript/issues/51000) by initially suggesting migration via warnings and quick fixes - though we recognise that the deprecation process was originally intended only for flags.\r\n* **Auto-complete for static import/re-export declarations:** Auto-complete seems to be only working with dynamic `import()` right now. This could be expanded to also work for attributes in static declarations.\r\n\r\n## 📃 Motivating Example\r\n\r\nThis will be new ECMAScript syntax so motivation is to be compatible with the language. The champion group considers this to be stable, even though it just changed: this is what re-promoting to Stage 3 represents.\r\n\r\nIt sounds like this would also unblock https://github.com/microsoft/TypeScript/issues/49055#issuecomment-1485768138.\r\n\r\n## 💻 Use Cases\r\n\r\nhttps://github.com/tc39/proposal-import-attributes#motivation\r\n\r\nIn addition, we have an internal use case in Bloomberg to use Import Attributes as an annotation to achieve lazy-loading by deferring module evaluation. This is an early implementation of [the TC39 proposal for Deferring Module Evaluation](https://github.com/tc39/proposal-defer-import-eval).\r\n\r\n---\r\n\r\nThis issue is raised only for awareness. At this point we are not planning to implement.\r\n","author":{"url":"https://github.com/mkubilayk","@type":"Person","name":"mkubilayk"},"datePublished":"2023-04-04T10:34:27Z","url":"https://github.com/microsoft/TypeScript/issues/53656"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0b1af26e-9b67-8f4c-1807-3bc6b6f23748 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 816C:1C6C3E:B222D9:EC6A12:6B00ED41 |
| html-safe-nonce | fada74c9069ce761b32dce8d78207fdbf548d79001ccd5af0ad7e4956198324d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTZDOjFDNkMzRTpCMjIyRDk6RUM2QTEyOjZCMDBFRDQxIiwidmlzaXRvcl9pZCI6IjU2NzkzOTUzNDc5MDcwMTM5NTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8318c124540ea0792c43de6289b621d8ee6090374355143eb1066fd197a43b0e |
| hovercard-subject-tag | issue:1653621852 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/53656/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7322fae185613cc1b6fda044d5b718754b64b55a256fd1ece470bd5874f299fd/microsoft/TypeScript/issues/53656 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7322fae185613cc1b6fda044d5b718754b64b55a256fd1ece470bd5874f299fd/microsoft/TypeScript/issues/53656 |
| og:image:alt | Suggestion 🔍 Search Terms import attributes, import assertions, esnext ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScri... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mkubilayk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width