import { type Component, type FunctionalComponent, Text, type VNode, h, } from 'vue' import { expectType } from './utils' // simple function signature const Foo = (props: { foo: number }) => h(Text, null, props.foo) // TSX expectType() expectType() expectType() // @ts-expect-error ; // @ts-expect-error ; // @ts-expect-error ; // Explicit signature with props + emits const Bar: FunctionalComponent< { foo: number }, { update: (value: number) => void } > = (props, { emit }) => { expectType(props.foo) emit('update', 123) // @ts-expect-error emit('nope') // @ts-expect-error emit('update') // @ts-expect-error emit('update', 'nope') } // assigning runtime options Bar.props = { foo: Number, } // @ts-expect-error Bar.props = { foo: String } Bar.emits = { update: value => value > 1, } // @ts-expect-error Bar.emits = { baz: () => void 0 } // TSX expectType( {}} />) // @ts-expect-error ; // @ts-expect-error ; // @ts-expect-error ; const Baz: FunctionalComponent<{}, string[]> = (props, { emit }) => { expectType<{}>(props) expectType<(event: string) => void>(emit) } expectType(Baz) const Qux: FunctionalComponent<{}, ['foo', 'bar']> = (props, { emit }) => { emit('foo') emit('foo', 1, 2) emit('bar') emit('bar', 1, 2) } expectType(Qux) const Quux: FunctionalComponent< {}, {}, { default: { foo: number } optional?: { foo: number } } > = (props, { emit, slots }) => { expectType<{ default: (scope: { foo: number }) => VNode[] optional?: (scope: { foo: number }) => VNode[] }>(slots) slots.default({ foo: 123 }) // @ts-expect-error slots.default({ foo: 'fesf' }) slots.optional?.({ foo: 123 }) // @ts-expect-error slots.optional?.({ foo: 'fesf' }) // @ts-expect-error slots.optional({ foo: 123 }) } expectType(Quux) ;