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

Add more simple types #1843

Merged
merged 2 commits into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/rules/arrayTypeRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,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