Skip to content

Type generation generates invalid types for inline functions accepting results #627

Open
@mschuwalow

Description

@mschuwalow

The following wit

package example:example;

world component {
  export foo: func(res: result<string, string>);
}

Produces the following types when used to generate guest-types (though the problem also applies to host types)

declare module 'example:example/component' {
  export function foo(res: Result<string, string>): void;
}

The problem here is that there is no definition for the Result type.


When doing the same with an interface

package example:example;

interface foo {
  foo: func(res: result<string, string>);
}

world component {
  export foo;
}

The generated types are valid and include an inline definition of result

declare module 'example:example/foo' {
  export function foo(res: Result<string, string>): void;
  export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypeScriptTypescript code/ecosystembugSomething isn't workinggenerated-typesRelated to generated types (Typescript)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions