-
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
Regression: Argument of type ... is not assignable to parameter of type ... #29505
Comments
EDIT: Also, I would recommend changing the issue name for visibility. Something like: Conditional type is deferred when check and extend types are identical and instantiable. I think this is a bug, but I'm not 100%. This will probably need @weswigham or @ahejlsberg to answer definitively. I think this is a bug because wrapping the conditional type in a 1-tuple fixes the error, but it shouldn't really make a difference because the conditional type was never distributive in the first place. This works: export type FilterPropsByType<T, TT> = {
[K in keyof T]: [T[K]] extends [TT] ? K : never
}[keyof T]; Specifically, the code is skipping past this check because both the check and extends type are instantiable. // We attempt to resolve the conditional type only when the check and extends types are non-generic
if (!checkTypeInstantiable && !maybeTypeOfKind(inferredExtendsType, TypeFlags.Instantiable | TypeFlags.GenericMappedType)) {
if (inferredExtendsType.flags & TypeFlags.AnyOrUnknown) {
return instantiateType(root.trueType, mapper);
} and then dropping down into deferral: // Return a deferred type for a check that is neither definitely true nor definitely false
const erasedCheckType = getActualTypeVariable(checkType);
const result = <ConditionalType>createType(TypeFlags.Conditional); Checking for identity before deferral does fix the issue, but I'm not sure it's the right thing to do: if (isTypeIdenticalTo(checkType, extendsType)) {
return instantiateType(root.trueType, combinedMapper || mapper);
}
// Return a deferred type for a check that is neither definitely true nor definitely false
// …. |
@weswigham tentatively tagging this as a bug because it is indeed a regression relative to 3.1 |
This bug was target for 3.5.0 milestone but it's still present in 3.5.1. I just cannot update TypeScript since 3.0.1 in my project. |
I just tested 3.6.0-dev.20190720 and the bug is still present. |
|
The linked PR is pretty wide-reaching so I'm slightly hesitant to call it a definitive fix for the issue here |
This were working without error in TypeScript 3.0.1 but is not working on 3.2.4.
The
select
function is intended to accept only property names of type string in the last argument, but in 3.2.4 it does not accept any string.It gives error:
[ts] Argument of type '"value"' is not assignable to parameter of type 'XX extends XX ? "value" : never'. [2345]
The text was updated successfully, but these errors were encountered: