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

Renaming tags doesn't propagate to Action.match keys #13

Open
OliverJAsh opened this issue Nov 26, 2017 · 2 comments
Open

Renaming tags doesn't propagate to Action.match keys #13

OliverJAsh opened this issue Nov 26, 2017 · 2 comments

Comments

@OliverJAsh
Copy link
Collaborator

I think this can be boiled down to a TypeScript issue. In the following example, foo is not renamed within match, but it should be:

{
  type MyActions = { foo: {}; bar: {} };
  type Cases = Record<keyof MyActions, {}>;
  const match = (cases: Cases) => {}

  match({
    foo: 1,
    bar: 2,
  })
}

If Record is replaced with mapped types, renaming does work:

{
  type MyActions = { foo: {}; bar: {} };
  type Cases = { [key in keyof MyActions]: {} };
  const match = (cases: Cases) => {}

  match({
    foo: 1,
    bar: 2,
  })
}

I opened an issue on TypeScript to track this microsoft/TypeScript#20272.

Filing here in case other people find the same problem when using unionize!

(And thanks for the fantastic library.)

@OliverJAsh
Copy link
Collaborator Author

This no longer appears to be an issue. Did we stop using Record in place of mapped types somewhere along the line?

@pelotom
Copy link
Owner

pelotom commented Jul 4, 2018

Nothing has changed in the basic approach, my guess is the TS language service just got a little smarter at some point 🙂

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