Skip to content

fix(auth): make RepoScopeGuard's AuthenticatedRequest type-check and drop unused ROLES_KEY (#495) - #695

Merged
chonilius merged 2 commits into
MergeFi:mainfrom
choniszn1:fix/495-repo-scope-guard-types
Oct 15, 2026
Merged

chonilius merged 2 commits into
MergeFi:mainfrom
choniszn1:fix/495-repo-scope-guard-types

Conversation

@choniszn1

@choniszn1 choniszn1 commented Oct 15, 2026 •

Copy link
Copy Markdown

Problem

src/auth/guards/repo-scope.guard.ts, the per-repository sync guard from #312, failed both the type check and lint:

src/auth/guards/repo-scope.guard.ts(20,11): error TS2430: Interface 'AuthenticatedRequest' incorrectly extends interface 'Request<ParamsDictionary, ...>'

AuthenticatedRequest extended express.Request and redeclared params?: { owner?: string; repo?: string }. Express declares params as a required ParamsDictionary, so making it optional is not a valid subtype, and tsc rejects the interface. ESLint also reported ROLES_KEY as imported but never used (no-unused-vars, error). Together these keep tsc and eslint red for the whole project.

What changed

  1. fix(auth): the route params are now typed through Express's own generic instead of redeclaring the property:
    interface AuthenticatedRequest extends Request<{ owner?: string; repo?: string }> {
      user?: { userId: string };
    }
    request.params.owner / .repo keep the same narrow types, and the guard's logic doesn't change. The existing request.params?.owner reads still compile.
  2. chore(auth): removes the unused ROLES_KEY import. It also runs eslint --fix on the same file to clear four Prettier formatting errors that were already on main (line wrapping only, no behaviour change), so the file now lints clean.

Verification

  • npx tsc --noEmit: no errors in repo-scope.guard.ts. TS2430 is gone.
  • npx eslint src/auth/guards/repo-scope.guard.ts: clean.
  • npx jest src/auth/guards: 14/14 passed.

Related: #312

Closes #495
Closes #496
Closes #493
Closes #494

Redeclaring params as optional conflicted with express.Request's
required ParamsDictionary (TS2430).
)

Also applies prettier --fix to the file so it lints clean.
@vercel

vercel Bot commented Oct 15, 2026

Copy link
Copy Markdown

@choniszn1 is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 15, 2026

Copy link
Copy Markdown

@choniszn1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@chonilius
chonilius merged commit b4e5b47 into MergeFi:main Oct 15, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment