Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryList<> interface is not iterable in TypeScript #7022

Closed
hansl opened this issue Feb 11, 2016 · 9 comments
Closed

QueryList<> interface is not iterable in TypeScript #7022

hansl opened this issue Feb 11, 2016 · 9 comments

Comments

@hansl
Copy link
Contributor

hansl commented Feb 11, 2016

The d.ts generated does not contain the Symbol.iterator member (and does not implement the Iterable interface). That would be okay if we could use toArray() but the Dart implementation is missing that declaration.

@zoechi
Copy link
Contributor

zoechi commented Feb 12, 2016

There is a PR for forEach #6314, #6341.
I tried .map() recently and it doesn't seem to be implemented in Dart even though it can be called, but has no effect. (I'll check again later and file an issue)

@araujoigor
Copy link

Adding [Symbol.iterator](): any; manually to query_list.d.ts would do the trick temporally.

@juanmaflyer
Copy link

In 2.0.0 QueryList still isn't an Iterable. Here is a demo:

http://plnkr.co/edit/oeTcVe0jrtDjalN3nJdz?p=preview

Moreover, the docs are confunsing because it says "Implements an iterable interface, therefore it can be used in both ES6 javascript for (var i of items) loops as well as in Angular templates with *ngFor="let i of myList".

https://angular.io/docs/js/latest/api/core/index/QueryList-class.html

@zoechi
Copy link
Contributor

zoechi commented Sep 16, 2016

toArray() can now be used. Dart is not a dependency anymore.

@vicb vicb self-assigned this Sep 16, 2016
@vicb
Copy link
Contributor

vicb commented Sep 16, 2016

@juanmaflyer it actually seems like a bug in TS. Investigating.

@vicb
Copy link
Contributor

vicb commented Sep 17, 2016

@juanmaflyer TS assumes the object is either a string or an array when using for..of and the target is < ES2015.

@vicb vicb closed this as completed Sep 17, 2016
@hansl
Copy link
Contributor Author

hansl commented Sep 18, 2016

@vicb: did you file a bug with typescript? I don't see it.

@mafredri
Copy link

mafredri commented Jun 6, 2017

Is there anything blocking this now that TypeScript supports the downlevelIteration option (microsoft/TypeScript#3164 (comment))?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants