Skip to content

[ZEPPELIN-6441] Replace outdated type assertions with satisfies#5323

Open
kimyenac wants to merge 1 commit into
apache:masterfrom
kimyenac:ZEPPELIN-6441
Open

[ZEPPELIN-6441] Replace outdated type assertions with satisfies#5323
kimyenac wants to merge 1 commit into
apache:masterfrom
kimyenac:ZEPPELIN-6441

Conversation

@kimyenac

Copy link
Copy Markdown
Contributor

What is this PR for?

The Angular UI now uses TypeScript ~5.9.3, so the pre-4.9 workaround TODOs that asked to replace broad type assertions with satisfies are obsolete. This replaces those outdated assertions with satisfies, which improves compile-time checking without changing runtime behavior.

  • app.module.ts: as JoinedEditorOptionssatisfies 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 constas const satisfies ... for both the action→handler map and the Monaco-handled action list. as const is intentionally kept so the downstream typeof-based literal indexing still narrows correctly, while satisfies now validates keys/values (e.g. invalid handler names are rejected).

All three changes are compile-time-only annotations; runtime behavior is unchanged.

What type of PR is it?

Improvement

What is the Jira issue?

ZEPPELIN-6441

How should this be tested?

  • cd zeppelin-web-angular && npm run lint passes (0 errors).
  • Verified the satisfies checks are active: injecting an unsupported editor option is caught as TS2353, and an invalid handler name is caught as TS2418.

Questions:

  • Does the license files need to update? No
  • Is there breaking changes for older versions? No
  • Does this need documentation? No

🤖 Generated with Claude Code

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) <noreply@anthropic.com>

@tbonelee tbonelee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice cleanup of the obsolete pre-4.9 TODOs.

Ran tsc --noEmit -p src/tsconfig.json with the changes applied: 0 errors. Also confirmed the satisfies checks are actually enforced (injecting an invalid handler name fails with TS2418), and the Record<ParagraphActions, ...> passing means the full enum is covered. as const satisfies keeps the downstream typeof narrowing intact. Compile-time only, no runtime change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants