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

Immutable<T> incorrectly changes tuples to ReadonlyArray #2

Open
goblindegook opened this issue Jan 11, 2019 · 1 comment
Open

Immutable<T> incorrectly changes tuples to ReadonlyArray #2

goblindegook opened this issue Jan 11, 2019 · 1 comment
Labels
bug Something isn't working immutable

Comments

@goblindegook
Copy link
Member

goblindegook commented Jan 11, 2019

Immutable incorrectly changes tuples to ReadonlyArray. For example:

import { Immutable } from '@pacote/immutable'

type ImmutableTuple = Immutable<[number, string]>
// expected => Readonly<[number, string]>
// actual   => ReadonlyArray<number | string>

const test: ImmutableTuple = ['string', 1] // this should be failing compilation

The correct behaviour is for Immutable<[number, string]> to become Readonly<[number, string]>.

@goblindegook goblindegook added bug Something isn't working immutable labels Jan 11, 2019
@teves-castro
Copy link
Member

The way tuples are implemented in typescript, I don't believe there is a way to do this except for declaring an internal type for each of the different arity tuples explicitly and then use a union type for the exported type. Even so I don't know if at the call site the compiler can differentiate the cases correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working immutable
Projects
None yet
Development

No branches or pull requests

2 participants