Skip to content

Incorrect type for Set.prototype.values().next Iterator #53223

Closed
@vezaynk

Description

@vezaynk

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;
//    ^?

Playground

🔎 Search Terms

iterator, set, treturn, next any

🕗 Version & Regression Information

⏯ 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions