Typescript loses constraint of satisfies
on initial value/accumulator for Array.prototype.reduce
#52526
Labels
Duplicate
An existing issue was already created
🔎 Search Terms
🕗 Version & Regression Information
>=4.9.0
when thesatisfies
operator was introduced💻 Repo
Playground
🙁 Actual behavior
The accumulator loses some of that information from the
satisfies
constraint, especially as it pertains to arrays. Typescript incorrectly thinks theerrors
array is typenever[]
.🙂 Expected behavior
The
errors
array should have the same type as asserted with thesatisfies
operator. As you can see in the playground, you can use theas
operator, but you lose all of the benefits thatsatisfies
provides. In my head, thesatisfies
operator is the same asas
, but with actual type checking happening on the operands.The text was updated successfully, but these errors were encountered: