Skip to content

Commit a8687f9

Browse files
committed
build: fix strict property initialization errors in dev apps
Updates the code to be compatible with strict property initialization.
1 parent b4fe00f commit a8687f9

File tree

27 files changed

+92
-90
lines changed

27 files changed

+92
-90
lines changed

src/dev-app/autocomplete/autocomplete-demo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class AutocompleteDemo {
7777
reactiveDisableStateOption: DisableStateOption = 'none';
7878
templateDisableStateOption: DisableStateOption = 'none';
7979

80-
@ViewChild(NgModel) modelDir: NgModel;
80+
@ViewChild(NgModel) modelDir!: NgModel;
8181

8282
groupedStates: StateGroup[];
8383
filteredGroupedStates: StateGroup[];
@@ -207,7 +207,7 @@ export class AutocompleteDemo {
207207
}
208208

209209
dialog = inject(MatDialog);
210-
dialogRef: MatDialogRef<AutocompleteDemoExampleDialog> | null;
210+
dialogRef: MatDialogRef<AutocompleteDemoExampleDialog> | null = null;
211211

212212
openDialog() {
213213
this.dialogRef = this.dialog.open(AutocompleteDemoExampleDialog, {width: '400px'});

src/dev-app/baseline/baseline-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ import {MatToolbarModule} from '@angular/material/toolbar';
3131
changeDetection: ChangeDetectionStrategy.OnPush,
3232
})
3333
export class BaselineDemo {
34-
name: string;
34+
name = '';
3535
}

src/dev-app/bottom-sheet/bottom-sheet-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class BottomSheetDemo {
5454
ariaLabel: 'Example bottom sheet',
5555
};
5656

57-
@ViewChild(TemplateRef) template: TemplateRef<any>;
57+
@ViewChild(TemplateRef) template!: TemplateRef<any>;
5858

5959
openComponent() {
6060
this._bottomSheet.open(ExampleBottomSheet, this.config);

src/dev-app/cdk-dialog/dialog-demo.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ const defaultDialogConfig = new DialogConfig();
3131
export class DialogDemo {
3232
dialog = inject(Dialog);
3333

34-
dialogRef: DialogRef<string> | null;
35-
result: string;
36-
actionsAlignment: 'start' | 'center' | 'end';
34+
dialogRef: DialogRef<string> | null = null;
35+
result = '';
36+
actionsAlignment!: 'start' | 'center' | 'end';
3737
config = {
3838
disableClose: defaultDialogConfig.disableClose,
3939
panelClass: 'demo-cdk-dialog',
@@ -51,7 +51,7 @@ export class DialogDemo {
5151
};
5252
numTemplateOpens = 0;
5353

54-
@ViewChild(TemplateRef) template: TemplateRef<any>;
54+
@ViewChild(TemplateRef) template!: TemplateRef<any>;
5555

5656
readonly cdr = inject(ChangeDetectorRef);
5757

src/dev-app/checkbox/checkbox-demo.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ export class CheckboxDemo {
118118
demoChecked = false;
119119
demoDisabled = false;
120120
demoIndeterminate = false;
121-
demoLabel: string;
122-
demoLabelledBy: string;
123-
demoId: string;
124-
demoName: string;
125-
demoValue: string;
121+
demoLabel = '';
122+
demoLabelledBy = '';
123+
demoId = '';
124+
demoName = '';
125+
demoValue = '';
126126
demoColor: ThemePalette = 'primary';
127127
demoDisableRipple = false;
128128
demoHideLabel = false;

src/dev-app/connected-overlay/connected-overlay-demo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export class ConnectedOverlayDemo {
5454
viewContainerRef = inject(ViewContainerRef);
5555
dir = inject(Directionality);
5656

57-
@ViewChild(CdkOverlayOrigin) _overlayOrigin: CdkOverlayOrigin;
58-
@ViewChild('overlay') overlayTemplate: TemplateRef<any>;
57+
@ViewChild(CdkOverlayOrigin) _overlayOrigin!: CdkOverlayOrigin;
58+
@ViewChild('overlay') overlayTemplate!: TemplateRef<any>;
5959

6060
originX: HorizontalConnectionPos = 'start';
6161
originY: VerticalConnectionPos = 'bottom';
@@ -69,7 +69,7 @@ export class ConnectedOverlayDemo {
6969
itemCount = 25;
7070
itemArray: any[] = [];
7171
itemText = 'Item with a long name';
72-
overlayRef: OverlayRef | null;
72+
overlayRef: OverlayRef | null = null;
7373

7474
openWithConfig() {
7575
const positionStrategy = createFlexibleConnectedPositionStrategy(

src/dev-app/datepicker/datepicker-demo.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export class CustomHeaderNgContent<D> {
158158
private _dateAdapter = inject<DateAdapter<D>>(DateAdapter);
159159

160160
@ViewChild(MatCalendarHeader)
161-
header: MatCalendarHeader<D>;
161+
header!: MatCalendarHeader<D>;
162162

163163
todayClicked() {
164164
let calendar = this.header.calendar;
@@ -189,17 +189,17 @@ export class CustomHeaderNgContent<D> {
189189
],
190190
})
191191
export class DatepickerDemo {
192-
touch: boolean;
193-
filterOdd: boolean;
194-
yearView: boolean;
195-
inputDisabled: boolean;
196-
datepickerDisabled: boolean;
197-
minDate: Date;
198-
maxDate: Date;
199-
startAt: Date;
192+
touch = false;
193+
filterOdd = false;
194+
yearView = false;
195+
inputDisabled = false;
196+
datepickerDisabled = false;
197+
minDate!: Date;
198+
maxDate!: Date;
199+
startAt!: Date;
200200
date: any;
201-
lastDateInput: Date | null;
202-
lastDateChange: Date | null;
201+
lastDateInput: Date | null = null;
202+
lastDateChange: Date | null = null;
203203
color: ThemePalette;
204204
showActions = false;
205205

src/dev-app/dialog/dialog-demo.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ import {MatSelectModule} from '@angular/material/select';
5959
export class DialogDemo {
6060
dialog = inject(MatDialog);
6161

62-
dialogRef: MatDialogRef<JazzDialog> | null;
63-
lastAfterClosedResult: string;
64-
lastBeforeCloseResult: string;
65-
actionsAlignment: 'start' | 'center' | 'end';
62+
dialogRef: MatDialogRef<JazzDialog> | null = null;
63+
lastAfterClosedResult = '';
64+
lastBeforeCloseResult = '';
65+
actionsAlignment!: 'start' | 'center' | 'end';
6666
config = {
6767
disableClose: false,
6868
panelClass: 'custom-overlay-pane-class',
@@ -88,7 +88,7 @@ export class DialogDemo {
8888
enableLegacyPadding = false;
8989
isScrollable = false;
9090

91-
@ViewChild(TemplateRef) template: TemplateRef<any>;
91+
@ViewChild(TemplateRef) template!: TemplateRef<any>;
9292

9393
readonly cdr = inject(ChangeDetectorRef);
9494

@@ -259,7 +259,7 @@ export class ContentElementDialog {
259259
dialog = inject(MatDialog);
260260

261261
actionsAlignment?: 'start' | 'center' | 'end';
262-
isScrollable: boolean;
262+
isScrollable = false;
263263

264264
showInStackedDialog() {
265265
this.dialog.open(IFrameDialog, {maxWidth: '80vw'});

src/dev-app/drag-drop/drag-drop-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {MatCheckbox} from '@angular/material/checkbox';
4040
],
4141
})
4242
export class DragAndDropDemo {
43-
axisLock: 'x' | 'y';
43+
axisLock!: 'x' | 'y';
4444
dragStartDelay = 0;
4545
todo = ['Go out for Lunch', 'Make a cool app', 'Watch TV', 'Eat a healthy dinner', 'Go to sleep'];
4646
done = ['Get up', 'Have breakfast', 'Brush teeth', 'Check reddit'];

src/dev-app/example/example-list.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ import {Example} from './example';
6060
})
6161
export class ExampleList {
6262
/** Type of examples being displayed. */
63-
@Input() type: string;
63+
@Input() type!: string;
6464

6565
/** IDs of the examples to display. */
66-
@Input() ids: string[];
66+
@Input() ids!: string[];
6767

6868
@Input()
6969
get expandAll(): boolean {
@@ -72,7 +72,7 @@ export class ExampleList {
7272
set expandAll(v: BooleanInput) {
7373
this._expandAll = coerceBooleanProperty(v);
7474
}
75-
_expandAll: boolean;
75+
_expandAll = false;
7676

7777
exampleComponents = EXAMPLE_COMPONENTS;
7878

0 commit comments

Comments
 (0)