Angular 21 - Turned on strictTemplates flag - #7148
Conversation
| /** Debug tensor values under non-FULL_TENSOR debug modes. */ | ||
| @Input() | ||
| debugTensorValues: number[][] | null = null; | ||
| debugTensorValues: (number[] | null)[] | null = null; |
There was a problem hiding this comment.
I think it would be more straightforward to just have the separate types on a flat level:
number[][] | Array<null> | null
(I tried internally and I got a lint about using null[] type, saying Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead)
Is Array<null> necessary? Can it be simply number[][] | null ?
| </button> | ||
| <nav | ||
| *ngIf="(width$ | async) > 0" | ||
| *ngIf="((width$ | async) ?? 0) > 0" |
There was a problem hiding this comment.
I was thinking we can use startWith instead, in the source observable, so we would have something like:
this.width$ = this.store.select(getSideBarWidthInPercent).pipe(
startWith(0), // I added this line.
combineLatestWith(this.runsTableFullScreen$),
map(([percentageWidth, fullScreen]) => {
return fullScreen ? 100 : percentageWidth;
})
);
Hmmm... but actually, I'm not sure if this would allow getting rid of the async pipe, maybe not... nor whether TS would be able to tell that it will have a non-null / non-undefined value.
To me, this seemed simpler to reason about and handle, but maybe this is fine. You can check if that works and decide.
| autocomplete="off" | ||
| [placeholder]="placeholder" | ||
| [matAutocomplete]="matAutocomplete" | ||
| [matAutocomplete]="matAutocomplete!" |
There was a problem hiding this comment.
How can we be sure this is not undefined or null?
Is having the matAutocompleteDisabled attribute the intended way to support this?
|
|
||
| @Input() | ||
| customFormatter?: Formatter; | ||
| customFormatter?: Formatter | undefined; |
There was a problem hiding this comment.
Isn't this redundant with the ? at the end of the name? Should that be removed, then?
| [axisDirection]="axisDirection" | ||
| [timeSelection]="timeSelection" | ||
| [startStepAxisPosition]="getAxisPositionFromStartStep()" | ||
| [startStepAxisPosition]="$any(getAxisPositionFromStartStep())" |
There was a problem hiding this comment.
Maybe we can ensure this function returns a number (e.g. fall back to zero)?
| @Input() regexFilterValue!: string; | ||
| @HostBinding('class.valid') @Input() isRegexFilterValid!: boolean; | ||
| @Input() completions!: string[]; | ||
| @Input() completions: string[] | null = null; |
There was a problem hiding this comment.
Can we make the default value be an empty array instead? And we can remove the null checks above, in the template.
Motivation for features / changes
Turns on
strictTemplates. The flag was already set intsconfig.json, but it never reached the Angular compiler because of a gap in the Bazel build tooling. Fixing that bring up a batch of template type errors that this PR resolves.Technical description of changes
Patched
@bazel/concatjssoangularCompilerOptionsfrom the roottsconfig.jsonreaches the compiler. This is what madestrictTemplatesactually apply.strictTemplatesregulated template validation in 38 source files. Essentially a clean up was made with correct typing and unused code:trackByfunctions receiving the index instead of the item, an observable field assigned a plain value, and an input never passed down from its container.floatLabel="never"that stopped being valid several versions ago.strictNullInputTypesisfalsehere, sinceAsyncPipeis typedT | nulland rejects all 166asyncbindings. A follow-up PR moves those containers onto signals and turns it back on.Verification
//tensorboard/webapp/...builds clean, 691 targets.feature_flag.