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

Assignability b/w generic keyof T and KeysOfUnion<T> #1008

Open
juhort opened this issue Dec 16, 2024 · 1 comment · May be fixed by #1009
Open

Assignability b/w generic keyof T and KeysOfUnion<T> #1008

juhort opened this issue Dec 16, 2024 · 1 comment · May be fixed by #1009
Labels
enhancement New feature or request

Comments

@juhort
Copy link

juhort commented Dec 16, 2024

Ideally, keyof T should be assignable to KeysOfUnion<T> and KeysOfUnion<T> should not be assignable to keyof T.

However, currently the exactly opposite happens.

import { KeysOfUnion } from "type-fest";

// KeysOfUnion<T> should not be assignable to keyof T
type Assignability1<T, K extends keyof T> = unknown;
type Test1<T> = Assignability1<T, KeysOfUnion<T>>; // should error but doesn't

// keyof T should be assignable to KeysOfUnion<T>
type Assignability2<T, K extends KeysOfUnion<T>> = unknown;
type Test2<T> = Assignability2<T, keyof T>; // shouldn't error but does

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@juhort juhort added the enhancement New feature or request label Dec 16, 2024
@som-sm
Copy link
Contributor

som-sm commented Dec 16, 2024

That makes sense, let me give it a try!

@som-sm som-sm linked a pull request Dec 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants