Skip to content

Commit 102b65b

Browse files
crisbetoandrewseguin
authored andcommitted
build: enforce consistent array types (#19640)
Adds some linting that we consistently use `T[]` instead of `Array<T>`.
1 parent e4f1b7d commit 102b65b

File tree

13 files changed

+18
-17
lines changed

13 files changed

+18
-17
lines changed

src/cdk-experimental/popover-edit/edit-event-dispatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export class EditEventDispatcher {
274274
}
275275
}
276276

277-
function computeHoverContentState([firstRow, lastRow, activeRow, hoverRow]: Array<Element|null>):
277+
function computeHoverContentState([firstRow, lastRow, activeRow, hoverRow]: (Element|null)[]):
278278
Map<Element, HoverContentState> {
279279
const hoverContentState = new Map<Element, HoverContentState>();
280280

src/cdk/a11y/focus-trap/configurable-focus-trap.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {AfterViewInit, Component, ElementRef, Type, ViewChild} from '@angular/core';
1+
import {AfterViewInit, Component, ElementRef, Type, ViewChild, Provider} from '@angular/core';
22
import {ComponentFixture, TestBed} from '@angular/core/testing';
33
import {
44
A11yModule,
@@ -11,7 +11,7 @@ import {
1111
import {FocusTrapManager} from './focus-trap-manager';
1212

1313
describe('ConfigurableFocusTrap', () => {
14-
let providers: Array<Object>;
14+
let providers: Provider[];
1515

1616
describe('with FocusTrapInertStrategy', () => {
1717
let mockInertStrategy: FocusTrapInertStrategy;
@@ -88,8 +88,8 @@ describe('ConfigurableFocusTrap', () => {
8888
});
8989
});
9090

91-
function createComponent<T>(componentType: Type<T>, providers: Array<Object> = []
92-
): ComponentFixture<T> {
91+
function createComponent<T>(componentType: Type<T>, providers: Provider[] = []):
92+
ComponentFixture<T> {
9393
TestBed.configureTestingModule({
9494
imports: [A11yModule],
9595
declarations: [componentType],

src/cdk/a11y/focus-trap/event-listener-inert-strategy.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {AfterViewInit, Component, ElementRef, Type, ViewChild} from '@angular/core';
1+
import {AfterViewInit, Component, ElementRef, Type, ViewChild, Provider} from '@angular/core';
22
import {ComponentFixture, fakeAsync, flush, TestBed} from '@angular/core/testing';
33
import {patchElementFocus} from '@angular/cdk/testing/private';
44
import {
@@ -58,8 +58,8 @@ describe('EventListenerFocusTrapInertStrategy', () => {
5858

5959
});
6060

61-
function createComponent<T>(componentType: Type<T>, providers: Array<Object> = []
62-
): ComponentFixture<T> {
61+
function createComponent<T>(componentType: Type<T>, providers: Provider[] = []):
62+
ComponentFixture<T> {
6363
TestBed.configureTestingModule({
6464
imports: [A11yModule],
6565
declarations: [componentType],

src/cdk/overlay/overlay-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class OverlayConfig {
6565
// loses the array generic type in the `for of`. But we *also* have to use `Array` because
6666
// typescript won't iterate over an `Iterable` unless you compile with `--downlevelIteration`
6767
const configKeys =
68-
Object.keys(config) as Iterable<keyof OverlayConfig> & Array<keyof OverlayConfig>;
68+
Object.keys(config) as Iterable<keyof OverlayConfig> & (keyof OverlayConfig)[];
6969
for (const key of configKeys) {
7070
if (config[key] !== undefined) {
7171
// TypeScript, as of version 3.5, sees the left-hand-side of this expression

src/cdk/table/sticky-styler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export class StickyStyler {
224224
// Use `Iterable` instead of `Array` because TypeScript, as of 3.6.3,
225225
// loses the array generic type in the `for of`. But we *also* have to use `Array` because
226226
// typescript won't iterate over an `Iterable` unless you compile with `--downlevelIteration`
227-
for (const dir of STICKY_DIRECTIONS as Iterable<StickyDirection> & Array<StickyDirection>) {
227+
for (const dir of STICKY_DIRECTIONS as Iterable<StickyDirection> & StickyDirection[]) {
228228
if (element.style[dir]) {
229229
zIndex += zIndexIncrements[dir];
230230
}

src/google-maps/google-map/google-map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {
408408
* See
409409
* https://developers.google.com/maps/documentation/javascript/reference/map#Map.controls
410410
*/
411-
get controls(): Array<google.maps.MVCArray<Node>> {
411+
get controls(): google.maps.MVCArray<Node>[] {
412412
this._assertInitialized();
413413
return this.googleMap.controls;
414414
}

src/material-experimental/mdc-chips/chip-grid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export class MatChipGrid extends _MatChipGridMixinBase implements AfterContentIn
204204
set value(value: any) {
205205
this._value = value;
206206
}
207-
protected _value: Array<any> = [];
207+
protected _value: any[] = [];
208208

209209
/** An object used to control when error messages are shown. */
210210
@Input() errorStateMatcher: ErrorStateMatcher;

src/material-experimental/mdc-progress-bar/progress-bar.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {MatProgressBar} from './progress-bar';
88

99
describe('MDC-based MatProgressBar', () => {
1010
function createComponent<T>(componentType: Type<T>,
11-
imports?: Array<Type<{}>>): ComponentFixture<T> {
11+
imports?: Type<{}>[]): ComponentFixture<T> {
1212
TestBed.configureTestingModule({
1313
imports: imports || [MatProgressBarModule],
1414
declarations: [componentType]

src/material/progress-bar/progress-bar.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('MatProgressBar', () => {
1010
let fakePath: string;
1111

1212
function createComponent<T>(componentType: Type<T>,
13-
imports?: Array<Type<{}>>): ComponentFixture<T> {
13+
imports?: Type<{}>[]): ComponentFixture<T> {
1414
fakePath = '/fake-path';
1515

1616
TestBed.configureTestingModule({

src/material/select/select.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ describe('MatSelect', () => {
941941
describe('for options', () => {
942942
let fixture: ComponentFixture<BasicSelect>;
943943
let trigger: HTMLElement;
944-
let options: Array<HTMLElement>;
944+
let options: HTMLElement[];
945945

946946
beforeEach(fakeAsync(() => {
947947
fixture = TestBed.createComponent(BasicSelect);

src/material/tooltip/tooltip.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ class OnPushTooltipDemo {
11681168
</button>`,
11691169
})
11701170
class DynamicTooltipsDemo {
1171-
tooltips: Array<string> = [];
1171+
tooltips: string[] = [];
11721172
}
11731173

11741174
@Component({

tools/public_api_guard/google-maps/google-maps.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export declare class GoogleMap implements OnChanges, OnInit, OnDestroy {
33
boundsChanged: Observable<void>;
44
set center(center: google.maps.LatLngLiteral | google.maps.LatLng);
55
centerChanged: Observable<void>;
6-
get controls(): Array<google.maps.MVCArray<Node>>;
6+
get controls(): google.maps.MVCArray<Node>[];
77
get data(): google.maps.Data;
88
googleMap?: google.maps.Map;
99
headingChanged: Observable<void>;

tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"jsdoc-format": [true, "check-multiline-start"],
9898
"no-duplicate-imports": true,
9999
"await-promise": true,
100+
"array-type": [true, "array"],
100101

101102
// Codelyzer
102103
"template-banana-in-box": true,

0 commit comments

Comments
 (0)