Skip to content

Commit 7cef950

Browse files
committed
chore: add RenderReturn
1 parent da57f92 commit 7cef950

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

packages-private/dts-test/tsx.test-d.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// TSX w/ defineComponent is tested in defineComponent.test-d.tsx
22
import {
3-
type Block,
43
Fragment,
54
KeepAlive,
5+
type RenderReturn,
66
Suspense,
77
Teleport,
88
type VNode,
99
} from 'vue'
1010
import { expectType } from './utils'
1111

12-
expectType<VNode | Block>(<div />)
12+
expectType<RenderReturn>(<div />)
1313
expectType<JSX.Element>(<div />)
1414
expectType<JSX.Element>(<div id="foo" />)
1515
expectType<JSX.Element>(<div>hello</div>)

packages/runtime-vapor/src/apiDefineComponent.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export type VaporPublicProps = ReservedProps &
3232
AllowedComponentProps &
3333
ComponentCustomProps
3434

35+
export type RenderReturn = VNode | Block | ArrayRenderReturn
36+
type ArrayRenderReturn = Array<RenderReturn>
37+
3538
export type DefineVaporComponent<
3639
RuntimePropsOptions = {},
3740
RuntimePropsKeys extends string = string,
@@ -100,7 +103,7 @@ export function defineVaporComponent<
100103
attrs: Record<string, any>
101104
expose: (exposed: Exposed) => void
102105
},
103-
) => Block | VNode,
106+
) => RenderReturn,
104107
extraOptions?: ObjectVaporComponent<
105108
(keyof Props)[],
106109
Emits,
@@ -125,7 +128,7 @@ export function defineVaporComponent<
125128
attrs: Record<string, any>
126129
expose: (exposed: Exposed) => void
127130
},
128-
) => Block | VNode,
131+
) => RenderReturn,
129132
extraOptions?: ObjectVaporComponent<
130133
ComponentObjectPropsOptions<Props>,
131134
Emits,

packages/runtime-vapor/src/component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
type ObjectEmitsOptions,
1515
type ShallowUnwrapRef,
1616
type SuspenseBoundary,
17-
type VNode,
1817
callWithErrorHandling,
1918
currentInstance,
2019
endMeasure,
@@ -67,7 +66,7 @@ import {
6766
insertionParent,
6867
resetInsertionState,
6968
} from './insertionState'
70-
import type { DefineVaporComponent } from './apiDefineComponent'
69+
import type { DefineVaporComponent, RenderReturn } from './apiDefineComponent'
7170

7271
export { currentInstance } from '@vue/runtime-dom'
7372

@@ -118,7 +117,7 @@ export interface ObjectVaporComponent<
118117
emit: EmitFn<Emits>,
119118
attrs: any,
120119
slots: StaticSlots,
121-
): Block | VNode | void
120+
): RenderReturn
122121

123122
name?: string
124123
vapor?: boolean

packages/vue/jsx.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// global JSX namespace registration
33
// somehow we have to copy=pase the jsx-runtime types here to make TypeScript happy
44
import type { NativeElements, ReservedProps, VNode } from '@vue/runtime-dom'
5-
import type { Block } from '@vue/runtime-vapor'
5+
import type { RenderReturn } from '@vue/runtime-vapor'
66

77
declare global {
88
namespace JSX {
9-
export type Element = VNode | Block | Element[]
9+
export type Element = RenderReturn
1010
export interface IntrinsicElements extends NativeElements {
1111
// allow arbitrary elements
1212
// @ts-ignore suppress ts:2374 = Duplicate string index signature.

0 commit comments

Comments
 (0)