Skip to content

Commit

Permalink
Upgrade to TypeScript 4.8.4 (again). (tensorflow#6090)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bmd3k authored Dec 6, 2022
1 parent b6207af commit 2cd5158
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"prettier-plugin-organize-imports": "2.3.4",
"requirejs": "^2.3.6",
"tslib": "^2.3.0",
"typescript": "4.7.4",
"typescript": "4.8.4",
"yarn-deduplicate": "^5.0.0"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import {
import {TfDomRepeat} from './tf-dom-repeat';

@customElement('tf-category-paginated-view')
// @ts-ignore(go/ts48upgrade) Fix code and remove this comment. Error:
// TS2344: Type 'CategoryItem' does not satisfy the constraint '{}'.
class TfCategoryPaginatedView<CategoryItem> extends TfDomRepeat<CategoryItem> {
class TfCategoryPaginatedView<
CategoryItem extends {}
> extends TfDomRepeat<CategoryItem> {
static readonly template = html`
<template is="dom-if" if="[[_paneRendered]]" id="ifRendered">
<button class="heading" on-tap="_togglePane" open-button$="[[opened]]">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1271,12 +1271,10 @@ class TfGraphControls extends LegacyElementMixin(
_deviceCheckboxClicked(event: Event) {
// Update the device map.
const input = event.target as HTMLInputElement;
// @ts-ignore(go/ts48upgrade) Fix code and remove this comment. Error:
// TS2322: Type 'object' is not assignable to type 'DeviceForStats'.
const devicesForStats: DeviceForStats = Object.assign(
{},
this.devicesForStats
);
) as DeviceForStats;
const device = input.value;
if (input.checked) {
devicesForStats[device] = true;
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/webapp/persistent_settings/_data_source/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export declare interface BackendSettings {
notificationLastReadTimeInMs?: number;
sideBarWidthInPercent?: number;
timeSeriesSettingsPaneOpened?: boolean;
timeSeriesCardMinWidth?: number;
timeSeriesCardMinWidth?: number | null;
stepSelectorEnabled?: boolean;
rangeSelectionEnabled?: boolean;
linkedTimeEnabled?: boolean;
Expand All @@ -59,7 +59,7 @@ export interface PersistableSettings {
notificationLastReadTimeInMs?: number;
sideBarWidthInPercent?: number;
timeSeriesSettingsPaneOpened?: boolean;
timeSeriesCardMinWidth?: number;
timeSeriesCardMinWidth?: number | null;
stepSelectorEnabled?: boolean;
rangeSelectionEnabled?: boolean;
linkedTimeEnabled?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@ import {
} from './persistent_settings_config_types';

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

constructor(
@Optional()
@Inject(GLOBAL_PERSISTENT_SETTINGS_TOKEN)
globalSettingSelectorFactories: Array<
// @ts-ignore(go/ts48upgrade) Fix code and remove this
// comment. Error: TS2344: Type 'Settings' does not satisfy
// the constraint 'PersistableSettings'.
() => SettingSelector<State, Settings>
> | null
) {
Expand All @@ -47,9 +41,6 @@ export class PersistentSettingsConfigModule<State, Settings> {
/**
* Returns Ngrx selectors for getting global setting values.
*/
// @ts-ignore(go/ts48upgrade) Fix code and remove this comment. Error:
// TS2344: Type 'Settings' does not satisfy the constraint
// 'PersistableSettings'.
getGlobalSettingSelectors(): SettingSelector<State, Settings>[] {
return this.globalSettingSelectors ?? [];
}
Expand Down Expand Up @@ -77,12 +68,9 @@ export class PersistentSettingsConfigModule<State, Settings> {
* })
* export class MyModule {}
*/
static defineGlobalSetting<State, Settings>(
// @ts-ignore(go/ts48upgrade) Fix code and remove this comment. Error:
// TS2344: Type 'Settings' does not satisfy the constraint
// 'PersistableSettings'.
static defineGlobalSetting<State, Settings extends {}>(
selectorFactory: () => SettingSelector<State, Settings>
): ModuleWithProviders<PersistentSettingsConfigModule<any, {}>> {
): ModuleWithProviders<PersistentSettingsConfigModule<State, Settings>> {
return {
ngModule: PersistentSettingsConfigModule,
providers: [
Expand Down
4 changes: 1 addition & 3 deletions tensorboard/webapp/testing/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ limitations under the License.
* Recursively freezes an object and all of its fields. The given object is
* assumed not to have reference loops.
*/
export function deepFreeze<T>(obj: T): T {
// @ts-ignore(go/ts48upgrade) Fix code and remove this comment. Error:
// TS2769: No overload matches this call.
export function deepFreeze<T extends {}>(obj: T): T {
for (const val of Object.values(obj)) {
if (val && typeof val === 'object') {
deepFreeze(val);
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9843,16 +9843,16 @@ typed-assert@^1.0.8:
resolved "https://registry.yarnpkg.com/typed-assert/-/typed-assert-1.0.9.tgz#8af9d4f93432c4970ec717e3006f33f135b06213"
integrity sha512-KNNZtayBCtmnNmbo5mG47p1XsCyrx6iVqomjcZnec/1Y5GGARaxPs6r49RnSPeUP3YjNYiU9sQHAtY4BBvnZwg==

[email protected], typescript@~4.7.4:
version "4.7.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==

typescript@^4.6.2, typescript@~4.8.0:
[email protected], typescript@^4.6.2, typescript@~4.8.0:
version "4.8.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==

typescript@~4.7.4:
version "4.7.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==

[email protected]:
version "4.1.0"
resolved "https://registry.yarnpkg.com/typesettable/-/typesettable-4.1.0.tgz#9dc4f539fabad7db4de2c3b08e286ff72a60f038"
Expand Down

0 comments on commit 2cd5158

Please sign in to comment.