Skip to content

Commit 8c11a35

Browse files
committed
🔧 fix: #1409, #1425
1 parent 5d84d0a commit 8c11a35

File tree

8 files changed

+144
-122
lines changed

8 files changed

+144
-122
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ Improvement:
33
- [#1406](https://github.com/elysiajs/elysia/issues/1406) strictly check for 200 inline status code
44
- coerce union status value and return type
55
- add `BunHTMLBundleLike` to Elysia inline handler
6+
- prevent Elysia from being a dependency of itself
7+
- [#1425](https://github.com/elysiajs/elysia/issues/1425) DELETE doesn't ihnerit derive/resolve type
8+
9+
Change:
10+
- [#1409](https://github.com/elysiajs/elysia/issues/1409) onTransform now doesn't include type as it isn't validated yet, creating confusion
611

712
Bug fix:
813
- [#1410](https://github.com/elysiajs/elysia/issues/1410) handle union derive/resolve property
914
- probably fix mergeDeep attempted to assign to readonly property
15+
- derive/resolve inherit type in inline handler
1016

1117
# 1.4.5 - 15 Sep 2025
1218
Improvement:

build.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { $ } from 'bun'
22
import { build, type Options } from 'tsup'
3+
import pack from './package.json'
4+
5+
if ('elysia' in pack.dependencies)
6+
throw new Error("Error can't be a dependency of itself")
37

48
const external = ['@sinclair/typebox', 'file-type']
59

bun.lock

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
"name": "elysia",
66
"dependencies": {
77
"cookie": "^1.0.2",
8-
"elysia": "1.4.3-beta.0",
98
"exact-mirror": "0.2.2",
109
"fast-decode-uri-component": "^1.0.1",
1110
},
1211
"devDependencies": {
13-
"@elysiajs/openapi": "^1.3.11",
12+
"@elysiajs/openapi": "^1.4.1",
1413
"@types/bun": "^1.2.12",
1514
"@types/cookie": "^1.0.0",
1615
"@types/fast-decode-uri-component": "^1.0.0",
@@ -47,7 +46,7 @@
4746

4847
"@ark/util": ["@ark/util@0.49.0", "", {}, "sha512-/BtnX7oCjNkxi2vi6y1399b+9xd1jnCrDYhZ61f0a+3X8x8DxlK52VgEEzyuC2UQMPACIfYrmHkhD3lGt2GaMA=="],
4948

50-
"@elysiajs/openapi": ["@elysiajs/openapi@1.3.11", "", { "dependencies": { "@sinclair/typemap": "^0.10.1", "openapi-types": "^12.1.3" }, "peerDependencies": { "elysia": ">= 1.3.0" } }, "sha512-+jwAEIDbIGmSKjl/kePwdDaHFgsIX/cEpw01sSjzm7SosjwZuQjJDVgDCab2p68lIO+VUOsvkKuP+5Sm5ehCvQ=="],
49+
"@elysiajs/openapi": ["@elysiajs/openapi@1.4.2", "", { "peerDependencies": { "elysia": ">= 1.4.0" } }, "sha512-i+9YYVmX9Qx40dGRI9DE9zZJrEo4qXo5h2lfuxf1WuQZKYY8RonnYQZYbdWr/Azs8upTfIdyCifgjfu3Cht8rw=="],
5150

5251
"@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.25.4", "", { "os": "aix", "cpu": "ppc64" }, "sha512-1VCICWypeQKhVbE9oW/sJaAmjLxhVqacdkvPLEjwlttjfwENRSClS8EjBz0KzRyFSCPDIkuXW34Je/vk7zdB7Q=="],
5352

@@ -189,8 +188,6 @@
189188

190189
"@sinclair/typebox": ["@sinclair/typebox@0.34.41", "", {}, "sha512-6gS8pZzSXdyRHTIqoqSVknxolr1kzfy4/CeDnrzsVz8TTIWUbOBr6gnzOmTYJ3eXQNh4IYHIGi5aIL7sOZ2G/g=="],
191190

192-
"@sinclair/typemap": ["@sinclair/typemap@0.10.1", "", { "peerDependencies": { "@sinclair/typebox": "^0.34.30", "valibot": "^1.0.0", "zod": "^3.24.1" } }, "sha512-UXR0fhu/n3c9B6lB+SLI5t1eVpt9i9CdDrp2TajRe3LbKiUhCTZN2kSfJhjPnpc3I59jMRIhgew7+0HlMi08mg=="],
193-
194191
"@tokenizer/inflate": ["@tokenizer/inflate@0.2.7", "", { "dependencies": { "debug": "^4.4.0", "fflate": "^0.8.2", "token-types": "^6.0.0" } }, "sha512-MADQgmZT1eKjp06jpI2yozxaU9uVs4GzzgSL+uEq7bVcJ9V1ZXQkeGNql1fsSI0gMy1vhvNTNbUqrx+pZfJVmg=="],
195192

196193
"@tokenizer/token": ["@tokenizer/token@0.3.0", "", {}, "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A=="],

example/a.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,2 @@
1-
import { Elysia } from '../src'
2-
3-
export interface AuthData {
4-
id: number
5-
}
6-
7-
const a = new Elysia().decorate({
8-
thing: {
9-
a: []
10-
}
11-
})
12-
13-
const b = new Elysia()
14-
.decorate({
15-
thing: {
16-
a: ''
17-
}
18-
})
19-
.use(a)
20-
.listen(3000)
1+
import { Elysia, t } from '../src'
2+
import { openapi } from '@elysiajs/openapi'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
"fast-decode-uri-component": "^1.0.1"
189189
},
190190
"devDependencies": {
191-
"@elysiajs/openapi": "^1.3.11",
191+
"@elysiajs/openapi": "^1.4.1",
192192
"@types/bun": "^1.2.12",
193193
"@types/cookie": "^1.0.0",
194194
"@types/fast-decode-uri-component": "^1.0.0",

src/index.ts

Lines changed: 36 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ import type {
164164
MacroProperty,
165165
MaybeValueOrVoidFunction,
166166
IntersectIfObject,
167-
IntersectIfObjectSchema
167+
IntersectIfObjectSchema,
168+
EmptyRouteSchema,
169+
UnknownRouteSchema
168170
} from './types'
169171

170172
export type AnyElysia = Elysia<any, any, any, any, any, any, any>
@@ -1285,9 +1287,9 @@ export default class Elysia<
12851287
Ephemeral['standaloneSchema'] &
12861288
Volatile['standaloneSchema'] &
12871289
'global' extends Type
1288-
? { params: Record<string, string> }
1290+
? { params: { [name: string]: string | undefined } }
12891291
: 'scoped' extends Type
1290-
? { params: Record<string, string> }
1292+
? { params: { [name: string]: string | undefined } }
12911293
: {},
12921294
'global' extends Type
12931295
? {
@@ -1426,17 +1428,7 @@ export default class Elysia<
14261428
onTransform<const Schema extends RouteSchema>(
14271429
handler: MaybeArray<
14281430
TransformHandler<
1429-
MergeSchema<
1430-
Schema,
1431-
MergeSchema<
1432-
Volatile['schema'],
1433-
MergeSchema<Ephemeral['schema'], Metadata['schema']>
1434-
>,
1435-
BasePath
1436-
> &
1437-
Metadata['standaloneSchema'] &
1438-
Ephemeral['standaloneSchema'] &
1439-
Volatile['standaloneSchema'],
1431+
UnknownRouteSchema<ResolvePath<BasePath>>,
14401432
{
14411433
decorator: Singleton['decorator']
14421434
store: Singleton['store']
@@ -1470,22 +1462,13 @@ export default class Elysia<
14701462
options: { as: Type },
14711463
handler: MaybeArray<
14721464
TransformHandler<
1473-
MergeSchema<
1474-
Schema,
1475-
MergeSchema<
1476-
Volatile['schema'],
1477-
MergeSchema<Ephemeral['schema'], Metadata['schema']>
1478-
>,
1479-
BasePath
1480-
> &
1481-
Metadata['standaloneSchema'] &
1482-
Ephemeral['standaloneSchema'] &
1483-
Volatile['standaloneSchema'] &
1465+
UnknownRouteSchema<
14841466
'global' extends Type
1485-
? { params: Record<string, string> }
1486-
: 'scoped' extends Type
1487-
? { params: Record<string, string> }
1488-
: {},
1467+
? { [name: string]: string | undefined }
1468+
: 'scoped' extends Type
1469+
? { [name: string]: string | undefined }
1470+
: ResolvePath<BasePath>
1471+
>,
14891472
'global' extends Type
14901473
? {
14911474
decorator: Singleton['decorator']
@@ -1564,9 +1547,9 @@ export default class Elysia<
15641547
Ephemeral['standaloneSchema'] &
15651548
Volatile['standaloneSchema'] &
15661549
'global' extends Type
1567-
? { params: Record<string, string> }
1550+
? { params: { [name: string]: string | undefined } }
15681551
: 'scoped' extends Type
1569-
? { params: Record<string, string> }
1552+
? { params: { [name: string]: string | undefined } }
15701553
: {},
15711554
Singleton &
15721555
('global' extends Type
@@ -2064,9 +2047,9 @@ export default class Elysia<
20642047
Ephemeral['standaloneSchema'] &
20652048
Volatile['standaloneSchema'] &
20662049
'global' extends Type
2067-
? { params: Record<string, string> }
2050+
? { params: { [name: string]: string | undefined } }
20682051
: 'scoped' extends Type
2069-
? { params: Record<string, string> }
2052+
? { params: { [name: string]: string | undefined } }
20702053
: {},
20712054
Singleton &
20722055
('global' extends Type
@@ -2188,9 +2171,9 @@ export default class Elysia<
21882171
Ephemeral['standaloneSchema'] &
21892172
Volatile['standaloneSchema'] &
21902173
'global' extends Type
2191-
? { params: Record<string, string> }
2174+
? { params: { [name: string]: string | undefined } }
21922175
: 'scoped' extends Type
2193-
? { params: Record<string, string> }
2176+
? { params: { [name: string]: string | undefined } }
21942177
: {},
21952178
Singleton &
21962179
('global' extends Type
@@ -2434,9 +2417,9 @@ export default class Elysia<
24342417
Ephemeral['standaloneSchema'] &
24352418
Volatile['standaloneSchema'] &
24362419
'global' extends Type
2437-
? { params: Record<string, string> }
2420+
? { params: { [name: string]: string | undefined } }
24382421
: 'scoped' extends Type
2439-
? { params: Record<string, string> }
2422+
? { params: { [name: string]: string | undefined } }
24402423
: {},
24412424
Singleton &
24422425
('global' extends Type
@@ -2554,9 +2537,9 @@ export default class Elysia<
25542537
Ephemeral['standaloneSchema'] &
25552538
Volatile['standaloneSchema'] &
25562539
'global' extends Type
2557-
? { params: Record<string, string> }
2540+
? { params: { [name: string]: string | undefined } }
25582541
: 'scoped' extends Type
2559-
? { params: Record<string, string> }
2542+
? { params: { [name: string]: string | undefined } }
25602543
: {},
25612544
Singleton &
25622545
('global' extends Type
@@ -2725,9 +2708,9 @@ export default class Elysia<
27252708
Ephemeral['standaloneSchema'] &
27262709
Volatile['standaloneSchema'] &
27272710
'global' extends Type
2728-
? { params: Record<string, string> }
2711+
? { params: { [name: string]: string | undefined } }
27292712
: 'scoped' extends Type
2730-
? { params: Record<string, string> }
2713+
? { params: { [name: string]: string | undefined } }
27312714
: {},
27322715
Singleton &
27332716
('global' extends Type
@@ -2838,9 +2821,9 @@ export default class Elysia<
28382821
Ephemeral['standaloneSchema'] &
28392822
Volatile['standaloneSchema'] &
28402823
'global' extends Type
2841-
? { params: Record<string, string> }
2824+
? { params: { [name: string]: string | undefined } }
28422825
: 'scoped' extends Type
2843-
? { params: Record<string, string> }
2826+
? { params: { [name: string]: string | undefined } }
28442827
: {},
28452828
Singleton &
28462829
('global' extends Type
@@ -5954,6 +5937,7 @@ export default class Elysia<
59545937
Input,
59555938
// @ts-ignore
59565939
Schema & MacroContext,
5940+
Decorator,
59575941
Definitions['error'],
59585942
keyof Metadata['parser']
59595943
>
@@ -6058,6 +6042,7 @@ export default class Elysia<
60586042
Input,
60596043
// @ts-ignore
60606044
Schema & MacroContext,
6045+
Decorator,
60616046
Definitions['error'],
60626047
keyof Metadata['parser']
60636048
>
@@ -6162,6 +6147,7 @@ export default class Elysia<
61626147
Input,
61636148
// @ts-ignore
61646149
Schema & MacroContext,
6150+
Decorator,
61656151
Definitions['error'],
61666152
keyof Metadata['parser']
61676153
>
@@ -6266,6 +6252,7 @@ export default class Elysia<
62666252
Input,
62676253
// @ts-ignore
62686254
Schema & MacroContext,
6255+
Decorator,
62696256
Definitions['error'],
62706257
keyof Metadata['parser']
62716258
>
@@ -6370,6 +6357,7 @@ export default class Elysia<
63706357
Input,
63716358
// @ts-ignore
63726359
Schema & MacroContext,
6360+
Decorator,
63736361
Definitions['error'],
63746362
keyof Metadata['parser']
63756363
>
@@ -6474,6 +6462,7 @@ export default class Elysia<
64746462
Input,
64756463
// @ts-ignore
64766464
Schema & MacroContext,
6465+
Decorator,
64776466
Definitions['error'],
64786467
keyof Metadata['parser']
64796468
>
@@ -6578,6 +6567,7 @@ export default class Elysia<
65786567
Input,
65796568
// @ts-ignore
65806569
Schema & MacroContext,
6570+
Decorator,
65816571
Definitions['error'],
65826572
keyof Metadata['parser']
65836573
>
@@ -6684,6 +6674,7 @@ export default class Elysia<
66846674
Input,
66856675
// @ts-ignore
66866676
Schema & MacroContext,
6677+
Decorator,
66876678
Definitions['error'],
66886679
keyof Metadata['parser']
66896680
> & {
@@ -7458,9 +7449,9 @@ export default class Elysia<
74587449
Ephemeral['standaloneSchema'] &
74597450
Volatile['standaloneSchema'] &
74607451
'global' extends Type
7461-
? { params: Record<string, string> }
7452+
? { params: { [name: string]: string | undefined } }
74627453
: 'scoped' extends Type
7463-
? { params: Record<string, string> }
7454+
? { params: { [name: string]: string | undefined } }
74647455
: {},
74657456
Singleton &
74667457
('global' extends Type

src/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,6 +2042,17 @@ export interface EmptyRouteSchema {
20422042
response: unknown
20432043
}
20442044

2045+
export interface UnknownRouteSchema<
2046+
Params = { [name: string]: string | undefined }
2047+
> {
2048+
body: unknown
2049+
headers: { [name: string]: string | undefined }
2050+
query: { [name: string]: string | undefined }
2051+
params: Params
2052+
cookie: {}
2053+
response: unknown
2054+
}
2055+
20452056
type Extract200<T> = T extends AnyElysiaCustomStatusResponse
20462057
?
20472058
| Exclude<T, AnyElysiaCustomStatusResponse>

0 commit comments

Comments
 (0)