Skip to content

Commit 7a8b022

Browse files
authored
Fix initializer of instance members that reference identifiers declared in the constructor
When public class fields are enabled, such cases throw a TS error similar to this. ``` third_party/javascript/angular_components/src/cdk/platform/platform.ts:37:29 - error TS2729: Property '_platformId' is used before its initialization. 37 isBrowser: boolean = this._platformId ~~~~~~~~~~~ third_party/javascript/angular_components/src/cdk/platform/platform.ts:87:15 87 constructor(@Inject(PLATFORM_ID) private _platformId: Object) {} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '_platformId' is declared here. ``` This error is fixed by moving the initializer of such class members into the constructor. This is a no-op change See go/lsc-fix-properties-used-before-initialization
1 parent 31ef2f8 commit 7a8b022

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

tensorboard/webapp/metrics/views/main_view/card_groups_container.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,20 @@ import {getSortedRenderableCardIdsWithMetadata} from './common_selectors';
3636
export class CardGroupsContainer {
3737
@Input() cardObserver!: CardObserver;
3838

39-
constructor(private readonly store: Store<State>) {}
39+
constructor(private readonly store: Store<State>) {
40+
this.cardGroups$ = this.store
41+
.select(getSortedRenderableCardIdsWithMetadata)
42+
.pipe(
43+
combineLatestWith(this.store.select(getMetricsFilteredPluginTypes)),
44+
map(([cardList, filteredPlugins]) => {
45+
if (!filteredPlugins.size) return cardList;
46+
return cardList.filter((card) => {
47+
return filteredPlugins.has(card.plugin);
48+
});
49+
}),
50+
map((cardList) => groupCardIdWithMetdata(cardList))
51+
);
52+
}
4053

41-
readonly cardGroups$: Observable<CardGroup[]> = this.store
42-
.select(getSortedRenderableCardIdsWithMetadata)
43-
.pipe(
44-
combineLatestWith(this.store.select(getMetricsFilteredPluginTypes)),
45-
map(([cardList, filteredPlugins]) => {
46-
if (!filteredPlugins.size) return cardList;
47-
return cardList.filter((card) => {
48-
return filteredPlugins.has(card.plugin);
49-
});
50-
}),
51-
map((cardList) => groupCardIdWithMetdata(cardList))
52-
);
54+
readonly cardGroups$: Observable<CardGroup[]>;
5355
}

0 commit comments

Comments
 (0)