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
Search Terms: conditional type not assignable, conditional branch assignable, default parameter assignable
(there are so many issues related to conditional types it's hard to tell which title may be related)
Note: This could be two separate bugs.
Example 1: The default parameter should be inferred to false, not boolean, like it is in const x = false, so if anything the error message should be Type 'false' is not assignable to [...]. It also does not seem to help to default to [...] = (false as false) or [...] = (false as const)
Example 2: Even with [...] ? boolean : boolean TS incorrectly does not allow to default to a boolean or false.
Actual behavior:
Example 1:
Type 'boolean' is not assignable to type 'Y extends string ? boolean : false'.(2322)
Example 2:
Type 'boolean' is not assignable to type 'Param<T>'.(2322)
Cool, looks like #26933 which that PR aims to fix (among other issues) is sufficiently similar to assume that this issue will be fixed by that as well. Closing as duplicate 👍
TypeScript Version: Nightly playground 2020-07-09
Search Terms: conditional type not assignable, conditional branch assignable, default parameter assignable
(there are so many issues related to conditional types it's hard to tell which title may be related)
Code
Close to my use case:
As minimal as I can get it, probably still the same cause:
Expected behavior:
No type error (other than unused parameters).
Note: This could be two separate bugs.
Example 1: The default parameter should be inferred to
false
, notboolean
, like it is inconst x = false
, so if anything the error message should beType 'false' is not assignable to [...]
. It also does not seem to help to default to[...] = (false as false)
or[...] = (false as const)
Example 2: Even with
[...] ? boolean : boolean
TS incorrectly does not allow to default to aboolean
orfalse
.Actual behavior:
Example 1:
Example 2:
Playground Link:
Example 1:
Playground Link
Example 2:
Playground Link
Related Issues:
The text was updated successfully, but these errors were encountered: