René's URL Explorer Experiment


Title: Ambient Module Declarations for Import Attributes (formerly known as Import Assertions) · Issue #46135 · microsoft/TypeScript · GitHub

Open Graph Title: Ambient Module Declarations for Import Attributes (formerly known as Import Assertions) · Issue #46135 · microsoft/TypeScript

X Title: Ambient Module Declarations for Import Attributes (formerly known as Import Assertions) · Issue #46135 · microsoft/TypeScript

Description: Suggestion 🔍 Search Terms import attributes, import assertions, ambient module ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScript code This wouldn't change the...

Open Graph Description: Suggestion 🔍 Search Terms import attributes, import assertions, ambient module ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/...

X Description: Suggestion 🔍 Search Terms import attributes, import assertions, ambient module ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScr...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Ambient Module Declarations for Import Attributes (formerly known as Import Assertions)","articleBody":"# Suggestion\n\n## 🔍 Search Terms\n\nimport attributes, import assertions, ambient module\n\n## ✅ Viability Checklist\n\nMy suggestion meets these guidelines:\n\n* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code\n* [x] This wouldn't change the runtime behavior of existing JavaScript code\n* [x] This could be implemented without emitting different JS based on the types of the expressions\n* [x] This isn't a runtime feature (e.g., library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)\n* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\n\n\n## ⭐ Suggestion\n\n\u003c!-- A summary of what you'd like to see added or changed -->\n\nFollowing the suggestion at https://github.com/microsoft/TypeScript/issues/40694#issuecomment-918343758\nAllow projects to declare ambient modules based on the import attributes. Such as:\n\n```ts\ndeclare module '*' with {type: 'css'} {\n  const stylesheet: CSSStyleSheet;\n  export default stylesheet;\n}\n```\n\n## 📃 Motivating Example\n\nCurrently frontend build tools use file extensions and URL query strings to support all kinds of custom modules that are eventually compiled into JavaScript.\n\nFor example, in Vite (webpack supports these features in a similar way), we support JS modules importing `.module.css` files as CSS modules, and adding `?url` postfixes to the imported path means we are to import the asset's real URL after bundling.\n\nThat is:\n```js\n// get the exported classes from a CSS module\nimport classes from './example.module.css'\n\n// Explicitly load assets as URL\nimport assetAsURL from './asset.js?url'\n```\n\nBut:\n1. The extension approach may collide with new browser native features, such as [the native CSS modules](https://css-tricks.com/css-modules-the-native-ones/). So it's better to have a way to differentiate them. Import attributes could help in this case.\n2. The query string approach is not a standard.\n    - It alters the standard semantics of an import statement\n    - Different tools vary on their choices of queries\n    - Modules with such syntaxes won't be able to run separately without *the specific bundler*\n    - So, we hope to migrate away from this approach and base the feature upon a standard. Import attributes seems to be the way to go.\n\nOne thing that blocks us from doing so is the ability to declare ambient modules based on import assertions in TypeScript.\n\nWe can easily have type definitions for files based on their file extensions and query strings. In vite we have: https://github.com/vitejs/vite/blob/b690810f555549e9eed4b03600b27fe7649d6b07/packages/vite/client.d.ts\n\nBut currently, I don't see a way to migrate these type definitions when we move to import assertions.\n\n## 💻 Use Cases\n\n\u003c!--\n  What do you want to use this for?\n  What shortcomings exist with current approaches?\n  What workarounds are you using in the meantime?\n-->\n\n1. The abovementioned frontend build tools.\n2. Type definitions for browsers' built-in CSS & JSON modules support. We can have `declare module '*' assert {type: 'json'}` and `declare module '*' assert {type: 'css'}` in the DOM lib.","author":{"url":"https://github.com/haoqunjiang","@type":"Person","name":"haoqunjiang"},"datePublished":"2021-09-29T14:01:07Z","url":"https://github.com/microsoft/TypeScript/issues/46135"}

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:5ffb7c93-5e70-3128-dc43-a0642b6ba014
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDD46:3897F3:B97B18:F0CD71:6B00ED5C
html-safe-nonce0c644b622f93b29b01a1f3a0bf7d440d20be945b1d744fce6bf2655b021196fd
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDQ2OjM4OTdGMzpCOTdCMTg6RjBDRDcxOjZCMDBFRDVDIiwidmlzaXRvcl9pZCI6IjQyNDIxMjU1ODkzMDMwNjE4NTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac4d0628d6f531bea27c8ecf460a7a72cd772ee1bb8fe0974ebf00f044330623d7
hovercard-subject-tagissue:1011000366
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/46135/issue_layout
twitter:imagehttps://opengraph.githubassets.com/affd4ec8eef70b2b186dbc4c04644bcebbf79e1fb31e956d469e16f27faa44d1/microsoft/TypeScript/issues/46135
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/affd4ec8eef70b2b186dbc4c04644bcebbf79e1fb31e956d469e16f27faa44d1/microsoft/TypeScript/issues/46135
og:image:altSuggestion 🔍 Search Terms import attributes, import assertions, ambient module ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamehaoqunjiang
hostnamegithub.com
expected-hostnamegithub.com
None4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc
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
release9983dd5da06943f833c971dd5b6bc988e2858be5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/46135#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F46135
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%2F46135
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/46135
Reloadhttps://github.com/microsoft/TypeScript/issues/46135
Reloadhttps://github.com/microsoft/TypeScript/issues/46135
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests308 (308)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/46135
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/46135
#63931https://github.com/microsoft/TypeScript/pull/63931
Ambient Module Declarations for Import Attributes (formerly known as Import Assertions)https://github.com/microsoft/TypeScript/issues/46135#top
#63931https://github.com/microsoft/TypeScript/pull/63931
https://github.com/gabritto
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com/haoqunjiang
Haoqun Jiang (haoqunjiang)https://github.com/haoqunjiang
on Sep 29, 2021https://github.com/microsoft/TypeScript/issues/46135#issue-1011000366
TypeScript's Design Goalshttps://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
#40694 (comment)https://github.com/microsoft/TypeScript/issues/40694#issuecomment-918343758
the native CSS moduleshttps://css-tricks.com/css-modules-the-native-ones/
https://github.com/vitejs/vite/blob/b690810f555549e9eed4b03600b27fe7649d6b07/packages/vite/client.d.tshttps://github.com/vitejs/vite/blob/b690810f555549e9eed4b03600b27fe7649d6b07/packages/vite/client.d.ts
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
on Sep 30, 2021https://github.com/microsoft/TypeScript/issues/46135#event-5385304763
https://github.com/justinfagnani
Justin Fagnani (justinfagnani)https://github.com/justinfagnani
on Sep 30, 2021https://github.com/microsoft/TypeScript/issues/46135#issuecomment-931553781
sodateahttps://github.com/sodatea
https://github.com/NuckChorris
Peter Lejeck (NuckChorris)https://github.com/NuckChorris
on Nov 9, 2021https://github.com/microsoft/TypeScript/issues/46135#issuecomment-963823238
imagetoolshttps://github.com/JonasKruckenberg/imagetools
https://github.com/jakearchibald
Jake Archibald (jakearchibald)https://github.com/jakearchibald
on Nov 22, 2023https://github.com/microsoft/TypeScript/issues/46135#issuecomment-1822522888
#56359https://github.com/microsoft/TypeScript/issues/56359
#56359https://github.com/microsoft/TypeScript/issues/56359
https://github.com/justinfagnani
Justin Fagnani (justinfagnani)https://github.com/justinfagnani
on Nov 22, 2023https://github.com/microsoft/TypeScript/issues/46135#issuecomment-1823070280
https://github.com/jakearchibald
Jake Archibald (jakearchibald)https://github.com/jakearchibald
on Nov 22, 2023https://github.com/microsoft/TypeScript/issues/46135#issuecomment-1823446426
https://github.com/fatcerberus
Bruce Pascoe (fatcerberus)https://github.com/fatcerberus
on Nov 23, 2023https://github.com/microsoft/TypeScript/issues/46135#issuecomment-1823896996
https://github.com/justinfagnani
Justin Fagnani (justinfagnani)https://github.com/justinfagnani
on Aug 26, 2024https://github.com/microsoft/TypeScript/issues/46135#issuecomment-2310885452
#56359https://github.com/microsoft/TypeScript/issues/56359
Add --allowArbitraryExtensions, a flag for allowing arbitrary extensions on import paths #51435https://github.com/microsoft/TypeScript/pull/51435
Haoqun Jiang (haoqunjiang)https://github.com/haoqunjiang
on Sep 2, 2024https://github.com/microsoft/TypeScript/issues/46135#event-14097022065
Aaron Gable (aarongable)https://github.com/aarongable
on Dec 11, 2024https://github.com/microsoft/TypeScript/issues/46135#event-15624590724
Remove @ts-ignore:next-line when using CSS import attribute.https://github.com/chromium/chromium/commit/cbba0aad224ab056d88be2b0e7c2d645bdb79b6e
@ts-ignorehttps://github.com/ts-ignore
cbba0aahttps://github.com/chromium/chromium/commit/cbba0aad224ab056d88be2b0e7c2d645bdb79b6e
https://github.com/fregante
fregantehttps://github.com/fregante
on Feb 21, 2025https://github.com/microsoft/TypeScript/issues/46135#issuecomment-2673417276
import attribute-based loadershttps://webpack.js.org/configuration/module/#ruleassert
Paul Irish (paulirish)https://github.com/paulirish
on Jun 1, 2025https://github.com/microsoft/TypeScript/issues/46135#event-17917639531
well that was fun. but its not gonna work.https://github.com/paulirish/devtools-frontend/commit/2e821cf347b5b67b1ac934182ca5262f21c4b835
2e821cfhttps://github.com/paulirish/devtools-frontend/commit/2e821cf347b5b67b1ac934182ca5262f21c4b835
https://github.com/ezzatron
Erin (ezzatron)https://github.com/ezzatron
on Jul 10, 2025https://github.com/microsoft/TypeScript/issues/46135#issuecomment-3056772234
import attribute-based loadershttps://webpack.js.org/configuration/module/#ruleassert
https://webpack.js.org/configuration/module/#rulewithhttps://webpack.js.org/configuration/module/#rulewith
https://github.com/alii
Alistair Smith (alii)https://github.com/alii
on Aug 18, 2025https://github.com/microsoft/TypeScript/issues/46135#issuecomment-3198734819
import byteshttps://github.com/tc39/proposal-import-bytes
https://github.com/AFatNiBBa
Sean Alunni (AFatNiBBa)https://github.com/AFatNiBBa
on Sep 12, 2025https://github.com/microsoft/TypeScript/issues/46135#issuecomment-3284241553
https://github.com/otomad
otomadhttps://github.com/otomad
on Dec 26, 2025https://github.com/microsoft/TypeScript/issues/46135#issuecomment-3692946297
https://github.com/justinfagnani
Justin Fagnani (justinfagnani)https://github.com/justinfagnani
on Jan 13, 2026https://github.com/microsoft/TypeScript/issues/46135#issuecomment-3745345018
https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/147#javascripthttps://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/147#javascript
https://github.com/jonathantneal
Jonathan Neal (jonathantneal)https://github.com/jonathantneal
on Jan 22, 2026https://github.com/microsoft/TypeScript/issues/46135#issuecomment-3784607037
#63036https://github.com/microsoft/TypeScript/pull/63036
Gabriela Araujo Britto (gabritto)https://github.com/gabritto
on Jul 31, 2026https://github.com/microsoft/TypeScript/issues/46135#event-28792589772
https://github.com/tomaswrobel
Tomáš Wróbel (tomaswrobel)https://github.com/tomaswrobel
on Aug 31, 2026https://github.com/microsoft/TypeScript/issues/46135#issuecomment-5479995982
Gabriela Araujo Britto (gabritto)https://github.com/gabritto
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#63931https://github.com/microsoft/TypeScript/pull/63931
on Sep 1, 2026https://github.com/microsoft/TypeScript/issues/46135#event-30312888604
https://github.com/jonathantneal
Jonathan Neal (jonathantneal)https://github.com/jonathantneal
on Sep 1, 2026https://github.com/microsoft/TypeScript/issues/46135#issuecomment-5498379097
Gabriela Araujo Britto (@gabritto)https://github.com/gabritto
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Sep 1, 2026https://github.com/microsoft/TypeScript/issues/46135#issuecomment-5498844938
https://github.com/krutoo
Dmitriy Petrov (krutoo)https://github.com/krutoo
on Sep 27, 2026https://github.com/microsoft/TypeScript/issues/46135#issuecomment-5855347964
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/46135
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/46135
Gabriela Araujo Britto (gabritto)https://github.com/gabritto
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
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.