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

Convert for-of to forEach availability #704

Open
j4k0xb opened this issue Sep 7, 2022 · 0 comments
Open

Convert for-of to forEach availability #704

j4k0xb opened this issue Sep 7, 2022 · 0 comments
Labels
💪 Improvement Refactoring doesn't run on a specific case or result could be optimized

Comments

@j4k0xb
Copy link
Contributor

j4k0xb commented Sep 7, 2022

Describe what's missing

Convert to forEach isn't available for many types of for-of loops.

How would it work

Allow any kind of expression instead of https://github.com/nicoespeon/abracadabra/blob/main/src/refactorings/convert-for-to-for-each/convert-for-to-for-each.ts#L113-L119
Edit: special case for string and map (if the type can be inferred)

Expected behavior

Example cases where it currently doesn't work, but should:

for (const item of items) { } // items isn't declared (or vscode doesn't know about it)

const getItems = () => ['foo', 'bar', 'baz'];
for (const item of getItems()) { }

Screenshots

image

Additional information

  • Version of the extension used: v6.15.3
@j4k0xb j4k0xb added the 💪 Improvement Refactoring doesn't run on a specific case or result could be optimized label Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 Improvement Refactoring doesn't run on a specific case or result could be optimized
Projects
None yet
Development

No branches or pull requests

1 participant