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
declarefunctionfoo(p: string): void;functionfn<Textendsstring|undefined,Uextendsstring>(one: T,two: U){letthree=Boolean() ? one : two;foo(one!);foo(two!);foo(three!);// error on this line}
Expected behavior:
No type error.
Actual behavior:
Argument of type 'string | String' is not assignable to parameter of type 'string'.
Type 'String' is not assignable to type 'string'.
'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible.
This is caused by #20995. To be fair, without that change the above was not valid at all.
getApparentTypeForLocation (which is how we enabled this, similarly to how we've made guards on this.foo.bar work when this.foo is an indexed access type) uses getAparrentType. That replaces primitives with their corresponding interfaces; I don't think we (ever) actually want do do that here (it just didn't matter when it was only ever used for the left hand side of a property access), so it's probably appropriate to factor out the constraint-mapping behaviors and perform only that here.
TypeScript Version: 2.7.0-dev.20180123
Search Terms:
Code
Expected behavior:
No type error.
Actual behavior:
This is caused by #20995. To be fair, without that change the above was not valid at all.
Playground Link:
Related Issues:
Maybe related to #21317
The text was updated successfully, but these errors were encountered: