Skip to content

Commit

Permalink
infra: upgrade TypeScript to 4.4.2. (tensorflow#5276)
Browse files Browse the repository at this point in the history
Internally, they are meaning to upgrade TypeScript and this is the
pre-work for the upgrade.

When we upgraded TypeScript, some type checks changed and this change
adapts to the change.
  • Loading branch information
stephanwlee authored Aug 31, 2021
1 parent f103aec commit 75c4f94
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 20 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@types/lodash": "^4.14.172",
"@types/marked": "^2.0.4",
"@types/node": "^16.4.13",
"@types/offscreencanvas": "^2019.6.3",
"@types/requirejs": "^2.1.33",
"@types/resize-observer-browser": "^0.1.6",
"@types/three": "^0.131.0",
Expand All @@ -60,7 +61,7 @@
"rollup": "^2.56.2",
"terser": "^5.7.1",
"tslib": "^2.3.0",
"typescript": "4.3.5"
"typescript": "4.4.2"
},
"dependencies": {
"@angular/animations": "^12.2.0",
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/components/experimental/plugin_util/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ export class IPC {
}

let replyPayload = null;
let replyError = null;
let replyError: string | null = null;
if (this.listeners.has(type)) {
const callback = this.listeners.get(type) as MessageCallback;
try {
const result = await callback(payload);
replyPayload = result;
} catch (e) {
replyError = e;
replyError = e as string;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tensorboard/plugins/graph/tf_graph_common/minimap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class Minimap {
this.zoomG = zoomG;
this.mainZoom = mainZoom;
this.maxWandH = maxWandH;
let $shadowRoot = d3.select(minimap.shadowRoot);
let $shadowRoot = d3.select((minimap.shadowRoot as unknown) as Element);
// The minimap will have 2 main components: the canvas showing the content
// and an svg showing a rectangle of the currently zoomed/panned viewpoint.
let $minimapSvg = $shadowRoot.select('svg');
Expand Down
32 changes: 22 additions & 10 deletions tensorboard/webapp/runs/store/runs_reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,17 @@ const dataReducer: ActionReducer<RunsDataState, Action> = createReducer(
on(runsActions.fetchRunsRequested, (state, action) => {
const nextRunsLoadState = {...state.runsLoadState};
for (const eid of action.requestedExperimentIds) {
nextRunsLoadState[eid] = {
lastLoadedTimeInMs: null,
...nextRunsLoadState[eid],
state: DataLoadState.LOADING,
};
if (!nextRunsLoadState[eid]) {
nextRunsLoadState[eid] = {
lastLoadedTimeInMs: null,
state: DataLoadState.LOADING,
};
} else {
nextRunsLoadState[eid] = {
...nextRunsLoadState[eid],
state: DataLoadState.LOADING,
};
}
}

return {...state, runsLoadState: nextRunsLoadState};
Expand Down Expand Up @@ -178,11 +184,17 @@ const dataReducer: ActionReducer<RunsDataState, Action> = createReducer(
on(runsActions.fetchRunsFailed, (state, action) => {
const nextRunsLoadState = {...state.runsLoadState};
for (const eid of action.requestedExperimentIds) {
nextRunsLoadState[eid] = {
lastLoadedTimeInMs: null,
...nextRunsLoadState[eid],
state: DataLoadState.FAILED,
};
if (!nextRunsLoadState[eid]) {
nextRunsLoadState[eid] = {
lastLoadedTimeInMs: null,
state: DataLoadState.FAILED,
};
} else {
nextRunsLoadState[eid] = {
...nextRunsLoadState[eid],
state: DataLoadState.FAILED,
};
}
}
return {...state, runsLoadState: nextRunsLoadState};
}),
Expand Down
1 change: 1 addition & 0 deletions tensorboard/webapp/widgets/line_chart_v2/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ tf_ts_library(
deps = [
":internal_types",
"//tensorboard/webapp/widgets/line_chart_v2/lib/renderer:types",
"@npm//@types/offscreencanvas",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tf_ts_library(
"//tensorboard/webapp/widgets/line_chart_v2/lib:coordinator",
"//tensorboard/webapp/widgets/line_chart_v2/lib:internal_types",
"//tensorboard/webapp/widgets/line_chart_v2/lib:utils",
"@npm//@types/offscreencanvas",
"@npm//@types/three",
"@npm//three",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

import * as THREE from 'three';

import {hsl, interpolateHsl} from '../../../../third_party/d3';
Expand Down Expand Up @@ -287,7 +288,7 @@ export class ThreeRenderer implements ObjectRenderer<CacheValue> {
antialias: true,
precision: 'highp',
alpha: true,
}) as WebGLRenderingContext,
} as WebGLContextAttributes) as WebGLRenderingContext,
});
this.renderer.setPixelRatio(devicePixelRatio);
}
Expand Down
1 change: 1 addition & 0 deletions tensorboard/webapp/widgets/line_chart_v2/lib/worker/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ tf_ts_library(
":compact_data_series",
"//tensorboard/webapp/widgets/line_chart_v2/lib:internal_types",
"//tensorboard/webapp/widgets/line_chart_v2/lib/renderer:types",
"@npm//@types/offscreencanvas",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ export class WorkerChart implements Chart {
useDarkMode: options.useDarkMode,
};

this.workerInstance.postMessage(initMessage, [canvas, channel.port2]);
this.workerInstance.postMessage(initMessage, [
canvas,
channel.port2,
] as Transferable[]);
}

dispose() {
Expand Down
25 changes: 21 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@
integrity sha512-uvs0ir7me/KSIm4YGhkPolIjs+Fzjg6JrkRg8CYjnVLz+I6Ajr2+X9e3ylZP+0lNWhqJkkCjXm1jybPTUV5RKQ==

"@bazel/typescript@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-3.7.0.tgz#a4d648a36f7ef4960c8a16222f853a4c285a522d"
integrity sha512-bkNHZaCWg4Jk+10wzhFDhB+RRZkfob/yydC4qRzUVxCDLPFICYgC0PWeLhf/ixEhVeHtS0Cmv74M+QziqKSdbw==
version "3.8.0"
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-3.8.0.tgz#725d51a1c25e314a1d8cddb8b880ac05ba97acd4"
integrity sha512-4C1pLe4V7aidWqcPsWNqXFS7uHAB1nH5SUKG5uWoVv4JT9XhkNSvzzQIycMwXs2tZeCylX4KYNeNvfKrmkyFlw==
dependencies:
protobufjs "6.8.8"
semver "5.6.0"
Expand Down Expand Up @@ -1618,6 +1618,13 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.6.0.tgz#0d5685f85066f94e97f19e8a67fe003c5fadacc4"
integrity sha512-OyiZPohMMjZEYqcVo/UJ04GyAxXOJEZO/FpzyXxcH4r/ArrVoXHf4MbUrkLp0Tz7/p1mMKpo5zJ6ZHl8XBNthQ==

"@types/offscreencanvas@^2019.6.3":
version "2019.6.3"
resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.6.3.tgz#0508eec9641f3228bf8a27009670166887dc966c"
integrity sha512-957DsU187Y90EmlXneuqrqnwmwCkC9oPyQ/IEGwmDRpMfuhcGtjIz72Me7HvdK04ZC16A0VWmv0TSNLwC9ZvXw==
dependencies:
"@types/webgl2" "*"

"@types/offscreencanvas@~2019.3.0":
version "2019.3.0"
resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553"
Expand Down Expand Up @@ -1655,6 +1662,11 @@
resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d"
integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg==

"@types/webgl2@*":
version "0.0.6"
resolved "https://registry.yarnpkg.com/@types/webgl2/-/webgl2-0.0.6.tgz#1ea2db791362bd8521548d664dbd3c5311cdf4b6"
integrity sha512-50GQhDVTq/herLMiqSQkdtRu+d5q/cWHn4VvKJtrj4DJAjo1MNkWYa2MA41BaBO1q1HgsUjuQvEOk0QHvlnAaQ==

"@types/[email protected]":
version "0.0.5"
resolved "https://registry.yarnpkg.com/@types/webgl2/-/webgl2-0.0.5.tgz#dd925e20ab8ace80eb4b1e46fda5b109c508fb0d"
Expand Down Expand Up @@ -5091,7 +5103,12 @@ type-is@~1.6.17:
media-typer "0.3.0"
mime-types "~2.1.24"

[email protected], typescript@~4.3.5:
[email protected]:
version "4.4.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==

typescript@~4.3.5:
version "4.3.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==
Expand Down

0 comments on commit 75c4f94

Please sign in to comment.