Stream: jco

Topic: plain enums are generating complex typescript


view this post on Zulip Zimon Dai (May 18 2024 at 08:07):

enum Align {
  Left,
  Center,
  Right
}

generates

export type Align = AlignLeft | AlignCenter | AlignRight;
export interface AlignLeft {
  tag: 'left',
}
export interface AlignCenter {
  tag: 'center',
}
export interface AlignRight {
  tag: 'right',
}

isn't this too complex? Can it just be export type Align = 'left' | 'center' | 'right' ?

view this post on Zulip Guy Bedford (May 19 2024 at 03:34):

This is a good question, can you post an issue to the Jco repo to discuss further? https://github.com/bytecodealliance/jco

JavaScript tooling for working with WebAssembly Components - bytecodealliance/jco

view this post on Zulip Zimon Dai (May 19 2024 at 03:41):

done https://github.com/bytecodealliance/jco/issues/438

enum Align { Left, Center, Right } generates export type Align = AlignLeft | AlignCenter | AlignRight; export interface AlignLeft { tag: 'left', } export interface AlignCenter { tag: 'center', } ex...

Last updated: Nov 22 2024 at 17:03 UTC