Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: honojs/hono
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.0.6
Choose a base ref
...
head repository: honojs/hono
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.0.7
Choose a head ref
  • 3 commits
  • 6 files changed
  • 2 contributors

Commits on Feb 25, 2024

  1. Copy the full SHA
    4b3cd3c View commit details
  2. fix(types): MergeSchemaPath supports regexp path params (#2271)

    * fix(types): `MergeSchemaPath` supports regexp path params
    
    * denoify
    yusukebe authored Feb 25, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1c4c395 View commit details
  3. v4.0.7

    yusukebe committed Feb 25, 2024
    Copy the full SHA
    eee1dd4 View commit details
Showing with 60 additions and 9 deletions.
  1. +2 −2 deno_dist/jsx/dom/render.ts
  2. +18 −2 deno_dist/types.ts
  3. +1 −1 package.json
  4. +2 −2 src/jsx/dom/render.ts
  5. +19 −0 src/types.test.ts
  6. +18 −2 src/types.ts
4 changes: 2 additions & 2 deletions deno_dist/jsx/dom/render.ts
Original file line number Diff line number Diff line change
@@ -2,10 +2,10 @@ import type { JSXNode } from '../base.ts'
import type { FC, Child, Props } from '../base.ts'
import { DOM_RENDERER, DOM_ERROR_HANDLER, DOM_STASH } from '../constants.ts'
import type { Context as JSXContext } from '../context.ts'
import { globalContexts as globalJSXContexts } from '../context.ts'
import { globalContexts as globalJSXContexts, useContext } from '../context.ts'
import type { EffectData } from '../hooks/index.ts'
import { STASH_EFFECT } from '../hooks/index.ts'
import { useContext, createContext } from './index.ts'
import { createContext } from './context.ts' // import dom-specific versions

const eventAliasMap: Record<string, string> = {
Change: 'Input',
20 changes: 18 additions & 2 deletions deno_dist/types.ts
Original file line number Diff line number Diff line change
@@ -1615,10 +1615,26 @@ export type MergeSchemaPath<OrigSchema extends Schema, SubPath extends string> =
input: Input extends { param: infer _ }
? ExtractParams<SubPath> extends never
? Input
: FlattenIfIntersect<Input & { param: ExtractParams<SubPath> }>
: FlattenIfIntersect<
Input & {
param: {
// Maps extracted keys, stripping braces, to a string-typed record.
[K in keyof ExtractParams<SubPath> as K extends `${infer Prefix}{${infer _}}`
? Prefix
: K]: string
}
}
>
: RemoveBlankRecord<ExtractParams<SubPath>> extends never
? Input
: Input & { param: ExtractParams<SubPath> }
: Input & {
// Maps extracted keys, stripping braces, to a string-typed record.
param: {
[K in keyof ExtractParams<SubPath> as K extends `${infer Prefix}{${infer _}}`
? Prefix
: K]: string
}
}
output: Output
}
: never
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hono",
"version": "4.0.6",
"version": "4.0.7",
"description": "Ultrafast web framework for the Edges",
"main": "dist/cjs/index.js",
"type": "module",
4 changes: 2 additions & 2 deletions src/jsx/dom/render.ts
Original file line number Diff line number Diff line change
@@ -2,10 +2,10 @@ import type { JSXNode } from '../base'
import type { FC, Child, Props } from '../base'
import { DOM_RENDERER, DOM_ERROR_HANDLER, DOM_STASH } from '../constants'
import type { Context as JSXContext } from '../context'
import { globalContexts as globalJSXContexts } from '../context'
import { globalContexts as globalJSXContexts, useContext } from '../context'
import type { EffectData } from '../hooks'
import { STASH_EFFECT } from '../hooks'
import { useContext, createContext } from '.'
import { createContext } from './context' // import dom-specific versions

const eventAliasMap: Record<string, string> = {
Change: 'Input',
19 changes: 19 additions & 0 deletions src/types.test.ts
Original file line number Diff line number Diff line change
@@ -681,6 +681,25 @@ describe('MergeSchemaPath', () => {
}
type verify = Expect<Equal<Expected, Actual>>
})

test('MergeSchemaPath - Path and SubPath have regexp path params', () => {
type Actual = MergeSchemaPath<ToSchema<'get', '/c/:d{.+}', {}, {}>, '/a/:b{.+}'>
type Expected = {
'/a/:b{.+}/c/:d{.+}': {
$get: {
input: {
param: {
d: string
} & {
b: string
}
}
output: {}
}
}
}
type verify = Expect<Equal<Expected, Actual>>
})
})

describe('Different types using json()', () => {
20 changes: 18 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1615,10 +1615,26 @@ export type MergeSchemaPath<OrigSchema extends Schema, SubPath extends string> =
input: Input extends { param: infer _ }
? ExtractParams<SubPath> extends never
? Input
: FlattenIfIntersect<Input & { param: ExtractParams<SubPath> }>
: FlattenIfIntersect<
Input & {
param: {
// Maps extracted keys, stripping braces, to a string-typed record.
[K in keyof ExtractParams<SubPath> as K extends `${infer Prefix}{${infer _}}`
? Prefix
: K]: string
}
}
>
: RemoveBlankRecord<ExtractParams<SubPath>> extends never
? Input
: Input & { param: ExtractParams<SubPath> }
: Input & {
// Maps extracted keys, stripping braces, to a string-typed record.
param: {
[K in keyof ExtractParams<SubPath> as K extends `${infer Prefix}{${infer _}}`
? Prefix
: K]: string
}
}
output: Output
}
: never