Skip to content

Commit 1534ffa

Browse files
authored
fix(factory): keep independent return types for nine handlers (#5618)
1 parent eb754bd commit 1534ffa

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

‎src/helper/factory/index.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,22 @@ describe('createHandler', () => {
356356
expectTypeOf<Handler1Output>().toEqualTypeOf<{ first: number }>()
357357
expectTypeOf<Handler2Output>().toEqualTypeOf<{ second: 'second' }>()
358358
})
359+
360+
it('Should keep independent return types for nine handlers', () => {
361+
const [first, , , , , , , , ninth] = factory.createHandlers(
362+
(c) => c.json({ first: 1 }),
363+
(c) => c.json({ second: 2 }),
364+
(c) => c.json({ third: 3 }),
365+
(c) => c.json({ fourth: 4 }),
366+
(c) => c.json({ fifth: 5 }),
367+
(c) => c.json({ sixth: 6 }),
368+
(c) => c.json({ seventh: 7 }),
369+
(c) => c.json({ eighth: 8 }),
370+
(c) => c.json({ ninth: 'ninth' as const })
371+
)
372+
expectTypeOf<ExtractOutput<typeof first>>().toEqualTypeOf<{ first: number }>()
373+
expectTypeOf<ExtractOutput<typeof ninth>>().toEqualTypeOf<{ ninth: 'ninth' }>()
374+
})
359375
})
360376
})
361377

‎src/helper/factory/index.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,14 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
262262
handler9: H<E10, P, I9, R9>
263263
): [
264264
H<E2, P, I, R>,
265-
H<E3, P, I2, R>,
266-
H<E4, P, I3, R>,
267-
H<E5, P, I4, R>,
268-
H<E6, P, I5, R>,
269-
H<E7, P, I6, R>,
270-
H<E8, P, I7, R>,
271-
H<E9, P, I8, R>,
272-
H<E10, P, I9, R>,
265+
H<E3, P, I2, R2>,
266+
H<E4, P, I3, R3>,
267+
H<E5, P, I4, R4>,
268+
H<E6, P, I5, R5>,
269+
H<E7, P, I6, R6>,
270+
H<E8, P, I7, R7>,
271+
H<E9, P, I8, R8>,
272+
H<E10, P, I9, R9>,
273273
]
274274

275275
// handler x10

0 commit comments

Comments
 (0)