Skip to content

Latest commit

 

History

History
97 lines (66 loc) · 1.57 KB

declaration-array-type.md

File metadata and controls

97 lines (66 loc) · 1.57 KB

sppt/declaration-array-type

Add explicit type declarations for array variables whose type can not be inferred

  • ⭐️ This rule is included in plugin:sppt/recommended preset.

Cases

✅ Correct

let a: number[] = [];
let a = Array<number>();
let a = Array<number>(5);
let a = new Array<number>();
let a = new Array<number>(5);

❌ Incorrect

let a = [];

Errors: Add explicit type declarations for array variables whose type can not be inferred

let a = Array();

Errors: Add explicit type declarations for array variables whose type can not be inferred

let a = Array(5);

Errors: Add explicit type declarations for array variables whose type can not be inferred

let a = new Array();

Errors: Add explicit type declarations for array variables whose type can not be inferred

let a = [];
let b = new Array(5);
let c = new Array(5);
let d = new Array<number>(5);

Errors: Add explicit type declarations for array variables whose type can not be inferred Add explicit type declarations for array variables whose type can not be inferred Add explicit type declarations for array variables whose type can not be inferred

(TODO: why is this rule useful?)

Rule Details

(TODO: how does this rule check code?)

Options

(TODO: what do options exist?)

Implementation