Skip to content

Commit 25ad0b5

Browse files
author
Andy
authored
Apply "array-type" lint rule (#18699)
1 parent 5353475 commit 25ad0b5

File tree

14 files changed

+33
-20
lines changed

14 files changed

+33
-20
lines changed

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ namespace ts {
14621462

14631463
// file.imports may not be undefined if there exists dynamic import
14641464
let imports: StringLiteral[];
1465-
let moduleAugmentations: Array<StringLiteral | Identifier>;
1465+
let moduleAugmentations: (StringLiteral | Identifier)[];
14661466
let ambientModules: string[];
14671467

14681468
// If we are importing helpers, we need to add a synthetic reference to resolve the

src/compiler/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ namespace ts {
15141514
}
15151515

15161516
export function getJSDocCommentsAndTags(node: Node): (JSDoc | JSDocTag)[] {
1517-
let result: Array<JSDoc | JSDocTag> | undefined;
1517+
let result: (JSDoc | JSDocTag)[] | undefined;
15181518
getJSDocCommentsAndTagsWorker(node);
15191519
return result || emptyArray;
15201520

src/harness/fourslash.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ namespace FourSlash {
10031003
}
10041004
}
10051005

1006-
public verifyReferenceGroups(startRanges: Range | Range[], parts: Array<{ definition: string, ranges: Range[] }>): void {
1006+
public verifyReferenceGroups(startRanges: Range | Range[], parts: FourSlashInterface.ReferenceGroup[]): void {
10071007
const fullExpected = ts.map(parts, ({ definition, ranges }) => ({ definition, ranges: ranges.map(rangeToReferenceEntry) }));
10081008

10091009
for (const startRange of toArray(startRanges)) {
@@ -3833,7 +3833,7 @@ namespace FourSlashInterface {
38333833
this.state.verifyReferencesOf(start, references);
38343834
}
38353835

3836-
public referenceGroups(startRanges: FourSlash.Range[], parts: Array<{ definition: string, ranges: FourSlash.Range[] }>) {
3836+
public referenceGroups(startRanges: FourSlash.Range[], parts: ReferenceGroup[]) {
38373837
this.state.verifyReferenceGroups(startRanges, parts);
38383838
}
38393839

@@ -4344,6 +4344,11 @@ namespace FourSlashInterface {
43444344
}
43454345
}
43464346

4347+
export interface ReferenceGroup {
4348+
definition: string;
4349+
ranges: FourSlash.Range[];
4350+
}
4351+
43474352
export interface ApplyRefactorOptions {
43484353
refactorName: string;
43494354
actionName: string;

src/harness/unittests/session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ namespace ts.server {
509509
class InProcClient {
510510
private server: InProcSession;
511511
private seq = 0;
512-
private callbacks: Array<(resp: protocol.Response) => void> = [];
512+
private callbacks: ((resp: protocol.Response) => void)[] = [];
513513
private eventHandlers = createMap<(args: any) => void>();
514514

515515
handle(msg: protocol.Message): void {

src/lib/es2015.core.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface Array<T> {
1010
* @param thisArg If provided, it will be used as the this value for each invocation of
1111
* predicate. If it is not provided, undefined is used instead.
1212
*/
13-
find(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): T | undefined;
13+
find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined;
1414

1515
/**
1616
* Returns the index of the first element in the array where predicate is true, and -1
@@ -21,7 +21,7 @@ interface Array<T> {
2121
* @param thisArg If provided, it will be used as the this value for each invocation of
2222
* predicate. If it is not provided, undefined is used instead.
2323
*/
24-
findIndex(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): number;
24+
findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number;
2525

2626
/**
2727
* Returns the this object after filling the section identified by start and end with value
@@ -52,13 +52,13 @@ interface ArrayConstructor {
5252
* @param mapfn A mapping function to call on every element of the array.
5353
* @param thisArg Value of 'this' used to invoke the mapfn.
5454
*/
55-
from<T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): Array<U>;
55+
from<T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[];
5656

5757
/**
5858
* Returns a new array from a set of elements.
5959
* @param items A set of elements to include in the new array object.
6060
*/
61-
of<T>(...items: T[]): Array<T>;
61+
of<T>(...items: T[]): T[];
6262
}
6363

6464
interface DateConstructor {

src/lib/es2015.iterable.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ interface ArrayConstructor {
5454
* @param mapfn A mapping function to call on every element of the array.
5555
* @param thisArg Value of 'this' used to invoke the mapfn.
5656
*/
57-
from<T, U = T>(iterable: Iterable<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): Array<U>;
57+
from<T, U = T>(iterable: Iterable<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[];
5858
}
5959

6060
interface ReadonlyArray<T> {

src/lib/es2015.reflect.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ declare namespace Reflect {
88
function getPrototypeOf(target: object): object;
99
function has(target: object, propertyKey: PropertyKey): boolean;
1010
function isExtensible(target: object): boolean;
11-
function ownKeys(target: object): Array<PropertyKey>;
11+
function ownKeys(target: object): PropertyKey[];
1212
function preventExtensions(target: object): boolean;
1313
function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
1414
function setPrototypeOf(target: object, proto: any): boolean;

src/server/editorServices.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ namespace ts.server {
8484
}
8585

8686
export interface SafeList {
87-
[name: string]: { match: RegExp, exclude?: Array<Array<string | number>>, types?: string[] };
87+
[name: string]: { match: RegExp, exclude?: (string | number)[][], types?: string[] };
8888
}
8989

9090
function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions: CommandLineOption[]): Map<Map<number>> {
@@ -1780,7 +1780,7 @@ namespace ts.server {
17801780

17811781
if (rule.exclude) {
17821782
for (const exclude of rule.exclude) {
1783-
const processedRule = root.replace(rule.match, (...groups: Array<string>) => {
1783+
const processedRule = root.replace(rule.match, (...groups: string[]) => {
17841784
return exclude.map(groupNumberOrString => {
17851785
// RegExp group numbers are 1-based, but the first element in groups
17861786
// is actually the original string, so it all works out in the end.

src/services/findAllReferences.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ namespace ts.FindAllReferences.Core {
515515
}
516516

517517
// Source file ID → symbol ID → Whether the symbol has been searched for in the source file.
518-
private readonly sourceFileToSeenSymbols: Array<Array<true>> = [];
518+
private readonly sourceFileToSeenSymbols: true[][] = [];
519519
/** Returns `true` the first time we search for a symbol in a file and `false` afterwards. */
520520
markSearchedSymbol(sourceFile: SourceFile, symbol: Symbol): boolean {
521521
const sourceId = getNodeId(sourceFile);

src/services/importTracker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace ts.FindAllReferences {
44
export interface ImportsResult {
55
/** For every import of the symbol, the location and local symbol for the import. */
6-
importSearches: Array<[Identifier, Symbol]>;
6+
importSearches: [Identifier, Symbol][];
77
/** For rename imports/exports `{ foo as bar }`, `foo` is not a local, so it may be added as a reference immediately without further searching. */
88
singleReferences: Identifier[];
99
/** List of source files that may (or may not) use the symbol via a namespace. (For UMD modules this is every file.) */
@@ -180,7 +180,7 @@ namespace ts.FindAllReferences {
180180
* But re-exports will be placed in 'singleReferences' since they cannot be locally referenced.
181181
*/
182182
function getSearchesFromDirectImports(directImports: Importer[], exportSymbol: Symbol, exportKind: ExportKind, checker: TypeChecker, isForRename: boolean): Pick<ImportsResult, "importSearches" | "singleReferences"> {
183-
const importSearches: Array<[Identifier, Symbol]> = [];
183+
const importSearches: [Identifier, Symbol][] = [];
184184
const singleReferences: Identifier[] = [];
185185
function addSearch(location: Identifier, symbol: Symbol): void {
186186
importSearches.push([location, symbol]);

0 commit comments

Comments
 (0)