Skip to content

for...of with strictNullChecks #9631

Closed
Closed
@johnfn

Description

@johnfn

I was able to dig up a lot of discussion about why myArray[i] should not be a nullable type, and that makes sense. But I wasn't able to dig up anything on for ... of loops.

How come the following:

const x = ["a", "b"]
for (const y of x) { /* ... */ } 

makes y a nullable type? All the arguments saying myArray[i] shouldn't be a nullable type also seem to apply to for ... of loops, as far as I can see.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions