Skip to content

Commit b8c1024

Browse files
crisbetovivian-hu-zz
authored andcommitted
refactor: add support for noImplicitAny (#13381)
Enables the `noImplicitAny` compiler option and fixes all of the resulting compiler errors. Fixes #13330.
1 parent 9e5fd91 commit b8c1024

File tree

69 files changed

+486
-361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+486
-361
lines changed

package-lock.json

Lines changed: 236 additions & 178 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"@types/fs-extra": "^4.0.3",
6262
"@types/glob": "^5.0.33",
6363
"@types/gulp": "3.8.32",
64+
"@types/gulp-util": "^3.0.34",
6465
"@types/hammerjs": "^2.0.35",
6566
"@types/jasmine": "^2.8.8",
6667
"@types/merge2": "^0.3.30",

src/cdk-experimental/dialog/dialog-injectors.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
*/
88

99
import {InjectionToken} from '@angular/core';
10-
import {ComponentType, Overlay, ScrollStrategy, BlockScrollStrategy} from '@angular/cdk/overlay';
10+
import {
11+
ComponentType,
12+
Overlay,
13+
ScrollStrategy,
14+
} from '@angular/cdk/overlay';
1115
import {DialogRef} from './dialog-ref';
1216
import {CdkDialogContainer} from './dialog-container';
1317
import {DialogConfig} from './dialog-config';
@@ -31,7 +35,7 @@ export const DIALOG_CONTAINER =
3135

3236
/** @docs-private */
3337
export function MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay):
34-
() => BlockScrollStrategy {
38+
() => ScrollStrategy {
3539
return () => overlay.scrollStrategies.block();
3640
}
3741

src/cdk-experimental/dialog/dialog.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import {
1414
Injector,
1515
Inject,
1616
ComponentRef,
17-
OnDestroy
17+
OnDestroy,
18+
Type
1819
} from '@angular/core';
1920
import {ComponentPortal, PortalInjector, TemplatePortal} from '@angular/cdk/portal';
2021
import {of as observableOf, Observable, Subject, defer} from 'rxjs';
@@ -28,6 +29,7 @@ import {
2829
Overlay,
2930
OverlayRef,
3031
OverlayConfig,
32+
ScrollStrategy,
3133
} from '@angular/cdk/overlay';
3234
import {startWith} from 'rxjs/operators';
3335

@@ -45,6 +47,8 @@ import {
4547
*/
4648
@Injectable()
4749
export class Dialog implements OnDestroy {
50+
private _scrollStrategy: () => ScrollStrategy;
51+
4852
/** Stream that emits when all dialogs are closed. */
4953
get _afterAllClosed(): Observable<void> {
5054
return this._parentDialog ? this._parentDialog.afterAllClosed : this._afterAllClosedBase;
@@ -68,8 +72,10 @@ export class Dialog implements OnDestroy {
6872
constructor(
6973
private overlay: Overlay,
7074
private injector: Injector,
71-
@Inject(DIALOG_REF) private dialogRefConstructor,
72-
@Inject(DIALOG_SCROLL_STRATEGY) private _scrollStrategy,
75+
@Inject(DIALOG_REF) private dialogRefConstructor: Type<DialogRef<any>>,
76+
// TODO(crisbeto): the `any` here can be replaced
77+
// with the proper type once we start using Ivy.
78+
@Inject(DIALOG_SCROLL_STRATEGY) scrollStrategy: any,
7379
@Optional() @SkipSelf() private _parentDialog: Dialog,
7480
@Optional() location: Location) {
7581

@@ -79,6 +85,8 @@ export class Dialog implements OnDestroy {
7985
if (!_parentDialog && location) {
8086
location.subscribe(() => this.closeAll());
8187
}
88+
89+
this._scrollStrategy = scrollStrategy;
8290
}
8391

8492
/** Gets an open dialog by id. */

src/cdk-experimental/tsconfig-build.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"noUnusedParameters": true,
99
"strictNullChecks": true,
1010
"strictFunctionTypes": true,
11+
"noImplicitAny": true,
1112
"importHelpers": true,
1213
"newLine": "lf",
1314
"module": "es2015",

src/cdk/accordion/accordion.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,10 @@ describe('CdkAccordion', () => {
6666

6767
@Component({template: `
6868
<cdk-accordion [multi]="multi">
69-
<cdk-accordion-item #item1></cdk-accordion-item>
70-
<cdk-accordion-item #item2></cdk-accordion-item>
69+
<cdk-accordion-item></cdk-accordion-item>
70+
<cdk-accordion-item></cdk-accordion-item>
7171
</cdk-accordion>`})
7272
class SetOfItems {
73-
@ViewChild('item1') item1;
74-
@ViewChild('item2') item2;
7573
multi: boolean = false;
7674
}
7775

src/cdk/collections/tree-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ export interface TreeDataNodeFlattener<T> {
2727
* Put node descendants of node in array.
2828
* If `onlyExpandable` is true, then only process expandable descendants.
2929
*/
30-
nodeDescendents(node: T, nodes: T[], onlyExpandable: boolean);
30+
nodeDescendents(node: T, nodes: T[], onlyExpandable: boolean): void;
3131
}

src/cdk/drag-drop/drag-utils.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('dragging utilities', () => {
5757
});
5858

5959
it('should not do anything if the source array is empty', () => {
60-
const a = [];
60+
const a: number[] = [];
6161
const b = [3, 4, 5];
6262

6363
transferArrayItem(a, b, 0, 0);

src/cdk/drag-drop/drag.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
SkipSelf,
2929
ViewContainerRef,
3030
} from '@angular/core';
31-
import {Observable, Subject, Subscription} from 'rxjs';
31+
import {Observable, Subject, Subscription, Observer} from 'rxjs';
3232
import {take} from 'rxjs/operators';
3333
import {DragDropRegistry} from './drag-drop-registry';
3434
import {
@@ -206,15 +206,16 @@ export class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
206206
* Emits as the user is dragging the item. Use with caution,
207207
* because this event will fire for every pixel that the user has dragged.
208208
*/
209-
@Output('cdkDragMoved') moved: Observable<CdkDragMove<T>> = Observable.create(observer => {
210-
const subscription = this._moveEvents.subscribe(observer);
211-
this._moveEventSubscriptions++;
212-
213-
return () => {
214-
subscription.unsubscribe();
215-
this._moveEventSubscriptions--;
216-
};
217-
});
209+
@Output('cdkDragMoved') moved: Observable<CdkDragMove<T>> =
210+
Observable.create((observer: Observer<CdkDragMove<T>>) => {
211+
const subscription = this._moveEvents.subscribe(observer);
212+
this._moveEventSubscriptions++;
213+
214+
return () => {
215+
subscription.unsubscribe();
216+
this._moveEventSubscriptions--;
217+
};
218+
});
218219

219220
constructor(
220221
/** Element that the draggable is attached to. */
@@ -470,7 +471,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
470471
* Updates the item's position in its drop container, or moves it
471472
* into a new one, depending on its current drag position.
472473
*/
473-
private _updateActiveDropContainer({x, y}) {
474+
private _updateActiveDropContainer({x, y}: Point) {
474475
// Drop container that draggable has been moved into.
475476
let newContainer = this.dropContainer._getSiblingContainerFromPosition(this, x, y);
476477

src/cdk/layout/breakpoints-observer.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class FakeMediaQueryList {
137137
/** The callback for change events. */
138138
addListenerCallback?: (mql: MediaQueryListEvent) => void;
139139

140-
constructor(public matches, public media) {}
140+
constructor(public matches: boolean, public media: string) {}
141141

142142
/** Toggles the matches state and "emits" a change event. */
143143
setMatches(matches: boolean) {

0 commit comments

Comments
 (0)