@@ -23,15 +23,15 @@ Always use `T[]` or `readonly T[]` for all array types.
23
23
Incorrect code for ` "array" ` :
24
24
25
25
``` ts
26
- const x: Array <string > = [" a " , " b " ];
27
- const y: ReadonlyArray <string > = [" a " , " b " ];
26
+ const x: Array <string > = [' a ' , ' b ' ];
27
+ const y: ReadonlyArray <string > = [' a ' , ' b ' ];
28
28
```
29
29
30
30
Correct code for ` "array" ` :
31
31
32
32
``` ts
33
- const x: string [] = [" a " , " b " ];
34
- const y: readonly string [] = [" a " , " b " ];
33
+ const x: string [] = [' a ' , ' b ' ];
34
+ const y: readonly string [] = [' a ' , ' b ' ];
35
35
```
36
36
37
37
### ` "generic" `
@@ -41,15 +41,15 @@ Always use `Array<T>` or `ReadonlyArray<T>` for all array types.
41
41
Incorrect code for ` "generic" ` :
42
42
43
43
``` ts
44
- const x: string [] = [" a " , " b " ];
45
- const y: readonly string [] = [" a " , " b " ];
44
+ const x: string [] = [' a ' , ' b ' ];
45
+ const y: readonly string [] = [' a ' , ' b ' ];
46
46
```
47
47
48
48
Correct code for ` "generic" ` :
49
49
50
50
``` ts
51
- const x: Array <string > = [" a " , " b " ];
52
- const y: ReadonlyArray <string > = [" a " , " b " ];
51
+ const x: Array <string > = [' a ' , ' b ' ];
52
+ const y: ReadonlyArray <string > = [' a ' , ' b ' ];
53
53
```
54
54
55
55
### ` "array-simple" `
@@ -60,23 +60,23 @@ Use `Array<T>` or `ReadonlyArray<T>` for all other types (union types, intersect
60
60
Incorrect code for ` "array-simple" ` :
61
61
62
62
``` ts
63
- const a: (string | number )[] = [" a " , " b " ];
64
- const b: ({ prop: string })[] = [{ prop: " a " }];
63
+ const a: (string | number )[] = [' a ' , ' b ' ];
64
+ const b: ({ prop: string })[] = [{ prop: ' a ' }];
65
65
const c: (() => void )[] = [() => {}];
66
- const d: Array <MyType > = [" a " , " b " ];
67
- const e: Array <string > = [" a " , " b " ];
68
- const f: ReadonlyArray <string > = [" a " , " b " ];
66
+ const d: Array <MyType > = [' a ' , ' b ' ];
67
+ const e: Array <string > = [' a ' , ' b ' ];
68
+ const f: ReadonlyArray <string > = [' a ' , ' b ' ];
69
69
```
70
70
71
71
Correct code for ` "array-simple" ` :
72
72
73
73
``` ts
74
- const a: Array <string | number > = [" a " , " b " ];
75
- const b: Array <{ prop: string }> = [{ prop: " a " }];
74
+ const a: Array <string | number > = [' a ' , ' b ' ];
75
+ const b: Array <{ prop: string }> = [{ prop: ' a ' }];
76
76
const c: Array <() => void > = [() => {}];
77
- const d: MyType [] = [" a " , " b " ];
78
- const e: string [] = [" a " , " b " ];
79
- const f: readonly string [] = [" a " , " b " ];
77
+ const d: MyType [] = [' a ' , ' b ' ];
78
+ const e: string [] = [' a ' , ' b ' ];
79
+ const f: readonly string [] = [' a ' , ' b ' ];
80
80
```
81
81
82
82
## Related to
0 commit comments