mirror of
https://github.com/honojs/hono.git
synced 2024-11-21 18:18:57 +01:00
fix(client): set Path as the default of Original (#3058)
This commit is contained in:
parent
2d3bc55954
commit
1d16b84b62
@ -23,3 +23,37 @@ describe('WebSockets', () => {
|
||||
>().toEqualTypeOf(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('without the leading slash', () => {
|
||||
const app = new Hono()
|
||||
.get('foo', (c) => c.json({}))
|
||||
.get('foo/bar', (c) => c.json({}))
|
||||
.get('foo/:id/baz', (c) => c.json({}))
|
||||
const client = hc<typeof app>('')
|
||||
it('`foo` should have `$get`', () => {
|
||||
expectTypeOf(client.foo).toHaveProperty('$get')
|
||||
})
|
||||
it('`foo.bar` should not have `$get`', () => {
|
||||
expectTypeOf(client.foo.bar).toHaveProperty('$get')
|
||||
})
|
||||
it('`foo[":id"].baz` should have `$get`', () => {
|
||||
expectTypeOf(client.foo[':id'].baz).toHaveProperty('$get')
|
||||
})
|
||||
})
|
||||
|
||||
describe('with the leading slash', () => {
|
||||
const app = new Hono()
|
||||
.get('/foo', (c) => c.json({}))
|
||||
.get('/foo/bar', (c) => c.json({}))
|
||||
.get('/foo/:id/baz', (c) => c.json({}))
|
||||
const client = hc<typeof app>('')
|
||||
it('`foo` should have `$get`', () => {
|
||||
expectTypeOf(client.foo).toHaveProperty('$get')
|
||||
})
|
||||
it('`foo.bar` should not have `$get`', () => {
|
||||
expectTypeOf(client.foo.bar).toHaveProperty('$get')
|
||||
})
|
||||
it('`foo[":id"].baz` should have `$get`', () => {
|
||||
expectTypeOf(client.foo[':id'].baz).toHaveProperty('$get')
|
||||
})
|
||||
})
|
||||
|
@ -146,7 +146,7 @@ export type InferRequestOptionsType<T> = T extends (
|
||||
type PathToChain<
|
||||
Path extends string,
|
||||
E extends Schema,
|
||||
Original extends string = ''
|
||||
Original extends string = Path
|
||||
> = Path extends `/${infer P}`
|
||||
? PathToChain<P, E, Path>
|
||||
: Path extends `${infer P}/${infer R}`
|
||||
|
Loading…
Reference in New Issue
Block a user