-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Implement Import Assertions (stage 3) #40694
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
One thing that would be great to include in the design here is a way for assertions to inform the module interface, similar to wildcard module declarations. For instance, with CSS modules, you might match on the declare module '*.css' {
const stylesheet: CSSStyleSheet;
export default stylesheet;
} but with CSS modules and import assertions, we'd want to match on the declare module '*' assert {type: 'css'} {
const stylesheet: CSSStyleSheet;
export default stylesheet;
} And then include this declaration with the DOM typings when CSS modules are standardized. |
If you have comments about the design, much better to bring them up with TC39 in the proposal: https://github.com/tc39/proposal-import-assertions. This really isn't the forum to debate ECMAScript syntax semantics. |
@kitsonk Please note I'm only talking about TypeScript syntax here. I'm well aware of the proposal and TC39's process. |
For the short term, we will likely parse (but not enforce) import assertions. As far as whether/how that syntax should be applied to ambient module declarations, that's something the team will need to discuss in a future design meeting. |
https://github.com/tc39/proposal-json-modules is stage 3 too. |
Nope. |
An update here: import assertions and JSON modules have shipped in Chrome and Edge 91. CSS Modules are up next. |
I’m working on a Rollup plugin for this feature (afterwards will move in to Webpack), but each file that uses the |
Sadly 4.4 has already released. We cannot add new syntax features after beta. |
@Kingwl any chance for 4.5? Another update: Chrome and Edge are shipping CSS module scripts in 93. You can try it in beta now. |
As with 4.2, 4.3 and 4.4. No. |
It's in the 4.5 iteration plan, though. 😕 I'm just curious, what is the reason it won't be considered for 4.5? |
Oh, sorry. I misread chance as change. |
@Kingwl @rbuckton since #40698 is closing this issue, should we open another for ambient module definitions? It think adding asserts to Ideally this would be in the DOM lib: declare module '*' assert {type: 'css'} {
const stylesheet: CSSStyleSheet;
export default stylesheet;
} With something similar in the built-in lib for |
FYI I opened a follow-up issue at #46135 |
Search Terms
esnext, import-assertions
Suggestion
https://github.com/tc39/proposal-import-assertions
Use Cases
Examples
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: