-
Notifications
You must be signed in to change notification settings - Fork 198
prefer-array-literal: Error when using Array in a type annotation #110
Comments
Good find! Our coding standard says to prefer the literal syntax, even when declaring the array type. We can add a parameter to the rule that will let you turn this on. Why do you prefer
instead of
The 2nd is shorter and gives your code base one single, consistent way to declare array types. If it were me, I would just follow the rule's advice. But that's a bit unfair because I wrote the rule :) |
Thanks for the response, @HamletDRC. I don't necessarily prefer the |
how can one specify the size of the array? const foo = new Array(10) |
@ogiexela You can use |
Oh that sounds like a bug in the rule... |
@JoshuaKGoldberg OK. how can I help this issue? |
That'd be great! Would you mind filing a new issue describing what you're seeing regarding being allowed to use |
@JoshuaKGoldberg Yes, I will do. I just checked which ts-lint actually does palantir/tslint#2946 (comment) I am going to test it with up-to-date version of |
@jonascarlsonschmidt Created. Thanks for guiding me. |
Perhaps this is the intended behavior, but from the description of the rule, the
prefer-array-literal
rule looks like its purpose is to disallow usingArray
when instantiating new arrays:However, this rule also disallows using
Array
as a type parameter, which is one of the recommended ways of declaring Array types in the handbook:I expected this rule to throw errors on the first set of examples above but allow the second set.
The text was updated successfully, but these errors were encountered: