File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/** @jsxImportSource ./ */
22
3- import type { JSXNode } from './base'
3+ import type { Child , JSXNode } from './base'
44// eslint-disable-next-line @typescript-eslint/no-unused-vars
55import { cloneElement , jsx , Fragment } from './base'
66
@@ -43,4 +43,10 @@ describe('createElement', () => {
4343 expect ( element . type ) . toBe ( 'svg' )
4444 expect ( element . ref ) . toBe ( ref )
4545 } )
46+
47+ it ( 'should accept a Child-typed value as a child' , ( ) => {
48+ const child : Child = < span > inner</ span >
49+ const element = jsx ( 'div' , null , child ) as unknown as JSXNode
50+ expect ( element . toString ( ) ) . toBe ( '<div><span>inner</span></div>' )
51+ } )
4652} )
Original file line number Diff line number Diff line change @@ -302,11 +302,7 @@ export class JSXFragmentNode extends JSXNode {
302302 }
303303}
304304
305- export const jsx = (
306- tag : string | Function ,
307- props : Props | null ,
308- ...children : ( string | number | HtmlEscapedString ) [ ]
309- ) : JSXNode => {
305+ export const jsx = ( tag : string | Function , props : Props | null , ...children : Child [ ] ) : JSXNode => {
310306 props ??= { }
311307 if ( children . length ) {
312308 props . children = children . length === 1 ? children [ 0 ] : children
@@ -321,11 +317,7 @@ export const jsx = (
321317}
322318
323319let initDomRenderer = false
324- export const jsxFn = (
325- tag : string | Function ,
326- props : Props ,
327- children : ( string | number | HtmlEscapedString ) [ ]
328- ) : JSXNode => {
320+ export const jsxFn = ( tag : string | Function , props : Props , children : Child [ ] ) : JSXNode => {
329321 if ( ! initDomRenderer ) {
330322 for ( const k in domRenderers ) {
331323 // eslint-disable-next-line @typescript-eslint/no-explicit-any
You can’t perform that action at this time.
0 commit comments