Skip to content

Commit

Permalink
add vnode support
Browse files Browse the repository at this point in the history
  • Loading branch information
pikax committed Nov 15, 2023
1 parent bbad2f8 commit 1d40c76
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/dts-test/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ describe('with object props', () => {
props: {
myProp: {
type: Number,
validator: (val: unknown) => {
validator(val) {
// @ts-expect-error
return val !== this.otherProp
},
Expand Down
5 changes: 4 additions & 1 deletion packages/dts-test/h.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
Suspense,
Component,
resolveComponent,
ConcreteComponent
ConcreteComponent,
VNode
} from 'vue'
import { describe, expectAssignable, expectType } from './utils'

Expand Down Expand Up @@ -254,6 +255,8 @@ describe('h should work with multiple types', () => {
h(sampleComponent, {}, [])
})

// usage in test-utils
describe('should allow to assign vnode', () => {
h(h('div', 'test'))
h({} as unknown as VNode | string | { render: Function } | Component)
})
7 changes: 5 additions & 2 deletions packages/runtime-core/src/h.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,12 @@ export function h<P>(
): VNode

// catch all types
export function h(type: string | Constructor, children?: RawChildren): VNode
export function h(
type: VNode | string | Constructor,
children?: RawChildren
): VNode
export function h<P>(
type: string | Component<P>,
type: VNode | string | Component<P>,
props?: (RawProps & P) | ({} extends P ? null : never),
children?: RawChildren | RawSlots
): VNode
Expand Down

0 comments on commit 1d40c76

Please sign in to comment.