Skip to content

Iterator in for ... of loop transpiled to use length property which is undefined #12484

Closed
@jasonpang

Description

@jasonpang

TypeScript Version: nightly (2.2.0-dev.20161118)

Chrome Version: Stable 54.0.2840.99 (Official Build) m (64-bit) (Revision 7eca4ce1e662f12cadaf96c30cd2335fd03e7140-refs/branch-heads/2840@{#830})

TypeScript Code: (relevant portion)

for (var param of iterator) {

Transpiled ES5 JavaScript (relevant portion):

 for (... ; _i < iterator_1.length; _i++) {
                 ^^^^^^^^^^^^^^^^^
                 length is undefined

Screenshot of Transpiled ES5 Code:

image

Expected behavior:
Using for (var x of iterator) { ... } should be transpiled correctly.

Actual behavior:
The iterator loop is transpiled to use the length property which appears to be undefined for the iterator.

Reproducible Project

For some reason, GitHub isn't allowing me to upload a .zip file, so here's a Google Drive link to the project ZIP: https://goo.gl/xvbwHu.

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