You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
falsandtru
changed the title
Indexed access breaks with object type (regression)
Conditional types wrongly work with Indexed access and object type (regression)
May 1, 2018
falsandtru
changed the title
Conditional types wrongly work with Indexed access and object type (regression)
Conditional types wrongly work with indexed access and object type (regression)
May 1, 2018
The immediate cause of this is #23768. However, it just exposes indexed access types to an issue that already exists with regular type parameters:
functionfoo<T,U>(x: T){leta: object=x;// Error as expectedletb: U|object=x;// No error!}
The problem is caused by some logic in structuredTypeRelatedTo that specifically excludes checking the default {} constraint of an unconstrained type parameter against a target type of object. However, that logic doesn't kick in when the target is a union type that includes object.
Instead of attempting to exclude cases, when the source is an unconstrained type variable I think we need to check if the target is an empty object type or a union containing an empty object type.
cc @ahejlsberg
TypeScript Version: 2.9.0-dev.20180501
Search Terms:
Code
Expected behavior:
Actual behavior:
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered: