Skip to content

feat(WebAssembly): Make WebAssembly.Global generic - #963

Merged
Nathan Shively-Sanders (sandersn) merged 4 commits into
microsoft:mainfrom
ExE-Boss:types/wasm/generic-global
Apr 24, 2023
Merged

feat(WebAssembly): Make WebAssembly.Global generic#963
Nathan Shively-Sanders (sandersn) merged 4 commits into
microsoft:mainfrom
ExE-Boss:types/wasm/generic-global

Conversation

@ExE-Boss

@ExE-Boss ExE Boss (ExE-Boss) commented Dec 12, 2020

Copy link
Copy Markdown
Contributor

This makes WebAssembly.Global generic to better match the runtime behaviour:


Q: Should I change this to use something more like:

declare namespace WebAssembly {
	class Global<T extends ValueType = ValueType> {
		constructor(descriptor: GlobalDescriptor<T>, v?: ValueTypeMap[T]);
		value: ValueTypeMap[T];
		valueOf(): ValueTypeMap[T];
	}

	type ValueType = keyof ValueTypeMap;
	interface ValueTypeMap {
		i32: number;
		i64: bigint;
		f32: number;
		f64: number;
	}
}

Comment thread baselines/dom.generated.d.ts Outdated
Comment thread inputfiles/addedTypes.json Outdated
@sandersn

Copy link
Copy Markdown
Member

The types look like an improvement to me. Kagami Sascha Rosylight (@saschanaz) would it be better to fix this upstream somewhere instead of overriding it here? If not I think this would be appropriate here.

@saschanaz

Copy link
Copy Markdown
Contributor

The IDL syntax does not support this kind of generics, so I think we need to override them. Looks good to me, feel free to merge 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants