Array
and IteratorObject
reduce
method type error
#60204
Labels
Duplicate
An existing issue was already created
π Search Terms
"Array IteratorObject reduce"
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?target=99&ts=5.6.3#code/GYVwdgxgLglg9mABAJwKYBMQVQHgCoA0iAygHwAUAsAFCKLABci5MYMsAhgDZPFEQhkaMFCZ4AlIgC8pEgRp1W7XvNqJ2qZGIDaAXUQAfRAEkomjlDjIA8gCMAVqmj5SqyQG8FiAPTf1wZgBBIQ4ATwA6GABnYOQwljNkcUk0KEEkDWRwtExscmAiJShxAG5EL1T09UTsjCxUfMK2YpKaAF8aGlBIWAQAKhQOMABzBo8vUJhULnREAEZWtUnp2YAmRbplmcQAZkWO6hoIBCi4LlRwrjhh8hz68nIOIltJGUQORABqRFsiAAYiHERmNkotjmBTudLtdbnU8o9nq9ZB9vr9EAAidGAoajcjJUpAA
π» Code
π Actual behavior
The type error that should not occur appears at
f
in the linereturn iter.reduce(f, init);
as follows:π Expected behavior
Both
T[]
andIteratorObject<T>
have areduce
method, and the interfaces of the two methods are identical. Therefore, the error should not occur. For example, the type error disappears if the commented line is uncommented. All that line does is distinguish whetheriter
is aT[]
or anIteratorObject<T>
. In fact, the code after this conditional branch is identical. Therefore, this error should not exist.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: