import { FunctionalComponent, expectError, expectType, Component } from './index' // simple function signature const Foo = (props: { foo: number }) => props.foo // TSX expectType() expectType() expectType() // @ts-expect-error expectError() // @ts-expect-error expectError() // @ts-expect-error expectError() // 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 expectError(emit('nope')) // @ts-expect-error expectError(emit('update')) // @ts-expect-error expectError(emit('update', 'nope')) } // assigning runtime options Bar.props = { foo: Number } // @ts-expect-error expectError((Bar.props = { foo: String })) Bar.emits = { update: value => value > 1 } // @ts-expect-error expectError((Bar.emits = { baz: () => void 0 })) // TSX expectType() // @ts-expect-error expectError() // @ts-expect-error expectError() // @ts-expect-error expectError() 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)