Skip to content

Support source phase imports #61216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
6 tasks done
dsherret opened this issue Feb 18, 2025 · 2 comments
Open
6 tasks done

Support source phase imports #61216

dsherret opened this issue Feb 18, 2025 · 2 comments
Labels
Committed The team has roadmapped this issue Help Wanted You can do this Suggestion An idea for TypeScript

Comments

@dsherret
Copy link
Contributor

dsherret commented Feb 18, 2025

๐Ÿ” Search Terms

import source wasm

โœ… Viability Checklist

โญ Suggestion

Support for source phase imports: https://github.com/tc39/proposal-source-phase-imports

๐Ÿ“ƒ Motivating Example

// wasmModule is WebAssembly.Module
import source wasmModule from "./math.wasm"

๐Ÿ’ป Use Cases

  1. Getting a wasm module instead of instance.
@nicolo-ribaudo
Copy link

If anybody is going to work on a PR for this, it might be worth doing it on top of #60757 to avoid a ton of conflicts in the parsing logic.

@Jamesernator
Copy link

Jamesernator commented Feb 26, 2025

It would be good to make abstract module sources generic, especially for when sources support JS sources.

e.g.:

// mod.ts

export const name = "foo";

export function bar(): number { ... }
// mod has type ModuleSource<{ name: string, bar: () => number }>
import source modSource from "./mod.js";

// ... sometime later ...
const m = await import(modSource);

m.name; // has type string
m.bar; // has type () => number

For JS/TS/JSON the type of the module should already be available as it is today, ideally this would work with WASM as well but TS would need to parse wasm modules to find their types, alternatively we could have class WebAssembly.Module extends AbstractModuleSource<WebAssembly.Exports> if avoiding WASM parsing is really preferred.

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Committed The team has roadmapped this issue labels Mar 19, 2025
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.9.0 milestone Mar 19, 2025
@RyanCavanaugh RyanCavanaugh added the Help Wanted You can do this label Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Committed The team has roadmapped this issue Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants