We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
TypeScript Version: 2.5.2
Code
function f<T, K extends keyof T>(t: T, k: K): Partial<T[K]> { return t[k]; }
Expected behavior: No error. In my understanding, X should always be assignable to Partial<X>.
X
Partial<X>
Actual behavior:
TS2322: Type 'T[K]' is not assignable to type 'Partial<T[K]>'. Type 'T[string]' is not assignable to type 'Partial<T[K]>'.
The text was updated successfully, but these errors were encountered:
If I break down the above code into two separate functions, there's no error. Therefore I think this must be a bug.
function f<T, K extends keyof T>(t: T, k: K): Partial<T[K]> { return g(h(t, k)); } function h<T, K extends keyof T>(t: T, k: K): T[K] { return t[k]; } function g<T>(t: T): Partial<T> { return t; }
Sorry, something went wrong.
This may be related to #18156.
Partial<T>
ahejlsberg
No branches or pull requests
TypeScript Version: 2.5.2
Code
Expected behavior:
No error. In my understanding,
X
should always be assignable toPartial<X>
.Actual behavior:
The text was updated successfully, but these errors were encountered: