From: Evan You Date: Fri, 13 Nov 2020 05:01:44 +0000 (-0500) Subject: wip: type inference for useOptions X-Git-Tag: v3.0.3~50^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fc8d5d0ba79691b7814ecb472bd89c8a15a3d10;p=thirdparty%2Fvuejs%2Fcore.git wip: type inference for useOptions --- diff --git a/packages/runtime-core/src/helpers/useOptions.ts b/packages/runtime-core/src/helpers/useOptions.ts index 172b2aaad1..055f280784 100644 --- a/packages/runtime-core/src/helpers/useOptions.ts +++ b/packages/runtime-core/src/helpers/useOptions.ts @@ -1,22 +1,88 @@ +import { EmitFn, EmitsOptions } from '../componentEmits' +import { + ComponentObjectPropsOptions, + ExtractPropTypes +} from '../componentProps' import { Slots } from '../componentSlots' +import { Directive } from '../directives' import { warn } from '../warning' interface DefaultContext { - props: Record + props: {} attrs: Record emit: (...args: any[]) => void slots: Slots } +interface InferredContext { + props: Readonly

+ attrs: Record + emit: EmitFn + slots: Slots +} + +type InferContext, P, E> = { + [K in keyof DefaultContext]: T[K] extends {} ? T[K] : InferredContext[K] +} + +/** + * This is a subset of full options that are still useful in the context of + *