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
{{ message }}
Repository navigation
Type inference problem with generics and Readonly #26600
The compiler complains about the return this.doSthWithX(localX || false); line. It says:
Argument of type 'PT["x"]' is not assignable to parameter of type 'boolean'.
Type 'boolean | undefined' is not assignable to type 'boolean'.
Type 'undefined' is not assignable to type 'boolean'.
Adding the explicit type for localX solves the problem.
We'd need #22348 or something similar to correctly typecheck this -- it requires the checker understanding that all of the truthy values of the mapped type's x property are boolean, which is not immediately apparent.
Activity
RyanCavanaugh commentedon Oct 10, 2018
Requires strictNullChecks on; not a regression
RyanCavanaugh commentedon Oct 10, 2018
We'd need #22348 or something similar to correctly typecheck this -- it requires the checker understanding that all of the truthy values of the mapped type's
xproperty areboolean, which is not immediately apparent.