From 5aa42f137facb420d37a9dc45f85ad852982b62e Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 13 Aug 2019 11:18:23 -0400 Subject: [PATCH] types: use unknown --- packages/runtime-core/src/component.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index 13c465661..8df68a691 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -12,7 +12,7 @@ import { PROPS, DYNAMIC_SLOTS, FULL_PROPS } from './patchFlags' 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) @@ -24,7 +24,7 @@ export type ComponentRenderProxy

= { $slots: Data $root: ComponentInstance | null $parent: ComponentInstance | null - $emit: (event: string, ...args: any[]) => void + $emit: (event: string, ...args: unknown[]) => void } & P & S @@ -49,7 +49,7 @@ interface ComponentOptionsWithoutProps { interface ComponentOptionsWithArrayProps< PropNames extends string = string, RawBindings = Data, - Props = { [key in PropNames]?: any } + Props = { [key in PropNames]?: unknown } > { props: PropNames[] setup?: SetupFunction @@ -99,7 +99,7 @@ interface SetupContext { refs: Data parent: ComponentInstance | null root: ComponentInstance - emit: ((event: string, ...args: any[]) => void) + emit: ((event: string, ...args: unknown[]) => void) } export type ComponentInstance

= { @@ -127,8 +127,8 @@ export type ComponentInstance

= { // overload 1: direct setup function // (uses user defined props interface) export function createComponent( - 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 @@ -138,13 +138,13 @@ export function createComponent( new (): ComponentRenderProxy> } // 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( options: ComponentOptionsWithArrayProps ): { new (): ComponentRenderProxy< - { [key in PropNames]?: any }, + { [key in PropNames]?: unknown }, UnwrapValue > } @@ -203,7 +203,7 @@ export function createComponentInstance( 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) {