Skip to content

Commit

Permalink
fix(jsx): rename Hono to JSX and export JSX namespace (#2937)
Browse files Browse the repository at this point in the history
* fix(jsx): rename `Hono` to `JSX` and export `JSX` namespace

* export as type
  • Loading branch information
yusukebe authored Jun 8, 2024
1 parent 1a32ef4 commit e727879
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/jsx/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { escapeToBuffer, stringBufferToString } from '../utils/html'
import type { HtmlEscaped, HtmlEscapedString, StringBuffer } from '../utils/html'
import type { Context } from './context'
import { globalContexts } from './context'
import type { Hono, IntrinsicElements as IntrinsicElementsDefined } from './intrinsic-elements'
import type {
JSX as HonoJSX,
IntrinsicElements as IntrinsicElementsDefined,
} from './intrinsic-elements'
import { normalizeIntrinsicElementProps, styleObjectForEach } from './utils'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -13,7 +16,7 @@ export type FC<P = Props> = {
defaultProps?: Partial<P> | undefined
displayName?: string | undefined
}
export type DOMAttributes = Hono.HTMLAttributes
export type DOMAttributes = HonoJSX.HTMLAttributes

// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace JSX {
Expand Down
2 changes: 2 additions & 0 deletions src/jsx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,5 @@ export default {
}

export type * from './types'

export type { JSX } from './intrinsic-elements'
4 changes: 2 additions & 2 deletions src/jsx/intrinsic-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Hono {
export namespace JSX {
export type CrossOrigin = 'anonymous' | 'use-credentials' | '' | undefined
export type CSSProperties = {}
type AnyAttributes = { [attributeName: string]: any }
Expand Down Expand Up @@ -726,4 +726,4 @@ export namespace Hono {
}
}

export interface IntrinsicElements extends Hono.IntrinsicElements {}
export interface IntrinsicElements extends JSX.IntrinsicElements {}
4 changes: 2 additions & 2 deletions src/jsx/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* All types exported from "hono/jsx" are in this file.
*/
import type { Child, JSXNode } from './base'
import type { Hono } from './intrinsic-elements'
import type { JSX } from './intrinsic-elements'

export type { Child, JSXNode, FC } from './base'
export type { RefObject } from './hooks'
export type { Context } from './context'

export type PropsWithChildren<P = unknown> = P & { children?: Child | undefined }
export type CSSProperties = Hono.CSSProperties
export type CSSProperties = JSX.CSSProperties

/**
* React types
Expand Down

0 comments on commit e727879

Please sign in to comment.