types: use unknown
This commit is contained in:
parent
1cfa2da78a
commit
5aa42f137f
@ -12,7 +12,7 @@ import { PROPS, DYNAMIC_SLOTS, FULL_PROPS } from './patchFlags'
|
|||||||
import { Slots } from './componentSlots'
|
import { Slots } from './componentSlots'
|
||||||
import { STATEFUL_COMPONENT } from './typeFlags'
|
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
|
// public properties exposed on the proxy, which is used as the render context
|
||||||
// in templates (as `this` in the render option)
|
// in templates (as `this` in the render option)
|
||||||
@ -24,7 +24,7 @@ export type ComponentRenderProxy<P = {}, S = {}, PublicProps = P> = {
|
|||||||
$slots: Data
|
$slots: Data
|
||||||
$root: ComponentInstance | null
|
$root: ComponentInstance | null
|
||||||
$parent: ComponentInstance | null
|
$parent: ComponentInstance | null
|
||||||
$emit: (event: string, ...args: any[]) => void
|
$emit: (event: string, ...args: unknown[]) => void
|
||||||
} & P &
|
} & P &
|
||||||
S
|
S
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ interface ComponentOptionsWithoutProps<Props = Data, RawBindings = Data> {
|
|||||||
interface ComponentOptionsWithArrayProps<
|
interface ComponentOptionsWithArrayProps<
|
||||||
PropNames extends string = string,
|
PropNames extends string = string,
|
||||||
RawBindings = Data,
|
RawBindings = Data,
|
||||||
Props = { [key in PropNames]?: any }
|
Props = { [key in PropNames]?: unknown }
|
||||||
> {
|
> {
|
||||||
props: PropNames[]
|
props: PropNames[]
|
||||||
setup?: SetupFunction<Props, RawBindings>
|
setup?: SetupFunction<Props, RawBindings>
|
||||||
@ -99,7 +99,7 @@ interface SetupContext {
|
|||||||
refs: Data
|
refs: Data
|
||||||
parent: ComponentInstance | null
|
parent: ComponentInstance | null
|
||||||
root: ComponentInstance
|
root: ComponentInstance
|
||||||
emit: ((event: string, ...args: any[]) => void)
|
emit: ((event: string, ...args: unknown[]) => void)
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ComponentInstance<P = Data, S = Data> = {
|
export type ComponentInstance<P = Data, S = Data> = {
|
||||||
@ -127,8 +127,8 @@ export type ComponentInstance<P = Data, S = Data> = {
|
|||||||
// overload 1: direct setup function
|
// overload 1: direct setup function
|
||||||
// (uses user defined props interface)
|
// (uses user defined props interface)
|
||||||
export function createComponent<Props>(
|
export function createComponent<Props>(
|
||||||
setup: (props: Props, ctx: SetupContext) => (() => any)
|
setup: (props: Props, ctx: SetupContext) => (() => unknown)
|
||||||
): (props: Props) => any
|
): (props: Props) => unknown
|
||||||
// overload 2: object format with no props
|
// overload 2: object format with no props
|
||||||
// (uses user defined props interface)
|
// (uses user defined props interface)
|
||||||
// return type is for Vetur and TSX support
|
// return type is for Vetur and TSX support
|
||||||
@ -138,13 +138,13 @@ export function createComponent<Props, RawBindings>(
|
|||||||
new (): ComponentRenderProxy<Props, UnwrapValue<RawBindings>>
|
new (): ComponentRenderProxy<Props, UnwrapValue<RawBindings>>
|
||||||
}
|
}
|
||||||
// overload 3: object format with array props declaration
|
// 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
|
// return type is for Vetur and TSX support
|
||||||
export function createComponent<PropNames extends string, RawBindings>(
|
export function createComponent<PropNames extends string, RawBindings>(
|
||||||
options: ComponentOptionsWithArrayProps<PropNames, RawBindings>
|
options: ComponentOptionsWithArrayProps<PropNames, RawBindings>
|
||||||
): {
|
): {
|
||||||
new (): ComponentRenderProxy<
|
new (): ComponentRenderProxy<
|
||||||
{ [key in PropNames]?: any },
|
{ [key in PropNames]?: unknown },
|
||||||
UnwrapValue<RawBindings>
|
UnwrapValue<RawBindings>
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ export function createComponentInstance(
|
|||||||
slots: EMPTY_OBJ,
|
slots: EMPTY_OBJ,
|
||||||
refs: EMPTY_OBJ,
|
refs: EMPTY_OBJ,
|
||||||
|
|
||||||
emit: (event: string, ...args: any[]) => {
|
emit: (event: string, ...args: unknown[]) => {
|
||||||
const props = instance.vnode.props || EMPTY_OBJ
|
const props = instance.vnode.props || EMPTY_OBJ
|
||||||
const handler = props[`on${event}`] || props[`on${capitalize(event)}`]
|
const handler = props[`on${event}`] || props[`on${capitalize(event)}`]
|
||||||
if (handler) {
|
if (handler) {
|
||||||
|
Loading…
Reference in New Issue
Block a user