-
Notifications
You must be signed in to change notification settings - Fork 12.8k
T[K] is not assignable to NonNullable<T>[K] even when T is nonnull (regression) #27456
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
Comments
I'm not sure there is a regression here. The following is an error with 3.0 as well: // Compile with --strictNullChecks
function foo<T, K extends keyof T>(x: T[K], y: NonNullable<T>[K]) {
x = y;
y = x; // Error
} I think the error is reasonable. After all, |
Compiling passed probably since 2018-3-5. https://github.com/falsandtru/clientchannel/blob/0611018e8b840abbcd7a9d49f08c9dc12daa847b/src/layer/domain/indexeddb/service/channel.ts Generally, subtype isn't replaceable by base type. But if T is originally nonnull, T and NonNullable<T> are the same type (base type is replaceable by subtype in this case). And if T is nullable, property access should be error. What do you think? |
@ahejlsberg Can you take a look at the requested info? |
TypeScript Version: 3.2.0-dev.20180929
Search Terms:
Code
Revert the change of source code to see the error: falsandtru/clientchannel@14cc53a
Expected behavior:
pass
Actual behavior:
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered: