+
Skip to content

Improve type-safety of adapter code #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2025

Conversation

jonkoops
Copy link
Contributor

@jonkoops jonkoops commented Jun 6, 2025

Improves the type-safety of the adapter code by adding JSDoc comments to most of it, and setting up the TypeScript compiler to run through them to validate correctness. This does not cover all the code, but a significant amount of code to make future refactoring more manageable.

This also converts class based instances to use the actual class syntax instead of the traditional prototype based approach, which helps with type annotations. Functionally, there is no impact to end-users, but makes it easier to refactor in the future.

The methods of the adapter are still attached in the constructor, as the code heavily relies on scoping, something which will have to be refactored in the future.

Closes #115

@jonkoops jonkoops requested review from a team and Copilot June 6, 2025 11:20
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Improves type-safety in the adapter code by adding JSDoc comments and converting prototype-based classes to use the actual class syntax. Key changes include:

  • Updating method return types to reflect possible undefined values.
  • Enhancing type annotations to support future refactoring.
  • Converting legacy prototype-based code to modern class syntax.
Comments suppressed due to low confidence (1)

test/support/test-executor.ts:240

  • Update the JSDoc comment for userInfo to mention that it can return undefined, so future maintainers understand the reasoning behind the type union.
async userInfo (): Promise<{} | undefined> {

Closes keycloak#115

Signed-off-by: Jon Koops <jonkoops@gmail.com>
@jonkoops jonkoops force-pushed the improve-type-safety branch from 7a1ae2d to 2b412cd Compare June 6, 2025 11:28
Copy link

@douglaspalmer douglaspalmer left a comment

Choose a reason for hiding this comment

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

LGTM

@jonkoops jonkoops merged commit 3a26e5b into keycloak:main Jun 16, 2025
4 checks passed
@jonkoops jonkoops deleted the improve-type-safety branch June 16, 2025 07:58
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.

Improve type-safety of code
2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载