Skip to content

Commit 680684f

Browse files
bmd3kyatbear
authored andcommitted
Upgrade to TypeScript 4.8.4 (again). (tensorflow#6090)
This is a revert of a revert of tensorflow#6082 with problems with the original PR addressed in commit tensorflow@a003b1a Original PR description: Upgrade to TypeScript 4.8.4 following instructions in https://github.com/tensorflow/tensorboard/blob/master/DEVELOPMENT.md#adding-updating-or-removing-frontend-dependencies. This upgrade is also a good opportunity to remove some @ts-ignore annotations that were added to the codebase to satisfy the internal upgrade to TS 4.8.4. See tensorflow#6075 and tensorflow#6037. Removing the annotations did indeed lead to build errors that I then fixed with some type adjustments. There is no change in behavior. Verified by: * Running the Angular test suite. * Building and running the TensorBoard app and clicking around. * `cd tensorboard; grep -r "ts-ignore" *` and ensuring all relevant @ts-ignore annotations have been removed.
1 parent 5e67607 commit 680684f

File tree

7 files changed

+17
-33
lines changed

7 files changed

+17
-33
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"prettier-plugin-organize-imports": "2.3.4",
6262
"requirejs": "^2.3.6",
6363
"tslib": "^2.3.0",
64-
"typescript": "4.7.4",
64+
"typescript": "4.8.4",
6565
"yarn-deduplicate": "^5.0.0"
6666
},
6767
"dependencies": {

tensorboard/components/tf_paginated_view/tf-category-paginated-view.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ import {
2828
import {TfDomRepeat} from './tf-dom-repeat';
2929

3030
@customElement('tf-category-paginated-view')
31-
// @ts-ignore(go/ts48upgrade) Fix code and remove this comment. Error:
32-
// TS2344: Type 'CategoryItem' does not satisfy the constraint '{}'.
33-
class TfCategoryPaginatedView<CategoryItem> extends TfDomRepeat<CategoryItem> {
31+
class TfCategoryPaginatedView<
32+
CategoryItem extends {}
33+
> extends TfDomRepeat<CategoryItem> {
3434
static readonly template = html`
3535
<template is="dom-if" if="[[_paneRendered]]" id="ifRendered">
3636
<button class="heading" on-tap="_togglePane" open-button$="[[opened]]">

tensorboard/plugins/graph/tf_graph_controls/tf-graph-controls.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,12 +1271,10 @@ class TfGraphControls extends LegacyElementMixin(
12711271
_deviceCheckboxClicked(event: Event) {
12721272
// Update the device map.
12731273
const input = event.target as HTMLInputElement;
1274-
// @ts-ignore(go/ts48upgrade) Fix code and remove this comment. Error:
1275-
// TS2322: Type 'object' is not assignable to type 'DeviceForStats'.
12761274
const devicesForStats: DeviceForStats = Object.assign(
12771275
{},
12781276
this.devicesForStats
1279-
);
1277+
) as DeviceForStats;
12801278
const device = input.value;
12811279
if (input.checked) {
12821280
devicesForStats[device] = true;

tensorboard/webapp/persistent_settings/_data_source/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export declare interface BackendSettings {
3737
notificationLastReadTimeInMs?: number;
3838
sideBarWidthInPercent?: number;
3939
timeSeriesSettingsPaneOpened?: boolean;
40-
timeSeriesCardMinWidth?: number;
40+
timeSeriesCardMinWidth?: number | null;
4141
stepSelectorEnabled?: boolean;
4242
rangeSelectionEnabled?: boolean;
4343
linkedTimeEnabled?: boolean;
@@ -59,7 +59,7 @@ export interface PersistableSettings {
5959
notificationLastReadTimeInMs?: number;
6060
sideBarWidthInPercent?: number;
6161
timeSeriesSettingsPaneOpened?: boolean;
62-
timeSeriesCardMinWidth?: number;
62+
timeSeriesCardMinWidth?: number | null;
6363
stepSelectorEnabled?: boolean;
6464
rangeSelectionEnabled?: boolean;
6565
linkedTimeEnabled?: boolean;

tensorboard/webapp/persistent_settings/persistent_settings_config_module.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,14 @@ import {
1919
} from './persistent_settings_config_types';
2020

2121
@NgModule()
22-
export class PersistentSettingsConfigModule<State, Settings> {
23-
// @ts-ignore(go/ts48upgrade) Fix code and remove this comment. Error:
24-
// TS2344: Type 'Settings' does not satisfy the constraint
25-
// 'PersistableSettings'.
22+
export class PersistentSettingsConfigModule<State, Settings extends {}> {
2623
private readonly globalSettingSelectors: SettingSelector<State, Settings>[] =
2724
[];
2825

2926
constructor(
3027
@Optional()
3128
@Inject(GLOBAL_PERSISTENT_SETTINGS_TOKEN)
3229
globalSettingSelectorFactories: Array<
33-
// @ts-ignore(go/ts48upgrade) Fix code and remove this
34-
// comment. Error: TS2344: Type 'Settings' does not satisfy
35-
// the constraint 'PersistableSettings'.
3630
() => SettingSelector<State, Settings>
3731
> | null
3832
) {
@@ -47,9 +41,6 @@ export class PersistentSettingsConfigModule<State, Settings> {
4741
/**
4842
* Returns Ngrx selectors for getting global setting values.
4943
*/
50-
// @ts-ignore(go/ts48upgrade) Fix code and remove this comment. Error:
51-
// TS2344: Type 'Settings' does not satisfy the constraint
52-
// 'PersistableSettings'.
5344
getGlobalSettingSelectors(): SettingSelector<State, Settings>[] {
5445
return this.globalSettingSelectors ?? [];
5546
}
@@ -77,12 +68,9 @@ export class PersistentSettingsConfigModule<State, Settings> {
7768
* })
7869
* export class MyModule {}
7970
*/
80-
static defineGlobalSetting<State, Settings>(
81-
// @ts-ignore(go/ts48upgrade) Fix code and remove this comment. Error:
82-
// TS2344: Type 'Settings' does not satisfy the constraint
83-
// 'PersistableSettings'.
71+
static defineGlobalSetting<State, Settings extends {}>(
8472
selectorFactory: () => SettingSelector<State, Settings>
85-
): ModuleWithProviders<PersistentSettingsConfigModule<any, {}>> {
73+
): ModuleWithProviders<PersistentSettingsConfigModule<State, Settings>> {
8674
return {
8775
ngModule: PersistentSettingsConfigModule,
8876
providers: [

tensorboard/webapp/testing/lang.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ limitations under the License.
1616
* Recursively freezes an object and all of its fields. The given object is
1717
* assumed not to have reference loops.
1818
*/
19-
export function deepFreeze<T>(obj: T): T {
20-
// @ts-ignore(go/ts48upgrade) Fix code and remove this comment. Error:
21-
// TS2769: No overload matches this call.
19+
export function deepFreeze<T extends {}>(obj: T): T {
2220
for (const val of Object.values(obj)) {
2321
if (val && typeof val === 'object') {
2422
deepFreeze(val);

yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9843,16 +9843,16 @@ typed-assert@^1.0.8:
98439843
resolved "https://registry.yarnpkg.com/typed-assert/-/typed-assert-1.0.9.tgz#8af9d4f93432c4970ec717e3006f33f135b06213"
98449844
integrity sha512-KNNZtayBCtmnNmbo5mG47p1XsCyrx6iVqomjcZnec/1Y5GGARaxPs6r49RnSPeUP3YjNYiU9sQHAtY4BBvnZwg==
98459845

9846-
[email protected], typescript@~4.7.4:
9847-
version "4.7.4"
9848-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
9849-
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==
9850-
9851-
typescript@^4.6.2, typescript@~4.8.0:
9846+
[email protected], typescript@^4.6.2, typescript@~4.8.0:
98529847
version "4.8.4"
98539848
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
98549849
integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==
98559850

9851+
typescript@~4.7.4:
9852+
version "4.7.4"
9853+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
9854+
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==
9855+
98569856
98579857
version "4.1.0"
98589858
resolved "https://registry.yarnpkg.com/typesettable/-/typesettable-4.1.0.tgz#9dc4f539fabad7db4de2c3b08e286ff72a60f038"

0 commit comments

Comments
 (0)