Skip to content

Commit d46f594

Browse files
authored
Merge pull request #1319 from miello/fix/array-of-plugin-base-path
fix: array of plugin usage causes incorrect path aggregation
2 parents 2449b5d + 53678c8 commit d46f594

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,7 @@ export type MergeElysiaInstances<
17271727
Routes &
17281728
(Prefix extends ``
17291729
? Current['~Routes']
1730-
: AddPrefix<Prefix, Current['~Routes']>)
1730+
: CreateEden<Prefix, Current['~Routes']>)
17311731
>
17321732
: Elysia<
17331733
Prefix,

test/types/index.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,33 @@ app.group(
959959
}>()
960960
}
961961

962+
// ? Inherits plugin instance prefix path
963+
{
964+
const pluginPrefixApp = new Elysia({ prefix: '/app' }).get('/test', () => 'hello')
965+
966+
const appWithArrayOfPlugin = new Elysia({ prefix: '/api' }).use([pluginPrefixApp])
967+
const appWithPlugin = new Elysia({ prefix: '/api' }).use(pluginPrefixApp)
968+
969+
expectTypeOf<typeof appWithArrayOfPlugin['~Routes']>().toEqualTypeOf<{
970+
api: {
971+
app: {
972+
test: {
973+
get: {
974+
body: unknown
975+
headers: unknown
976+
query: unknown
977+
params: Record<never, string>
978+
response: {
979+
200: string
980+
}
981+
}
982+
}
983+
},
984+
}
985+
}>()
986+
expectTypeOf<typeof appWithArrayOfPlugin['~Routes']>().toEqualTypeOf<typeof appWithPlugin['~Routes']>()
987+
}
988+
962989
// ? Inlining function callback don't repeat prefix
963990
{
964991
const test = (app: Elysia) =>

0 commit comments

Comments
 (0)