Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
array-type: undefined and never now considered simple types (#1843
Browse files Browse the repository at this point in the history
)
  • Loading branch information
andy-hanson authored and nchen63 committed Mar 6, 2017
1 parent f11c308 commit 3923abf
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/rules/arrayTypeRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ class ArrayTypeWalker extends Lint.RuleWalker {
case ts.SyntaxKind.ArrayType:
case ts.SyntaxKind.BooleanKeyword:
case ts.SyntaxKind.NullKeyword:
case ts.SyntaxKind.UndefinedKeyword:
case ts.SyntaxKind.NumberKeyword:
case ts.SyntaxKind.StringKeyword:
case ts.SyntaxKind.SymbolKeyword:
case ts.SyntaxKind.VoidKeyword:
case ts.SyntaxKind.NeverKeyword:
return true;
case ts.SyntaxKind.TypeReference:
// TypeReferences must be non-generic or be another Array with a simple type
Expand Down
2 changes: 1 addition & 1 deletion test/rules/array-type/array-simple/test.ts.fix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let x: number[] = [1] as number[];
let x: undefined[] = [undefined] as undefined[];
let y: string[] = <string[]>["2"];
let z: any[] = [3, "4"];

Expand Down
4 changes: 2 additions & 2 deletions test/rules/array-type/array-simple/test.ts.lint
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let x: Array<number> = [1] as number[];
~~~~~~~~~~~~~ [Array type using 'Array<T>' is forbidden for simple types. Use 'T[]' instead.]
let x: Array<undefined> = [undefined] as undefined[];
~~~~~~~~~~~~~~~~ [Array type using 'Array<T>' is forbidden for simple types. Use 'T[]' instead.]
let y: string[] = <Array<string>>["2"];
~~~~~~~~~~~~~ [Array type using 'Array<T>' is forbidden for simple types. Use 'T[]' instead.]
let z: Array = [3, "4"];
Expand Down
2 changes: 1 addition & 1 deletion test/rules/array-type/array/test.ts.fix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let x: number[] = [1] as number[];
let x: undefined[] = [undefined] as undefined[];
let y: string[] = <string[]>["2"];
let z: any[] = [3, "4"];

Expand Down
4 changes: 2 additions & 2 deletions test/rules/array-type/array/test.ts.lint
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let x: Array<number> = [1] as number[];
~~~~~~~~~~~~~ [Array type using 'Array<T>' is forbidden. Use 'T[]' instead.]
let x: Array<undefined> = [undefined] as undefined[];
~~~~~~~~~~~~~~~~ [Array type using 'Array<T>' is forbidden. Use 'T[]' instead.]
let y: string[] = <Array<string>>["2"];
~~~~~~~~~~~~~ [Array type using 'Array<T>' is forbidden. Use 'T[]' instead.]
let z: Array = [3, "4"];
Expand Down

0 comments on commit 3923abf

Please sign in to comment.