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

Improve assignability to target conditional types types that distribute with any/unknown extendsType #60817

Conversation

Andarist
Copy link
Contributor

fixes #60815

@@ -19321,7 +19321,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}

function isDistributionDependent(root: ConditionalRoot) {
return root.isDistributive && (
return root.isDistributive && !(root.extendsType.flags & TypeFlags.AnyOrUnknown) && (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't correct as it removes those correct errors:

function f5<T>(t1: { x: T; y: T }, t2: T extends any ? { x: T; y: T } : never) {
  t1 = t2; // OK
  t2 = t1; // should fail
}

function f6<T>(t1: { x: T; y: T }, t2: T extends unknown ? { x: T; y: T } : never) {
  t1 = t2; // OK
  t2 = t1; // should fail
}

@Andarist Andarist closed this Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

How is assignability b/w two uninstantiated generics checked?
2 participants