Skip to content

Can't get iterator from iterable object #1163

@ikokostya

Description

@ikokostya

When I try to get iterator from iterable object using Symbol.iterator

/* @flow */

'use strict';

const a = [1, 2, 3];
for (const value of a[Symbol.iterator]()) {
    console.log(value);
}

flow check produces error:

test.js:6
  6: for (const value of a[Symbol.iterator]()) {
                         ^^^^^^^^^^^^^^^^^^ access of computed property/element. Element cannot be accessed with
  6: for (const value of a[Symbol.iterator]()) {
                           ^^^^^^^^^^^^^^^ string

I have the same problem with Iterable interface:

/* @flow */

'use strict';

const iterable: Iterable<number> = [1, 2, 3];
const iter = iterable[Symbol.iterator];
$ flow check
test.js:6
  6: const iter = iterable[Symbol.iterator];
                  ^^^^^^^^^^^^^^^^^^^^^^^^^ access of computed property/element. Indexable signature not found in
  6: const iter = iterable[Symbol.iterator];
                  ^^^^^^^^ $Iterable
$ flow version
Flow, a static type checker for JavaScript, version 0.19.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions