Skip to content

bug(genType): @genType @as("0") generates type 0 not "0" #6486

Closed
@iamchanii

Description

@iamchanii

Thank you for filing! Check list:

  • Is it a bug? Usage questions should often be asked in the forum instead.
  • Concise, focused, friendly issue title & description.
  • A minimal, reproducible example.
  • OS and browser versions, if relevant.
  • Is it already fixed in master? Instructions

Hi there! I'm try to using variant interop with ReScript v11-rc.5. here is some snippet from my codes:

@genType
type tabIndex = | @as("0") Activity | @as("1") UserKeyword

And generated js code is fine as hopefully as what I expected

  var match$1 = searchParams.get("tabIndex");
  var tabIndex;
  if (match$1 == null) {
    tabIndex = undefined;
  } else {
    switch (match$1) {
      case "0" :
          tabIndex = "0";
          break;
      case "1" :
          tabIndex = "1";
          break;
      default:
        tabIndex = undefined;
    }
  }

I expect above code should be generate "0" | "1" as string union type, but actually I got 0 | 1 as numeric union type.

export type tabIndex = 0 | 1;

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