Skip to content

type alias declared in .wit file does not generate a named type #204

@deadprogram

Description

@deadprogram

I added a type alias to one of my wit files like this:

    /// size is a 2-element integer vector.
    /// It represents a width and height.
    record size {
        x: s32,
        y: s32,
    }

    /// point is a 2-element integer vector.
    /// It represents a x and y coordinate.
    type point = size;

The generated code substituted Size everywhere that the wit file used point which was not incorrect as far as typing/compilation, but did not achieve my objective of code readability which is why I created the alias.

What I expected was some Go code like this:

type Point Size

wit-bindgen for Rust did add named alias to generated code:

      /// point is a 2-element integer vector.
      /// It represents a x and y coordinate.
      pub type Point = Size;

Likewise C

// point is a 2-element integer vector.
// It represents a x and y coordinate.
typedef wasm_cv_types_size_t wasm_cv_types_point_t;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions