test: add test case for #12778

This commit is contained in:
Evan You 2022-11-09 17:35:45 +08:00
parent f7db7f361b
commit 5aed733ab6

View File

@ -1,4 +1,4 @@
import { VNode, defineComponent, ref } from '../../index'
import { VNode, defineComponent, ref, RenderContext } from '../../index'
import { expectType } from '../utils'
expectType<VNode>(<div />)
@ -25,7 +25,13 @@ expectType<JSX.Element>(<div ref="bar" />)
// allow Ref type type on arbitrary element
const fooRef = ref<HTMLElement>()
expectType<JSX.Element>(<div ref={fooRef} />)
expectType<JSX.Element>(<div ref={(el) => {fooRef.value = el as HTMLElement}} />)
expectType<JSX.Element>(
<div
ref={el => {
fooRef.value = el as HTMLElement
}}
/>
)
expectType<JSX.Element>(
<input
@ -56,5 +62,8 @@ const Foo = defineComponent({
// working
;<Foo bar={1} />
;<Foo bar={1} foo="baz" />
;<div slot="x" />
export default ({ data }: RenderContext) => {
return <button {...data} />
}