Skip to content

Commit dc20af5

Browse files
authored
Move the initializer into the constructor for instance members that r… (#6921)
…eference identifiers declared in the constructor. This updates our OSS code with a change made in cl/678990911, to prevent the change being reverted the next time we sync into our internal code base. When TypeScript outputs modern language features, the below case throws an TS error. ``` class C { a = this.x; // TS2729: Property 'x' is used before its initialization. constructor(public x:number){} } ``` This error is fixed by moving the initializer of such class members into the constructor.
1 parent 6439f10 commit dc20af5

File tree

11 files changed

+583
-553
lines changed

11 files changed

+583
-553
lines changed

tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/views/graph_executions/graph_executions_container.ts

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,33 +42,19 @@ import {State} from '../../store/debugger_types';
4242
`,
4343
})
4444
export class GraphExecutionsContainer {
45-
readonly numGraphExecutions$ = this.store.pipe(select(getNumGraphExecutions));
45+
readonly numGraphExecutions$;
4646

47-
readonly graphExecutionData$ = this.store.pipe(select(getGraphExecutionData));
47+
readonly graphExecutionData$;
4848

49-
readonly graphExecutionIndices$ = this.store.pipe(
50-
select(
51-
createSelector(
52-
getNumGraphExecutions,
53-
(numGraphExecution: number): number[] | null => {
54-
if (numGraphExecution === 0) {
55-
return null;
56-
}
57-
return Array.from({length: numGraphExecution}).map((_, i) => i);
58-
}
59-
)
60-
)
61-
);
49+
readonly graphExecutionIndices$;
6250

63-
readonly focusIndex$ = this.store.pipe(select(getGraphExecutionFocusIndex));
51+
readonly focusIndex$;
6452

6553
/**
6654
* Inferred graph-execution indices that belong to the immediate inputs
6755
* to the currently-focused graph op.
6856
*/
69-
readonly focusInputIndices$ = this.store.pipe(
70-
select(getFocusedGraphExecutionInputIndices)
71-
);
57+
readonly focusInputIndices$;
7258

7359
onScrolledIndexChange(scrolledIndex: number) {
7460
this.store.dispatch(graphExecutionScrollToIndex({index: scrolledIndex}));
@@ -78,5 +64,25 @@ export class GraphExecutionsContainer {
7864
this.store.dispatch(graphExecutionFocused(event));
7965
}
8066

81-
constructor(private readonly store: Store<State>) {}
67+
constructor(private readonly store: Store<State>) {
68+
this.numGraphExecutions$ = this.store.pipe(select(getNumGraphExecutions));
69+
this.graphExecutionData$ = this.store.pipe(select(getGraphExecutionData));
70+
this.graphExecutionIndices$ = this.store.pipe(
71+
select(
72+
createSelector(
73+
getNumGraphExecutions,
74+
(numGraphExecution: number): number[] | null => {
75+
if (numGraphExecution === 0) {
76+
return null;
77+
}
78+
return Array.from({length: numGraphExecution}).map((_, i) => i);
79+
}
80+
)
81+
)
82+
);
83+
this.focusIndex$ = this.store.pipe(select(getGraphExecutionFocusIndex));
84+
this.focusInputIndices$ = this.store.pipe(
85+
select(getFocusedGraphExecutionInputIndices)
86+
);
87+
}
8288
}

0 commit comments

Comments
 (0)