import { Slots } from './componentSlots'
import { STATEFUL_COMPONENT } from './typeFlags'
-export type Data = { [key: string]: any }
+export type Data = { [key: string]: unknown }
// public properties exposed on the proxy, which is used as the render context
// in templates (as `this` in the render option)
$slots: Data
$root: ComponentInstance | null
$parent: ComponentInstance | null
- $emit: (event: string, ...args: any[]) => void
+ $emit: (event: string, ...args: unknown[]) => void
} & P &
S
interface ComponentOptionsWithArrayProps<
PropNames extends string = string,
RawBindings = Data,
- Props = { [key in PropNames]?: any }
+ Props = { [key in PropNames]?: unknown }
> {
props: PropNames[]
setup?: SetupFunction<Props, RawBindings>
refs: Data
parent: ComponentInstance | null
root: ComponentInstance
- emit: ((event: string, ...args: any[]) => void)
+ emit: ((event: string, ...args: unknown[]) => void)
}
export type ComponentInstance<P = Data, S = Data> = {
// overload 1: direct setup function
// (uses user defined props interface)
export function createComponent<Props>(
- setup: (props: Props, ctx: SetupContext) => (() => any)
-): (props: Props) => any
+ setup: (props: Props, ctx: SetupContext) => (() => unknown)
+): (props: Props) => unknown
// overload 2: object format with no props
// (uses user defined props interface)
// return type is for Vetur and TSX support
new (): ComponentRenderProxy<Props, UnwrapValue<RawBindings>>
}
// overload 3: object format with array props declaration
-// props inferred as { [key in PropNames]?: any }
+// props inferred as { [key in PropNames]?: unknown }
// return type is for Vetur and TSX support
export function createComponent<PropNames extends string, RawBindings>(
options: ComponentOptionsWithArrayProps<PropNames, RawBindings>
): {
new (): ComponentRenderProxy<
- { [key in PropNames]?: any },
+ { [key in PropNames]?: unknown },
UnwrapValue<RawBindings>
>
}
slots: EMPTY_OBJ,
refs: EMPTY_OBJ,
- emit: (event: string, ...args: any[]) => {
+ emit: (event: string, ...args: unknown[]) => {
const props = instance.vnode.props || EMPTY_OBJ
const handler = props[`on${event}`] || props[`on${capitalize(event)}`]
if (handler) {