-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Unconstrained generics are incorrectly assignable to _any_ "Partial" type #30634
Comments
Not a regression |
As I said in the OP, the change that introduced the bug was #26517 from what I can tell, so we've had it long enough that we have people unintentionally relying on it. export type Shared<
InjectedProps,
DecorationTargetProps extends Shared<InjectedProps, DecorationTargetProps>
> = {
[P in Extract<keyof InjectedProps, keyof DecorationTargetProps>]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never;
}; only actually typechecks in most cases because |
… to sucessfully typecheck, this fixes that
… to sucessfully typecheck, this fixes that (#34335)
Fixing microsoft/TypeScript#30634 will make this constraint fail to check for most users - this type seems to have been copied from (to?) `react-redux`, which has taken in a similar change on DT: DefinitelyTyped/DefinitelyTyped#34335 DefinitelyTyped/DefinitelyTyped#34339
Fixing microsoft/TypeScript#30634 will make this constraint fail to check for most users - this type seems to have been copied from (to?) `react-redux`, which has taken in a similar change on DT: DefinitelyTyped/DefinitelyTyped#34335 DefinitelyTyped/DefinitelyTyped#34339
… to sucessfully typecheck, this fixes that (DefinitelyTyped#34335)
Fixing microsoft/TypeScript#30634 will make this constraint fail to check for most users - this type seems to have been copied from (to?) `react-redux`, which has taken in a similar change on DT: DefinitelyTyped/DefinitelyTyped#34335 DefinitelyTyped/DefinitelyTyped#34339
This one was fixed in #49119, explicitly via the first bullet in the PR description:
But, could probably use an explicit test. |
TypeScript Version: 3.4.0-dev.201xxxxx
Code
Expected behavior:
An error on
x = y
.Actual behavior:
No error.
Playground Link
The root cause is this relationship in
structuredTypeRelatedTo
added way back in this:This is unsound when
source
is the empty type resulting from the constraint of an unconstrained generic type (which, if changed tounknown
, catches this issue!). It's unsound when it comes from a constraint at all, actually. Fixing this will breakreact-redux
, whose recursiveShared
type (which we have in our test suite) actually only checks because of this unsoundness.The text was updated successfully, but these errors were encountered: