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

Tuple type serialisation #6566

Closed
1 task done
mattcorner opened this issue Jun 8, 2023 · 6 comments · Fixed by #6616
Closed
1 task done

Tuple type serialisation #6566

mattcorner opened this issue Jun 8, 2023 · 6 comments · Fixed by #6616

Comments

@mattcorner
Copy link

What version of Remix are you using?

1.16.1

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

We often have typings that narrow down, so a top level type might define a property as string[] but a refined version of that type might narrow it down to ["Some value"]. This works fine, until Remix infers and serialises the type across the network boundary.

I've taken the Serialization code from the repository, and generated a Typescript playground showing the issue. You'll see that the tuple gets interpretted as an array and has all of its keys incorrectly defined.

Typescript playground

Expected Behavior

The serialised type to remain string[] & ["Some value"]

Actual Behavior

The seralised type becomes

{
    [x: number]: "Some value";
    length: "Some value";
    toString: null;
    toLocaleString: null;
    pop: null;
    push: null;
    concat: null;
    join: null;
    reverse: null;
    shift: null;
    slice: null;
    sort: null;
    splice: null;
    ... 20 more ...;
    0: "Some value";
}
@pcattori
Copy link
Contributor

@mattcorner could you help me understand why string[] & ["Some value"] is a useful type for you? Why not narrow down to ["Some value"]?

@pcattori
Copy link
Contributor

Here's the solution in a Typescript playground. Will land this in a PR when I get the chance.

@MichaelDeBoey
Copy link
Member

Fixed by #6616

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version v0.0.0-nightly-382edbe-20230617 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 1.18.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 1.18.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants