Skip to content

Commit 9092bd8

Browse files
committed
feat: add support for noImplicitAny
Enables the `noImplicitAny` compiler option and fixes all of the resulting compiler errors. Fixes #13330.
1 parent 8ed0129 commit 9092bd8

File tree

66 files changed

+243
-180
lines changed

Some content is hidden

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

66 files changed

+243
-180
lines changed

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: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
Injectable,
1414
Injector,
1515
Inject,
16-
ComponentRef
16+
ComponentRef,
17+
Type
1718
} from '@angular/core';
1819
import {ComponentPortal, PortalInjector, TemplatePortal} from '@angular/cdk/portal';
1920
import {of as observableOf, Observable, Subject, defer} from 'rxjs';
@@ -27,6 +28,7 @@ import {
2728
Overlay,
2829
OverlayRef,
2930
OverlayConfig,
31+
ScrollStrategy,
3032
} from '@angular/cdk/overlay';
3133
import {startWith} from 'rxjs/operators';
3234

@@ -44,6 +46,8 @@ import {
4446
*/
4547
@Injectable()
4648
export class Dialog {
49+
private _scrollStrategy: () => ScrollStrategy;
50+
4751
/** Stream that emits when all dialogs are closed. */
4852
get _afterAllClosed(): Observable<void> {
4953
return this._parentDialog ? this._parentDialog.afterAllClosed : this._afterAllClosedBase;
@@ -67,8 +71,8 @@ export class Dialog {
6771
constructor(
6872
private overlay: Overlay,
6973
private injector: Injector,
70-
@Inject(DIALOG_REF) private dialogRefConstructor,
71-
@Inject(DIALOG_SCROLL_STRATEGY) private _scrollStrategy,
74+
@Inject(DIALOG_REF) private dialogRefConstructor: Type<DialogRef<any>>,
75+
@Inject(DIALOG_SCROLL_STRATEGY) scrollStrategy: any,
7276
@Optional() @SkipSelf() private _parentDialog: Dialog,
7377
@Optional() location: Location) {
7478

@@ -78,6 +82,8 @@ export class Dialog {
7882
if (!_parentDialog && location) {
7983
location.subscribe(() => this.closeAll());
8084
}
85+
86+
this._scrollStrategy = scrollStrategy;
8187
}
8288

8389
/** 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
@@ -27,7 +27,7 @@ import {
2727
SkipSelf,
2828
ViewContainerRef,
2929
} from '@angular/core';
30-
import {merge, Observable, Subject} from 'rxjs';
30+
import {merge, Observable, Subject, Observer} from 'rxjs';
3131
import {takeUntil, take} from 'rxjs/operators';
3232
import {DragDropRegistry} from './drag-drop-registry';
3333
import {
@@ -173,15 +173,16 @@ export class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
173173
* Emits as the user is dragging the item. Use with caution,
174174
* because this event will fire for every pixel that the user has dragged.
175175
*/
176-
@Output('cdkDragMoved') moved: Observable<CdkDragMove<T>> = Observable.create(observer => {
177-
const subscription = this._moveEvents.subscribe(observer);
178-
this._moveEventSubscriptions++;
179-
180-
return () => {
181-
subscription.unsubscribe();
182-
this._moveEventSubscriptions--;
183-
};
184-
});
176+
@Output('cdkDragMoved') moved: Observable<CdkDragMove<T>> =
177+
Observable.create((observer: Observer<CdkDragMove<T>>) => {
178+
const subscription = this._moveEvents.subscribe(observer);
179+
this._moveEventSubscriptions++;
180+
181+
return () => {
182+
subscription.unsubscribe();
183+
this._moveEventSubscriptions--;
184+
};
185+
});
185186

186187
constructor(
187188
/** Element that the draggable is attached to. */
@@ -428,7 +429,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
428429
* Updates the item's position in its drop container, or moves it
429430
* into a new one, depending on its current drag position.
430431
*/
431-
private _updateActiveDropContainer({x, y}) {
432+
private _updateActiveDropContainer({x, y}: Point) {
432433
// Drop container that draggable has been moved into.
433434
let newContainer = this.dropContainer._getSiblingContainerFromPosition(this, x, y);
434435

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 implements MediaQueryList {
137137
/** The callback for change events. */
138138
addListenerCallback?: (mql: MediaQueryList) => 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) {

src/cdk/observers/observe-content.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
OnDestroy,
2020
Output,
2121
} from '@angular/core';
22-
import {Observable, Subject, Subscription} from 'rxjs';
22+
import {Observable, Subject, Subscription, Observer} from 'rxjs';
2323
import {debounceTime} from 'rxjs/operators';
2424

2525
/**
@@ -65,7 +65,7 @@ export class ContentObserver implements OnDestroy {
6565
observe(elementOrRef: Element | ElementRef<Element>): Observable<MutationRecord[]> {
6666
const element = elementOrRef instanceof ElementRef ? elementOrRef.nativeElement : elementOrRef;
6767

68-
return Observable.create(observer => {
68+
return Observable.create((observer: Observer<MutationRecord[]>) => {
6969
const stream = this._observeElement(element);
7070
const subscription = stream.subscribe(observer);
7171

src/cdk/overlay/overlay-config.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
import {PositionStrategy} from './position/position-strategy';
1010
import {Direction, Directionality} from '@angular/cdk/bidi';
11-
import {ScrollStrategy} from './scroll/scroll-strategy';
12-
import {NoopScrollStrategy} from './scroll/noop-scroll-strategy';
11+
import {ScrollStrategy, NoopScrollStrategy} from './scroll/index';
1312

1413

1514
/** Initial configuration used when creating an overlay. */
@@ -62,9 +61,13 @@ export class OverlayConfig {
6261

6362
constructor(config?: OverlayConfig) {
6463
if (config) {
65-
Object.keys(config)
66-
.filter(key => typeof config[key] !== 'undefined')
67-
.forEach(key => this[key] = config[key]);
64+
Object.keys(config).forEach(k => {
65+
const key = k as keyof OverlayConfig;
66+
67+
if (typeof config[key] !== 'undefined') {
68+
this[key] = config[key];
69+
}
70+
});
6871
}
6972
}
7073
}

0 commit comments

Comments
 (0)