Closed
Description
Bug Report
Default iterator TReturn
type is any
. This causes code which works with iterators without a defined TReturn
type to return any
when getting next().value
.
const set1 = new Set<string>();
// Should be `string | undefined` but is `any`
const e1 = set1.values().next().value;
// ^?
🔎 Search Terms
iterator, set, treturn, next any
🕗 Version & Regression Information
- This is the behavior in every version I tried. Seems like it was introduced in Improve type checking and inference for Generators and Async Generators #30790
⏯ Playground Link
Playground link with relevant code
💻 Code
const set1 = new Set<string>();
// Should be `string | undefined` but is `any`
const e1 = set1.values().next().value;
// ^?
🙁 Actual behavior
e1
should be string | undefined
🙂 Expected behavior
e1
is any
Metadata
Metadata
Assignees
Labels
No labels