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

feature request (lint): Warn user when they're trying to use for in with an array #1283

Open
xyzshantaram opened this issue Apr 30, 2024 · 1 comment

Comments

@xyzshantaram
Copy link

You are going full speed writing that new piece of code you want. You need to iterate over an array, but suddenly TS complains saying you've got the wrong type for your array member.

image

You spend fifteen minutes puzzling it out, before you message the team. There can't be anything wrong with your code, it's 3 lines! Is this a bug in TypeScript?

A coworker points it out. You have just been bit by an ancient failing of JavaScript: for ... in instead of for ... of.


I just ran into this scenario and I was thinking it would be awesome if the linter could warn you of this. It's already in typescript-eslint (no-for-in-array), but since Deno is all about DX and it's not very DX-friendly to have to set up a second linter outside your LSP, I thought I would ask.

Basically, deno lint could display an error like "Use of for ... in to iterate over an array, did you mean for ... of?" I don't know how difficult it would be to implement, but it would definitely be nice to have.

Thanks in advance!

@petamoriken
Copy link
Contributor

petamoriken commented May 1, 2024

Unfortunately, deno_lint cannot handle TypeScript types at the moment #556

@lucacasonato lucacasonato transferred this issue from denoland/deno Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants