-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
use typescript-eslint array-type rule #7974
Conversation
@cpojer expressed a preference for Huge +1 to consistency though, and an autofixable rule helps. |
I guess that's why they added |
Heavy preference for In Flow, we use square brackets when we mean tuples instead of Arrays, but I'm not sure if TypeScript supports it. I'm not gonna block you but I'd like to hear a good reason over why array generics are special compared to any other generic type. |
Well, JS has special syntax for initializing arrays so IMO it makes sense that there's also a special syntax for declaring their types, and it's particularly familiar because it uses the same characters |
Another point - I read |
Yeah it being autofixable is why I don't really feel the need to convince anyone 😄 |
I mean that I read it in a way that does not represent what it is - I hit the "modifier" at the end which changes the semantics of the expression instead of it reading correctly the first time through. "this take a string or a boolean, as an array". Also "string or boolean array" - is that |
Ah, got it 👍 |
38fce95
to
14963ec
Compare
Updated with |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
The TypeScript sources currently use
Array<T>
andT[]
inconsistently.This makes it harder to grep for e.g.
Array<Test>
orTest[]
because you might miss some of them that use the other syntax.It might also confuse TS beginners who wonder what the difference between the two might be.
eslint-typescript
has thearray-type
rule to enforce one syntax or the other (or alternatively[]
for simple types andArray
for complex ones).I've set it to
'array'
([]
) and run the auto fixer, but I'd be open to discussion / links to convince me why another option would be better ;)Test plan