Skip to content

for-of does not work with DOM collections when target is ES3 or ES5 #2696

Closed
@Arnavion

Description

@Arnavion
var paragraphs = document.querySelectorAll("p");
for (let p of paragraphs) {
    console.log(p);
}
foo.ts(2,15): error TS2495: Type 'NodeList' is not an array type or a string type.

Is it because the standard emit will have the wrong behavior for live lists that are modified during iteration? A [].slice.call() in the emit would fix that, but perhaps that detracts from wanting to keep the output as close to the original as possible...

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions