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

Type inference is incorrect with readonly[] #287

Open
evantrimboli opened this issue Aug 10, 2022 · 0 comments
Open

Type inference is incorrect with readonly[] #287

evantrimboli opened this issue Aug 10, 2022 · 0 comments
Labels

Comments

@evantrimboli
Copy link

Describe the bug
In some cases, using the readonly modifier on an array causes type inference to break when using updateGroup in a nested fashion.

To Reproduce
Steps to reproduce the behavior:

Consider the following piece of code:

interface Item {
  readonly x: number;
  readonly y: number;
}

interface T1 {
  readonly whatever: {
    readonly keys: Item[];
  };
}

const v1 = updateGroup<T1>({
  whatever: updateGroup({
    keys: updateArray(
      updateGroup<Item>({
        x: validate(required)
      })
    )
  })
});

interface T2 {
  readonly whatever: {
    readonly keys: readonly Item[];
  };
}

const v2 = updateGroup<T2>({
  whatever: updateGroup({
    keys: updateArray(
      updateGroup<Item>({
        x: validate(required)
      })
    )
  })
});

Expected behavior
Both v1 and v2 should be able to resolve their types.

Screenshots
N/A

Library version:
7.0.0

Additional context
It seems like there's a problem with the type inference somewhere down the line. I had a look through the core to see where it's inferring the type but I wasn't able to find the particular spot. If I could be pointed in the right direction I'd be happy to look into it.

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

No branches or pull requests

1 participant