Skip to content

Commit

Permalink
Move the initializer into the constructor for instance members that r… (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
groszewn authored Sep 26, 2024
1 parent 6439f10 commit dc20af5
Show file tree
Hide file tree
Showing 11 changed files with 583 additions and 553 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,19 @@ import {State} from '../../store/debugger_types';
`,
})
export class GraphExecutionsContainer {
readonly numGraphExecutions$ = this.store.pipe(select(getNumGraphExecutions));
readonly numGraphExecutions$;

readonly graphExecutionData$ = this.store.pipe(select(getGraphExecutionData));
readonly graphExecutionData$;

readonly graphExecutionIndices$ = this.store.pipe(
select(
createSelector(
getNumGraphExecutions,
(numGraphExecution: number): number[] | null => {
if (numGraphExecution === 0) {
return null;
}
return Array.from({length: numGraphExecution}).map((_, i) => i);
}
)
)
);
readonly graphExecutionIndices$;

readonly focusIndex$ = this.store.pipe(select(getGraphExecutionFocusIndex));
readonly focusIndex$;

/**
* Inferred graph-execution indices that belong to the immediate inputs
* to the currently-focused graph op.
*/
readonly focusInputIndices$ = this.store.pipe(
select(getFocusedGraphExecutionInputIndices)
);
readonly focusInputIndices$;

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

constructor(private readonly store: Store<State>) {}
constructor(private readonly store: Store<State>) {
this.numGraphExecutions$ = this.store.pipe(select(getNumGraphExecutions));
this.graphExecutionData$ = this.store.pipe(select(getGraphExecutionData));
this.graphExecutionIndices$ = this.store.pipe(
select(
createSelector(
getNumGraphExecutions,
(numGraphExecution: number): number[] | null => {
if (numGraphExecution === 0) {
return null;
}
return Array.from({length: numGraphExecution}).map((_, i) => i);
}
)
)
);
this.focusIndex$ = this.store.pipe(select(getGraphExecutionFocusIndex));
this.focusInputIndices$ = this.store.pipe(
select(getFocusedGraphExecutionInputIndices)
);
}
}
Loading

0 comments on commit dc20af5

Please sign in to comment.