From 7145a5534858d1a8c85e13d07c914b418ccc292c Mon Sep 17 00:00:00 2001 From: kimyenac Date: Sun, 19 Jul 2026 15:31:48 +0900 Subject: [PATCH] [ZEPPELIN-6441] Replace outdated type assertions with satisfies TypeScript is now ~5.9.3, so the pre-4.9 workaround TODOs are obsolete. - app.module.ts: `as JoinedEditorOptions` -> `satisfies JoinedEditorOptions` so unsupported editor options are caught at compile time. - create-repository-modal.component.ts: `as Record<...>` -> `satisfies Record<...>` so every form control key is validated against CreateInterpreterRepositoryForm. - notebook-paragraph-keyboard-event-handler.ts: `as const` -> `as const satisfies ...` for both the action->handler map and the Monaco-handled action list. `as const` is kept so downstream `typeof`-based literal indexing still narrows correctly, while `satisfies` now validates keys/values (invalid handler names are rejected). Runtime behavior is unchanged; these are compile-time-only annotations. Co-Authored-By: Claude Opus 4.8 (1M context) --- zeppelin-web-angular/src/app/app.module.ts | 3 +-- .../notebook-paragraph-keyboard-event-handler.ts | 12 ++---------- .../create-repository-modal.component.ts | 3 +-- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/zeppelin-web-angular/src/app/app.module.ts b/zeppelin-web-angular/src/app/app.module.ts index af099ac17e5..a630b2d9be5 100644 --- a/zeppelin-web-angular/src/app/app.module.ts +++ b/zeppelin-web-angular/src/app/app.module.ts @@ -60,8 +60,7 @@ registerLocaleData(en); useValue: { defaultEditorOption: { scrollBeyondLastLine: false - // TODO: Change 'as' to 'satisfies' when typescript version is over 4.9 to detect unsupported editor options at compile time. - } as JoinedEditorOptions, + } satisfies JoinedEditorOptions, onLoad: loadMonaco } }, diff --git a/zeppelin-web-angular/src/app/key-binding/notebook-paragraph-keyboard-event-handler.ts b/zeppelin-web-angular/src/app/key-binding/notebook-paragraph-keyboard-event-handler.ts index 5ebffd8fedf..3c6e8508c83 100644 --- a/zeppelin-web-angular/src/app/key-binding/notebook-paragraph-keyboard-event-handler.ts +++ b/zeppelin-web-angular/src/app/key-binding/notebook-paragraph-keyboard-event-handler.ts @@ -69,12 +69,7 @@ export const ParagraphActionToHandlerName = { [ParagraphActions.PasteLine]: 'handlePasteLine', [ParagraphActions.SearchInsideCode]: 'handleSearchInsideCode', [ParagraphActions.FindInCode]: 'handleFindInCode' -} as const; -// TODO: Replace `as const` with -// `satisfies Record` -// when typescript version is over 4.9. -// This allows checking both keys and values at the type level, -// while preserving the binding between them. +} as const satisfies Record; // Referenced only via `typeof` below to derive a type; the runtime binding is intentionally unused. // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -85,10 +80,7 @@ const MonacoHandledParagraphActions = [ ParagraphActions.CutLine, ParagraphActions.PasteLine, ParagraphActions.SearchInsideCode -] as const; -// TODO: Replace `as const` with `satisfies ParagraphActions[]` when typescript version is over 4.9. -// This ensures that the array contains only valid ParagraphActions, -// while preserving the literal value of the each element. +] as const satisfies ParagraphActions[]; type MonacoHandledParagraphAction = (typeof MonacoHandledParagraphActions)[number]; diff --git a/zeppelin-web-angular/src/app/pages/workspace/interpreter/create-repository-modal/create-repository-modal.component.ts b/zeppelin-web-angular/src/app/pages/workspace/interpreter/create-repository-modal/create-repository-modal.component.ts index e254d6870dc..0813facdcd6 100644 --- a/zeppelin-web-angular/src/app/pages/workspace/interpreter/create-repository-modal/create-repository-modal.component.ts +++ b/zeppelin-web-angular/src/app/pages/workspace/interpreter/create-repository-modal/create-repository-modal.component.ts @@ -73,7 +73,6 @@ export class InterpreterCreateRepositoryModalComponent extends DestroyHookCompon ], proxyLogin: '', proxyPassword: '' - // TODO: Change 'as' to 'satisfies' when typescript version is over 4.9 to detect unsupported editor options at compile time. - } as Record); + } satisfies Record); } }