From e72787968fd19f56e5d7cbbc5637b5872e5a2a4a Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Sun, 9 Jun 2024 07:57:18 +0900 Subject: [PATCH] fix(jsx): rename `Hono` to `JSX` and export `JSX` namespace (#2937) * fix(jsx): rename `Hono` to `JSX` and export `JSX` namespace * export as type --- src/jsx/base.ts | 7 +++++-- src/jsx/index.ts | 2 ++ src/jsx/intrinsic-elements.ts | 4 ++-- src/jsx/types.ts | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/jsx/base.ts b/src/jsx/base.ts index 684edfbe8..36b430545 100644 --- a/src/jsx/base.ts +++ b/src/jsx/base.ts @@ -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 @@ -13,7 +16,7 @@ export type FC

= { defaultProps?: Partial

| 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 { diff --git a/src/jsx/index.ts b/src/jsx/index.ts index 8d233ea27..194a45c03 100644 --- a/src/jsx/index.ts +++ b/src/jsx/index.ts @@ -103,3 +103,5 @@ export default { } export type * from './types' + +export type { JSX } from './intrinsic-elements' diff --git a/src/jsx/intrinsic-elements.ts b/src/jsx/intrinsic-elements.ts index 67caba334..7f0bd12a3 100644 --- a/src/jsx/intrinsic-elements.ts +++ b/src/jsx/intrinsic-elements.ts @@ -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 } @@ -726,4 +726,4 @@ export namespace Hono { } } -export interface IntrinsicElements extends Hono.IntrinsicElements {} +export interface IntrinsicElements extends JSX.IntrinsicElements {} diff --git a/src/jsx/types.ts b/src/jsx/types.ts index 552ae6ad6..14a402163 100644 --- a/src/jsx/types.ts +++ b/src/jsx/types.ts @@ -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 & { children?: Child | undefined } -export type CSSProperties = Hono.CSSProperties +export type CSSProperties = JSX.CSSProperties /** * React types