Skip to content

Commit cff2153

Browse files
authored
fix(multiple): resolve extended template diagnostic warnings (#25546)
Turns the extended template diagnostic warnings into errors and resolves all of the existing ones.
1 parent 335aa0a commit cff2153

File tree

13 files changed

+33
-16
lines changed

13 files changed

+33
-16
lines changed

src/bazel-tsconfig-build.json

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
"skipLibCheck": true,
3333
"types": ["tslib"]
3434
},
35+
"angularCompilerOptions": {
36+
"extendedDiagnostics": {
37+
"defaultCategory": "error"
38+
}
39+
},
3540
"bazelOptions": {
3641
"suppressTsconfigOverrideWarnings": true
3742
}

src/components-examples/material/form-field/form-field-custom-control/example-tel-input-example.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div role="group" class="example-tel-input-container"
22
[formGroup]="parts"
3-
[attr.aria-labelledby]="_formField?.getLabelId()"
3+
[attr.aria-labelledby]="_formField.getLabelId()"
44
(focusin)="onFocusIn($event)"
55
(focusout)="onFocusOut($event)">
66
<input class="example-tel-input-element"

src/components-examples/material/form-field/form-field-hint/form-field-hint-example.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<mat-form-field hintLabel="Max 10 characters" appearance="fill">
33
<mat-label>Enter some input</mat-label>
44
<input matInput #input maxlength="10" placeholder="Ex. Nougat">
5-
<mat-hint align="end">{{input.value?.length || 0}}/10</mat-hint>
5+
<mat-hint align="end">{{input.value.length}}/10</mat-hint>
66
</mat-form-field>
77

88
<mat-form-field appearance="fill">

src/components-examples/material/list/list-single-selection/list-single-selection-example.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
</mat-selection-list>
66

77
<p>
8-
Option selected: {{shoes.selectedOptions.selected[0]?.value}}
8+
Option selected: {{shoes.selectedOptions.hasValue() ? shoes.selectedOptions.selected[0].value : 'None'}}
99
</p>

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {Example} from './example';
2323
<mat-expansion-panel *ngFor="let id of ids" [expanded]="expandAll">
2424
<mat-expansion-panel-header>
2525
<div class="header">
26-
<div class="title"> {{exampleComponents[id]?.title}} </div>
26+
<div class="title">{{_getTitle(id)}}</div>
2727
<div class="id"> <{{id}}> </div>
2828
</div>
2929
</mat-expansion-panel-header>
@@ -76,4 +76,8 @@ export class ExampleList {
7676
_expandAll: boolean;
7777

7878
exampleComponents = EXAMPLE_COMPONENTS;
79+
80+
protected _getTitle(id: string) {
81+
return this.exampleComponents[id]?.title;
82+
}
7983
}

src/dev-app/legacy-select/legacy-select-demo.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<p> Value: {{ currentDrink }} </p>
2424
<p> Touched: {{ drinkControl.touched }} </p>
2525
<p> Dirty: {{ drinkControl.dirty }} </p>
26-
<p> Status: {{ drinkControl.control?.status }} </p>
26+
<p> Status: {{ drinkControl.status }} </p>
2727
<p>
2828
<label for="floating-placeholder">Floating placeholder:</label>
2929
<select [(ngModel)]="floatLabel" id="floating-placeholder">
@@ -70,7 +70,7 @@
7070
<p> Value: {{ currentPokemon }} </p>
7171
<p> Touched: {{ pokemonControl.touched }} </p>
7272
<p> Dirty: {{ pokemonControl.dirty }} </p>
73-
<p> Status: {{ pokemonControl.control?.status }} </p>
73+
<p> Status: {{ pokemonControl.status }} </p>
7474
<p>
7575
<label for="pokemon-theme">Theme:</label>
7676
<select [(ngModel)]="pokemonTheme" id="pokemon-theme">
@@ -139,7 +139,7 @@
139139
<p> Value: {{ currentDrinkObject | json }} </p>
140140
<p> Touched: {{ drinkObjectControl.touched }} </p>
141141
<p> Dirty: {{ drinkObjectControl.dirty }} </p>
142-
<p> Status: {{ drinkObjectControl.control?.status }} </p>
142+
<p> Status: {{ drinkObjectControl.status }} </p>
143143
<p> Comparison Mode: {{ compareByValue ? 'VALUE' : 'REFERENCE' }} </p>
144144

145145
<button mat-button (click)="reassignDrinkByCopy()"

src/dev-app/legacy-select/legacy-select-demo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class LegacySelectDemo {
5959
currentPokemonFromGroup: string;
6060
currentDigimon: string;
6161
currentAppearanceValue: string | null;
62-
latestChangeEvent: MatSelectChange;
62+
latestChangeEvent: MatSelectChange | undefined;
6363
floatLabel: FloatLabelType = 'auto';
6464
drinksWidth = 'default';
6565
foodControl = new FormControl('pizza-1');

src/dev-app/select/select-demo.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<p> Value: {{ currentDrink }} </p>
2525
<p> Touched: {{ drinkControl.touched }} </p>
2626
<p> Dirty: {{ drinkControl.dirty }} </p>
27-
<p> Status: {{ drinkControl.control?.status }} </p>
27+
<p> Status: {{ drinkControl.status }} </p>
2828
<p>
2929
<label for="floating-label">Floating label:</label>
3030
<select [(ngModel)]="floatLabel" id="floating-label">
@@ -72,7 +72,7 @@
7272
<p> Value: {{ currentPokemon }} </p>
7373
<p> Touched: {{ pokemonControl.touched }} </p>
7474
<p> Dirty: {{ pokemonControl.dirty }} </p>
75-
<p> Status: {{ pokemonControl.control?.status }} </p>
75+
<p> Status: {{ pokemonControl.status }} </p>
7676
<p>
7777
<label for="pokemon-theme">Theme:</label>
7878
<select [(ngModel)]="pokemonTheme" id="pokemon-theme">
@@ -143,7 +143,7 @@
143143
<p> Value: {{ currentDrinkObject | json }} </p>
144144
<p> Touched: {{ drinkObjectControl.touched }} </p>
145145
<p> Dirty: {{ drinkObjectControl.dirty }} </p>
146-
<p> Status: {{ drinkObjectControl.control?.status }} </p>
146+
<p> Status: {{ drinkObjectControl.status }} </p>
147147
<p> Comparison Mode: {{ compareByValue ? 'VALUE' : 'REFERENCE' }} </p>
148148

149149
<button mat-button (click)="reassignDrinkByCopy()"

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class SelectDemo {
5656
currentPokemonFromGroup: string;
5757
currentDigimon: string;
5858
currentAppearanceValue: string | null;
59-
latestChangeEvent: MatSelectChange;
59+
latestChangeEvent: MatSelectChange | undefined;
6060
floatLabel: FloatLabelType = 'auto';
6161
drinksWidth = 'default';
6262
foodControl = new FormControl('pizza-1');

src/material/legacy-select/select.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
[cdkConnectedOverlayOrigin]="origin"
3535
[cdkConnectedOverlayOpen]="panelOpen"
3636
[cdkConnectedOverlayPositions]="_positions"
37-
[cdkConnectedOverlayMinWidth]="_triggerRect?.width!"
37+
[cdkConnectedOverlayMinWidth]="_getOverlayMinWidth()"
3838
[cdkConnectedOverlayOffsetY]="_offsetY"
3939
(backdropClick)="close()"
4040
(attach)="_onAttached()"

src/material/legacy-select/select.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export class MatLegacySelect extends _MatSelectBase<MatLegacySelectChange> imple
131131
private _scrollTop = 0;
132132

133133
/** The last measured value for the trigger's client bounding rect. */
134-
_triggerRect: ClientRect;
134+
private _triggerRect: ClientRect;
135135

136136
/** The cached font-size of the trigger element. */
137137
_triggerFontSize = 0;
@@ -264,6 +264,10 @@ export class MatLegacySelect extends _MatSelectBase<MatLegacySelectChange> imple
264264
return new MatLegacySelectChange(this, value);
265265
}
266266

267+
protected _getOverlayMinWidth(): number {
268+
return this._triggerRect?.width;
269+
}
270+
267271
/**
268272
* Sets the x-offset of the overlay panel in relation to the trigger's top start corner.
269273
* This must be adjusted to align the selected option text over the trigger text when

tools/public_api_guard/material/legacy-select.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export class MatSelect extends _MatSelectBase<MatSelectChange> implements OnInit
5353
// (undocumented)
5454
protected _getChangeEvent(value: any): MatSelectChange;
5555
// (undocumented)
56+
protected _getOverlayMinWidth(): number;
57+
// (undocumented)
5658
ngOnInit(): void;
5759
_offsetY: number;
5860
// (undocumented)
@@ -70,7 +72,6 @@ export class MatSelect extends _MatSelectBase<MatSelectChange> implements OnInit
7072
protected _scrollOptionIntoView(index: number): void;
7173
_transformOrigin: string;
7274
_triggerFontSize: number;
73-
_triggerRect: ClientRect;
7475
// (undocumented)
7576
static ɵcmp: i0.ɵɵComponentDeclaration<MatSelect, "mat-select", ["matSelect"], { "disabled": "disabled"; "disableRipple": "disableRipple"; "tabIndex": "tabIndex"; }, {}, ["customTrigger", "options", "optionGroups"], ["mat-select-trigger", "*"], false>;
7677
// (undocumented)

tsconfig.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@
3939
}
4040
},
4141
"angularCompilerOptions": {
42-
"strictTemplates": true
42+
"strictTemplates": true,
43+
"extendedDiagnostics": {
44+
"defaultCategory": "error"
45+
}
4346
},
4447
"include": [
4548
"src/**/*.ts",

0 commit comments

Comments
 (0)