Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

prefer-array-literal: Error when using Array in a type annotation #110

@nfriend

Description

@nfriend

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 using Array when instantiating new arrays:

new Array();
new Array(4,5);
// etc...

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:

// these throw "Replace generic-typed Array with array literal" linting error

let myArray: Array<MyObject> = [];

interface MyInterface {
    myArray: Array<number>;
}

I expected this rule to throw errors on the first set of examples above but allow the second set.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions