You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wow, import attributes do add quite a bit of complexity to module loading, don't they... I'm guessing this can of worms is what TC39 were attempting to avoid when they originally specified asserts as not affecting how a module is loaded...
Thanks @jakearchibald; could I get you to post this feedback in #46135? We discussed this recently in #56359 and weβre looking for more information about existing real-world use cases, but Iβd like to consolidate the discussion there.
π Search Terms
import attributes declare module types
β Viability Checklist
β Suggestion
With import attributes, you can now do this:
β¦where a build tool (such as Rollup) will generate the modules.
What's missing is a way to provide the types, so TypeScript sees
AnImage
as (for example) anImageBitmap
, andAnArrayBuffer
as anArrayBuffer
.One suggestion, adapted from #53656 (comment):
However, it would also be nice if declared exports could be conditional. So in
./icon.png.d.ts
:π Motivating Example
As described in the suggestion.
π» Use Cases
I think this is covered in the suggestion.
It's common for
with { type: "value" }
to influence the types of the returned module, but TypeScript doesn't allow the types to differ.Avoid using import attributes for this use-case, and instead use custom schemes in the module ID (or custom query strings).
The text was updated successfully, but these errors were encountered: