Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit d01f9c8

Browse files
committed
build: enable strictPropertyInitialization
- fix related build errors - complete `this._destroyed` in `ngOnDestroy()` - replace use of deprecated `DomPortalHost` with `DomPortalOutlet`
1 parent 4c71715 commit d01f9c8

File tree

22 files changed

+230
-165
lines changed

22 files changed

+230
-165
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var_4: &save_cache
2424
save_cache:
2525
key: *cache_key
2626
paths:
27-
- "node_modules"
27+
- "node_modules/"
2828

2929
var_5: &yarn_install
3030
run:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"publish-beta": "bash ./tools/deploy.sh stable beta",
2727
"test:audit:a11y": "node tools/audit-docs-a11y",
2828
"test:audit:a11y:localhost": "run-p --race \"~~light-server -s dist/material-angular-io -p 4200 --quiet\" \"test:audit:a11y http://localhost:4200\" --",
29-
"test:audit:a11y:ci": "run-p --race \"~~light-server -s ../dist/material-angular-io -p 4200 --quiet\" \"test:audit:a11y http://localhost:4200\" --",
29+
"test:audit:a11y:ci": "run-p --race \"~~light-server -s ../dist/material-angular-io -p 4200\" \"test:audit:a11y http://localhost:4200\" --",
3030
"test:audit": "node tools/audit-docs",
3131
"test:audit:localhost": "run-p --race \"start:static\" \"test:audit http://localhost:4200 2000\" --",
3232
"test:audit:ci": "run-p --race \"~~light-server -s ../dist/material-angular-io -p 4200 --quiet\" \"test:audit http://localhost:4200\" --",

src/app/pages/component-category-list/component-category-list.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1+
import {CommonModule} from '@angular/common';
12
import {Component, NgModule, OnDestroy, OnInit} from '@angular/core';
23
import {MatCardModule} from '@angular/material/card';
3-
import {CommonModule} from '@angular/common';
44
import {ActivatedRoute, Params, RouterModule} from '@angular/router';
5-
import {DocumentationItems, SECTIONS} from '../../shared/documentation-items/documentation-items';
6-
import {ComponentPageTitle} from '../page-title/page-title';
7-
import {SvgViewerModule} from '../../shared/svg-viewer/svg-viewer';
8-
import {Observable, combineLatest, Subscription} from 'rxjs';
9-
import {NavigationFocusModule} from '../../shared/navigation-focus/navigation-focus';
5+
import {combineLatest, Observable, Subscription} from 'rxjs';
106

7+
import {
8+
DocumentationItems,
9+
SECTIONS
10+
} from '../../shared/documentation-items/documentation-items';
11+
import {
12+
NavigationFocusModule
13+
} from '../../shared/navigation-focus/navigation-focus';
14+
import {SvgViewerModule} from '../../shared/svg-viewer/svg-viewer';
15+
import {ComponentPageTitle} from '../page-title/page-title';
1116

1217
@Component({
1318
selector: 'app-component-category-list',
1419
templateUrl: './component-category-list.html',
1520
styleUrls: ['./component-category-list.scss']
1621
})
1722
export class ComponentCategoryList implements OnInit, OnDestroy {
18-
params: Observable<Params>;
19-
routeParamSubscription: Subscription;
20-
_categoryListSummary: string;
23+
params: Observable<Params> | undefined;
24+
routeParamSubscription: Subscription = new Subscription();
25+
_categoryListSummary: string | undefined;
2126

2227
constructor(public docItems: DocumentationItems,
2328
public _componentPageTitle: ComponentPageTitle,

src/app/pages/component-list/component-list.ts

Whitespace-only changes.

src/app/pages/component-sidenav/component-sidenav.ts

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import {animate, state, style, transition, trigger} from '@angular/animations';
2+
import {CdkAccordionModule} from '@angular/cdk/accordion';
3+
import {BreakpointObserver} from '@angular/cdk/layout';
4+
import {CommonModule} from '@angular/common';
5+
import {HttpClientModule} from '@angular/common/http';
16
import {
27
Component,
38
Input,
@@ -8,38 +13,42 @@ import {
813
ViewChild,
914
ViewEncapsulation
1015
} from '@angular/core';
11-
import {DocumentationItems} from '../../shared/documentation-items/documentation-items';
16+
import {FormsModule} from '@angular/forms';
1217
import {MatIconModule} from '@angular/material/icon';
18+
import {MatListModule} from '@angular/material/list';
1319
import {MatSidenav, MatSidenavModule} from '@angular/material/sidenav';
20+
import {MatDrawerToggleResult} from '@angular/material/sidenav/drawer';
1421
import {ActivatedRoute, Params, RouterModule, Routes} from '@angular/router';
15-
import {CommonModule} from '@angular/common';
16-
import {ComponentHeaderModule} from '../component-page-header/component-page-header';
17-
import {FooterModule} from '../../shared/footer/footer';
1822
import {combineLatest, Observable, Subscription} from 'rxjs';
1923
import {map} from 'rxjs/operators';
20-
import {animate, state, style, transition, trigger} from '@angular/animations';
21-
import {CdkAccordionModule} from '@angular/cdk/accordion';
22-
import {BreakpointObserver} from '@angular/cdk/layout';
24+
25+
import {DocViewerModule} from '../../shared/doc-viewer/doc-viewer-module';
26+
import {
27+
DocumentationItems
28+
} from '../../shared/documentation-items/documentation-items';
29+
import {FooterModule} from '../../shared/footer/footer';
30+
import {
31+
NavigationFocusModule
32+
} from '../../shared/navigation-focus/navigation-focus';
33+
import {
34+
NavigationFocusService
35+
} from '../../shared/navigation-focus/navigation-focus.service';
36+
import {StackBlitzButtonModule} from '../../shared/stack-blitz';
37+
import {SvgViewerModule} from '../../shared/svg-viewer/svg-viewer';
2338
import {
2439
ComponentCategoryList,
2540
ComponentCategoryListModule
2641
} from '../component-category-list/component-category-list';
42+
import {
43+
ComponentHeaderModule
44+
} from '../component-page-header/component-page-header';
2745
import {
2846
ComponentApi,
2947
ComponentExamples,
3048
ComponentOverview,
3149
ComponentViewer,
3250
ComponentViewerModule
3351
} from '../component-viewer/component-viewer';
34-
import {DocViewerModule} from '../../shared/doc-viewer/doc-viewer-module';
35-
import {FormsModule} from '@angular/forms';
36-
import {HttpClientModule} from '@angular/common/http';
37-
import {StackBlitzButtonModule} from '../../shared/stack-blitz';
38-
import {SvgViewerModule} from '../../shared/svg-viewer/svg-viewer';
39-
import {MatDrawerToggleResult} from '@angular/material/sidenav/drawer';
40-
import {MatListModule} from '@angular/material/list';
41-
import {NavigationFocusModule} from '../../shared/navigation-focus/navigation-focus';
42-
import {NavigationFocusService} from '../../shared/navigation-focus/navigation-focus.service';
4352

4453
// These constants are used by the ComponentSidenav for orchestrating the MatSidenav in a responsive
4554
// way. This includes hiding the sidenav, defaulting it to open, changing the mode from over to
@@ -58,8 +67,8 @@ const SMALL_WIDTH_BREAKPOINT = 939;
5867
encapsulation: ViewEncapsulation.None,
5968
})
6069
export class ComponentSidenav implements OnInit, OnDestroy {
61-
@ViewChild(MatSidenav) sidenav: MatSidenav;
62-
params: Observable<Params>;
70+
@ViewChild(MatSidenav) sidenav!: MatSidenav;
71+
params: Observable<Params> | undefined;
6372
isExtraScreenSmall: Observable<boolean>;
6473
isScreenSmall: Observable<boolean>;
6574
private subscriptions = new Subscription();
@@ -112,8 +121,8 @@ export class ComponentSidenav implements OnInit, OnDestroy {
112121
],
113122
})
114123
export class ComponentNav {
115-
@Input() params: Observable<Params>;
116-
currentItemId: string;
124+
@Input() params: Observable<Params> | undefined;
125+
currentItemId: string | undefined;
117126

118127
constructor(public docItems: DocumentationItems) {}
119128
}

src/app/pages/component-viewer/component-viewer.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ export class ComponentViewer implements OnDestroy {
3131
sections: Set<string> = new Set(['overview', 'api']);
3232
private _destroyed = new Subject();
3333

34-
constructor(_route: ActivatedRoute,
35-
private router: Router,
34+
constructor(_route: ActivatedRoute, private router: Router,
3635
public _componentPageTitle: ComponentPageTitle,
37-
public docItems: DocumentationItems,
38-
) {
36+
public docItems: DocumentationItems) {
3937
const routeAndParentParams = [_route.params];
4038
if (_route.parent) {
4139
routeAndParentParams.push(_route.parent.params);
@@ -73,27 +71,27 @@ export class ComponentViewer implements OnDestroy {
7371
*/
7472
@Directive()
7573
export class ComponentBaseView implements OnInit, OnDestroy {
76-
@ViewChild('toc') tableOfContents: TableOfContents;
74+
@ViewChild('toc') tableOfContents!: TableOfContents;
7775

7876
showToc: Observable<boolean>;
79-
80-
destroyed = new Subject<void>();
77+
private _destroyed = new Subject();
8178

8279
constructor(public componentViewer: ComponentViewer, breakpointObserver: BreakpointObserver) {
8380
this.showToc = breakpointObserver.observe('(max-width: 1200px)')
8481
.pipe(map(result => !result.matches));
8582
}
8683

8784
ngOnInit() {
88-
this.componentViewer.componentDocItem.pipe(takeUntil(this.destroyed)).subscribe(() => {
85+
this.componentViewer.componentDocItem.pipe(takeUntil(this._destroyed)).subscribe(() => {
8986
if (this.tableOfContents) {
9087
this.tableOfContents.resetHeaders();
9188
}
9289
});
9390
}
9491

9592
ngOnDestroy() {
96-
this.destroyed.next();
93+
this._destroyed.next();
94+
this._destroyed.complete();
9795
}
9896

9997
updateTableOfContents(sectionName: string, docViewerContent: HTMLElement, sectionIndex = 0) {

src/app/shared/carousel/carousel.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,5 @@ describe('HorizontalCarousel', () => {
9999
})
100100
class CarouselTestComponent {
101101
numberOfItems = 6;
102-
@ViewChild(Carousel) carousel: Carousel;
102+
@ViewChild(Carousel) carousel!: Carousel;
103103
}
104-

0 commit comments

Comments
 (0)