Skip to content

fix(elysia): Widen accepted Elysia app type to support Elysia options#21164

Merged
Lms24 merged 1 commit into
developfrom
lms/fix-elysia-widen-wrapper-type
May 26, 2026
Merged

fix(elysia): Widen accepted Elysia app type to support Elysia options#21164
Lms24 merged 1 commit into
developfrom
lms/fix-elysia-widen-wrapper-type

Conversation

@Lms24
Copy link
Copy Markdown
Member

@Lms24 Lms24 commented May 26, 2026

This PR fixes a typing bug in our Sentry.withElysia wrapping API type definitions: Previously the passed app instance had to extend Elysia. This causes problems when users pass in options that rely on const string literal types (e.g. prefix as reported in #21159).

Because Elysia declares its prefix option as a string literal to extend const in out BasePath extends string = '', TS will throw an error if the option is provided by users but with a different string value than ''. The solution is to accept an app object of type AnyElysia, which is an alias for Elysia<any, any, ...>. This widens the type enough so that our wrapper can accept any kind of Elysia configuration.

As a result, we have to type-cast to the more narrow Elysia type again to get properly typed contexts on some callbacks. There is a slight chance that the context objects could in reality look a bit different than what we expect in code but this was technically the case beforehand, too. I'd say this is an okay tradeoff for now. If reviewers prefer, we can be stricter and add more checks in the callbacks to see if the properties really exist.

closes #21159

@Lms24 Lms24 self-assigned this May 26, 2026
@Lms24 Lms24 marked this pull request as ready for review May 26, 2026 09:50
@Lms24 Lms24 requested a review from a team as a code owner May 26, 2026 09:50
@Lms24 Lms24 requested review from logaretm, mydea and s1gr1d and removed request for a team May 26, 2026 09:50
@Lms24 Lms24 merged commit 5c75be7 into develop May 26, 2026
44 checks passed
@Lms24 Lms24 deleted the lms/fix-elysia-widen-wrapper-type branch May 26, 2026 11:42
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.

[@sentry/elysia] Type error when passing custom prefix to main Elysia instance

3 participants