Skip to content
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

fix: invalid names in import object #30

Merged

Conversation

eduardomourar
Copy link
Contributor

@eduardomourar eduardomourar commented Feb 12, 2023

This prepares the ground for when TypeScript will have support for "Arbitrary module namespace identifier names": microsoft/TypeScript#40594. Instead, we will export an interface in replacement of a namespace.

@guybedford
Copy link
Collaborator

Thanks for the PR, with #31 merged there should no longer be update issues if you're able to rebase to the latest main.

This prepares the ground for when TypeScript will have
support for "Arbitrary module namespace
identifier names":
microsoft/TypeScript#40594
@eduardomourar eduardomourar marked this pull request as ready for review February 15, 2023 23:21
@guybedford
Copy link
Collaborator

This is still failing unfortunately -

Error: test/output/flavorful/flavorful.d.ts(8,25): error TS1005: ';' expected.
Error: test/output/flavorful/flavorful.d.ts(10,3): error TS1109: Expression expected.
Error: test/output/flavorful/flavorful.d.ts(11,1): error TS1128: Declaration or statement expected.
Error: test/output/lists/lists.d.ts(8,16): error TS1003: Identifier expected.
Error: test/output/lists/lists.d.ts(8,25): error TS1005: ';' expected.
Error: test/output/lists/lists.d.ts(10,3): error TS1109: Expression expected.
Error: test/output/lists/lists.d.ts(11,1): error TS1128: Declaration or statement expected.
Error: test/output/many_arguments/many_arguments.d.ts(7,16): error TS1003: Identifier expected.
Error: test/output/many_arguments/many_arguments.d.ts(7,25): error TS1005: ';' expected.
Error: test/output/many_arguments/many_arguments.d.ts(9,3): error TS1109: Expression expected.
Error: test/output/many_arguments/many_arguments.d.ts(10,1): error TS1128: Declaration or statement expected.
Error: test/output/numbers/numbers.d.ts(8,16): error TS1003: Identifier expected.
Error: test/output/numbers/numbers.d.ts(8,25): error TS1005: ';' expected.
Error: test/output/numbers/numbers.d.ts(10,3): error TS1109: Expression expected.
Error: test/output/numbers/numbers.d.ts(11,1): error TS1128: Declaration or statement expected.
Error: test/output/records/records.d.ts(8,16): error TS1003: Identifier expected.
Error: test/output/records/records.d.ts(8,25): error TS1005: ';' expected.
Error: test/output/records/records.d.ts(10,3): error TS1109: Expression expected.
Error: test/output/records/records.d.ts(11,1): error TS1128: Declaration or statement expected.
Error: test/output/strings/strings.d.ts(7,16): error TS1003: Identifier expected.
Error: test/output/strings/strings.d.ts(7,25): error TS1005: ';' expected.
Error: test/output/strings/strings.d.ts(9,3): error TS1109: Expression expected.
Error: test/output/strings/strings.d.ts(10,1): error TS1128: Declaration or statement expected.
Error: test/output/variants/variants.d.ts(8,16): error TS1003: Identifier expected.
Error: test/output/variants/variants.d.ts(8,25): error TS1005: ';' expected.
Error: test/output/variants/variants.d.ts(10,3): error TS1109: Expression expected.
Error: test/output/variants/variants.d.ts(11,1): error TS1128: Declaration or statement expected.

@eduardomourar
Copy link
Contributor Author

eduardomourar commented Feb 17, 2023

This is still failing unfortunately -

The TypeScript compiler might take same time to support this syntax. Should we just generate something like this, instead?

import { WasiClocks as WasiClocksImports } from './imports/wasi-clocks';
import { WasiDefaultClocks as WasiDefaultClocksImports } from './imports/wasi-default-clocks';
import { WasiStderr as WasiStderrImports } from './imports/wasi-stderr';
export interface ImportObject {
  'wasi-clocks': typeof WasiClocksImports,
  'wasi-default-clocks': typeof WasiDefaultClocksImports,
  'wasi-stderr': typeof WasiStderrImports,
}
export namespace SomeCommand {
  export function command(stdin: number, stdout: number, args: string[], envVars: [string, string][], preopens: [number, string][]): void;
}

export function instantiate(
compileCore: (path: string, imports: Record<string, any>) => Promise<WebAssembly.Module>,
imports: ImportObject,
instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => Promise<WebAssembly.Instance>
): Promise<typeof Stedi>;

@guybedford
Copy link
Collaborator

Sure, that can work.

@guybedford guybedford merged commit 4f96f97 into bytecodealliance:main Feb 17, 2023
@guybedford
Copy link
Collaborator

Thanks for your work on this!

@eduardomourar eduardomourar deleted the fix/update-wit-component branch February 17, 2023 21:46
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.

2 participants