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

rescript@11-rc4: gentype output does not respect @tag for tagged variants #6436

Closed
ybybzj opened this issue Oct 12, 2023 · 3 comments
Closed

Comments

@ybybzj
Copy link

ybybzj commented Oct 12, 2023

in case that:

// Lib.resi
@gentype
@tag("action")
type action =
  | @as("insert") Insert({data: string})
  | @as("retain") Retain({data: string})
  | @as("remove") Remove({data: string})

the generated .ts by gentype are:

// Lib.gen.ts
export type action = 
    { TAG: "insert"; readonly data: string }
  | { TAG: "retain"; readonly data: string }
  | { TAG: "remove"; readonly data: string };

the discriminator property name is still TAG not action

@cristianoc
Copy link
Collaborator

Good test for semantic search "gentype emit js variant tag"

Screenshot 2023-10-12 at 02 18 38 Screenshot 2023-10-12 at 02 18 57 Screenshot 2023-10-12 at 02 19 17

@ybybzj
Copy link
Author

ybybzj commented Oct 12, 2023

Lib.resi
image
Lib.res
image
Lib.bs.js
image
Lib.gen.ts
image

gentypeconfig in bsconfig.json

"gentypeconfig": {
    "language": "typescript",
    "generatedFileExtension": ".gen.ts",
    "module": "es6",
  }

Sorry that I still cannot figure out where I did wrong.

cristianoc added a commit that referenced this issue Oct 12, 2023
@cristianoc
Copy link
Collaborator

Here: #6437

@zth zth closed this as completed in da3d740 Oct 12, 2023
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

No branches or pull requests

2 participants