Skip to content

Fix TypeScript compilation errors in adapters - add AuthService type parameter#592

Merged
hotlong merged 2 commits intomainfrom
copilot/fix-build-and-test
Feb 10, 2026
Merged

Fix TypeScript compilation errors in adapters - add AuthService type parameter#592
hotlong merged 2 commits intomainfrom
copilot/fix-build-and-test

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 10, 2026

TypeScript compilation failed in Hono, Next.js, and NestJS adapters because kernel.getService('auth') returned {} without a type parameter, preventing access to handleRequest().

Changes

  • Added AuthService interface defining handleRequest(request: Request): Promise<Response>
  • Updated getService() calls to use type parameter: getService<AuthService>('auth')

Example

// Before - TypeScript error: Property 'handleRequest' does not exist on type '{}'
const authService = kernel.getService('auth');
if (authService && typeof authService.handleRequest === 'function') {
  const response = await authService.handleRequest(req);
}

// After - properly typed
const authService = kernel.getService<AuthService>('auth');
if (authService && typeof authService.handleRequest === 'function') {
  const response = await authService.handleRequest(req);
}

Note

The AuthService interface is currently duplicated across the three adapters. Consider extracting to a shared types package in a follow-up.

Original prompt

fix build and test

The user has attached the following file paths as relevant context:

  • .github/copilot-instructions.md

Created from VS Code.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectstack-play Canceled Canceled Feb 10, 2026 2:56pm
spec Canceled Canceled Feb 10, 2026 2:56pm

Request Review

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix build and test issues Fix TypeScript compilation errors in adapters - add AuthService type parameter Feb 10, 2026
Copilot AI requested a review from hotlong February 10, 2026 14:52
@hotlong hotlong marked this pull request as ready for review February 10, 2026 15:01
Copilot AI review requested due to automatic review settings February 10, 2026 15:01
@hotlong hotlong merged commit 5270146 into main Feb 10, 2026
5 checks passed
Copy link
Copy Markdown
Contributor

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

This PR fixes TypeScript compilation issues in the Hono, Next.js, and NestJS adapters by adding a local AuthService interface and using it as the type parameter to kernel.getService<AuthService>('auth'), enabling type-safe access to handleRequest().

Changes:

  • Added an AuthService interface (per adapter) defining handleRequest(request: Request): Promise<Response>.
  • Updated auth service lookups to getService<AuthService>('auth') in all three adapters.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/adapters/nextjs/src/index.ts Adds local AuthService type and uses typed getService<AuthService>('auth') for auth handling.
packages/adapters/nestjs/src/index.ts Adds local AuthService type and uses typed getService<AuthService>('auth') in the controller auth route.
packages/adapters/hono/src/index.ts Adds local AuthService type and uses typed getService<AuthService>('auth') in the auth route.

Comment on lines 71 to 74
// Try AuthPlugin service first (preferred path)
const authService = typeof options.kernel.getService === 'function'
? options.kernel.getService('auth')
? options.kernel.getService<AuthService>('auth')
: null;
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

ObjectKernel.getService() throws when a service is missing (it does not return null/undefined). As written, calling getService<AuthService>('auth') will throw when the auth plugin/service isn’t registered, and the code will jump to the outer catch and return a 500, never reaching the legacy dispatcher fallback. Consider wrapping the getService call in a try/catch that treats the specific "service not found" error as a null authService so the fallback path can run.

Copilot uses AI. Check for mistakes.
Comment on lines 117 to 120
const kernel = this.service.getKernel();
const authService = typeof kernel.getService === 'function'
? kernel.getService('auth')
? kernel.getService<AuthService>('auth')
: null;
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

ObjectKernel.getService() throws when a service is missing. If the auth plugin/service isn’t registered, getService<AuthService>('auth') will throw and the handler will return a 500 from the catch block, never reaching the legacy dispatcher.handleAuth(...) fallback. Wrap the getService lookup in a try/catch and treat the "service not found" case as null so the fallback can execute.

Copilot uses AI. Check for mistakes.
Comment on lines 76 to 80
// Try AuthPlugin service first (preferred path)
const authService = typeof options.kernel.getService === 'function'
? options.kernel.getService('auth')
? options.kernel.getService<AuthService>('auth')
: null;

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

ObjectKernel.getService() throws when a service is missing. If the auth plugin/service isn’t registered, getService<AuthService>('auth') will throw and the route will return a 500 from the catch block, never reaching the legacy dispatcher.handleAuth(...) fallback. Wrap the getService call in a try/catch and treat the "service not found" case as null so fallback behavior works.

Copilot uses AI. Check for mistakes.
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