Skip to content

Commit 84e0190

Browse files
committed
🔧 fix: remove literal status response for inline value
1 parent 6e2ea51 commit 84e0190

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.2.24 - 2 Mar 2025
2+
Bug fix:
3+
- 200 object response is not inferring type in type-level
4+
-
5+
16
# 1.2.23 - 25 Feb 2025
27
Bug fix:
38
- [#1087](https://github.com/elysiajs/elysia/pull/1087) websocket to parse string array

example/a.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1-
import { Elysia, t } from '../src'
2-
import { hasTransform } from '../src/compose'
3-
import { post, req } from '../test/utils'
1+
import { Elysia, error, t } from '../src'
2+
import { req } from '../test/utils'
43

5-
import { treaty } from '../../eden'
4+
const app = new Elysia().get(
5+
'/',
6+
() => {
7+
return {
8+
name: 'a',
9+
a: 'b'
10+
}
11+
},
12+
{
13+
response: {
14+
200: t.Object({
15+
name: t.String()
16+
})
17+
}
18+
}
19+
)
20+
21+
app.handle(req('/'))
22+
.then((x) => x.json())
23+
.then(console.log)

src/types.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,7 @@ export type InlineHandler<
723723
derive: {}
724724
resolve: {}
725725
},
726-
Path extends string | undefined = undefined,
727-
MacroContext = {}
726+
Path extends string | undefined = undefined
728727
> =
729728
| ((context: Context<Route, Singleton, Path>) =>
730729
| Response
@@ -733,8 +732,9 @@ export type InlineHandler<
733732
? unknown
734733
:
735734
| (Route['response'] extends { 200: any }
736-
? Route['response']
735+
? Route['response'][200]
737736
: string | number | boolean | Object)
737+
// This could be possible because of set.status
738738
| Route['response'][keyof Route['response']]
739739
| {
740740
[Status in keyof Route['response']]: ElysiaCustomStatusResponse<
@@ -748,9 +748,8 @@ export type InlineHandler<
748748
? string | number | boolean | Object
749749
:
750750
| (Route['response'] extends { 200: any }
751-
? Route['response']
751+
? Route['response'][200]
752752
: string | number | boolean | Object)
753-
| Route['response'][keyof Route['response']]
754753
| {
755754
[Status in keyof Route['response']]: ElysiaCustomStatusResponse<
756755
// @ts-ignore Status is always a number

0 commit comments

Comments
 (0)