1import { Vue, CreateElement, CombinedVueInstance } from './vue'2import { VNode, VNodeData, VNodeDirective, NormalizedScopedSlot } from './vnode'3import { SetupContext } from './v3-setup-context'4import { DebuggerEvent } from './v3-generated'5import { DefineComponent } from './v3-define-component'6import { ComponentOptionsMixin } from './v3-component-options'7import { ObjectDirective, FunctionDirective } from './v3-directive'89type Constructor = {10 new (...args: any[]): any11}1213// we don't support infer props in async component14// N.B. ComponentOptions<V> is contravariant, the default generic should be bottom type15export type Component<16 Data = DefaultData<never>,17 Methods = DefaultMethods<never>,18 Computed = DefaultComputed,19 Props = DefaultProps,20 SetupBindings = {}21> =22 | typeof Vue23 | FunctionalComponentOptions<Props>24 | ComponentOptions<never, Data, Methods, Computed, Props, SetupBindings>25 | DefineComponent<any, any, any, any, any, any, any, any, any, any, any>2627type EsModule<T> = T | { default: T }2829type ImportedComponent<30 Data = DefaultData<never>,31 Methods = DefaultMethods<never>,32 Computed = DefaultComputed,33 Props = DefaultProps,34 SetupBindings = {}35> = EsModule<Component<Data, Methods, Computed, Props, SetupBindings>>3637export type AsyncComponent<38 Data = DefaultData<never>,39 Methods = DefaultMethods<never>,40 Computed = DefaultComputed,41 Props = DefaultProps,42 SetupBindings = {}43> =44 | AsyncComponentPromise<Data, Methods, Computed, Props, SetupBindings>45 | AsyncComponentFactory<Data, Methods, Computed, Props, SetupBindings>4647export type AsyncComponentPromise<48 Data = DefaultData<never>,49 Methods = DefaultMethods<never>,50 Computed = DefaultComputed,51 Props = DefaultProps,52 SetupBindings = {}53> = (54 resolve: (55 component: Component<Data, Methods, Computed, Props, SetupBindings>56 ) => void,57 reject: (reason?: any) => void58) => Promise<59 ImportedComponent<Data, Methods, Computed, Props, SetupBindings>60> | void6162export type AsyncComponentFactory<63 Data = DefaultData<never>,64 Methods = DefaultMethods<never>,65 Computed = DefaultComputed,66 Props = DefaultProps,67 SetupBindings = {}68> = () => {69 component: Promise<70 ImportedComponent<Data, Methods, Computed, Props, SetupBindings>71 >72 loading?: ImportedComponent73 error?: ImportedComponent74 delay?: number75 timeout?: number76}7778/**79 * When the `Computed` type parameter on `ComponentOptions` is inferred,80 * it should have a property with the return type of every get-accessor.81 * Since there isn't a way to query for the return type of a function, we allow TypeScript82 * to infer from the shape of `Accessors<Computed>` and work backwards.83 */84export type Accessors<T> = {85 [K in keyof T]: (() => T[K]) | ComputedOptions<T[K]>86}8788type DataDef<Data, Props, V> = Data | ((this: Readonly<Props> & V) => Data)89/**90 * This type should be used when an array of strings is used for a component's `props` value.91 */92export type ThisTypedComponentOptionsWithArrayProps<93 V extends Vue,94 Data,95 Methods,96 Computed,97 PropNames extends string,98 SetupBindings,99 Mixin extends ComponentOptionsMixin,100 Extends extends ComponentOptionsMixin101> = object &102 ComponentOptions<103 V,104 DataDef<Data, Record<PropNames, any>, V>,105 Methods,106 Computed,107 PropNames[],108 Record<PropNames, any>,109 SetupBindings,110 Mixin,111 Extends112 > &113 ThisType<114 CombinedVueInstance<115 V,116 Data,117 Methods,118 Computed,119 Readonly<Record<PropNames, any>>,120 SetupBindings,121 Mixin,122 Extends123 >124 >125126/**127 * This type should be used when an object mapped to `PropOptions` is used for a component's `props` value.128 */129export type ThisTypedComponentOptionsWithRecordProps<130 V extends Vue,131 Data,132 Methods,133 Computed,134 Props,135 SetupBindings,136 Mixin extends ComponentOptionsMixin,137 Extends extends ComponentOptionsMixin138> = object &139 ComponentOptions<140 V,141 DataDef<Data, Props, V>,142 Methods,143 Computed,144 RecordPropsDefinition<Props>,145 Props,146 SetupBindings,147 Mixin,148 Extends149 > &150 ThisType<151 CombinedVueInstance<152 V,153 Data,154 Methods,155 Computed,156 Readonly<Props>,157 SetupBindings,158 Mixin,159 Extends160 >161 >162163type DefaultData<V> = object | ((this: V) => object)164type DefaultProps = Record<string, any>165type DefaultMethods<V> = { [key: string]: (this: V, ...args: any[]) => any }166type DefaultComputed = { [key: string]: any }167168export interface ComponentOptions<169 V extends Vue,170 Data = DefaultData<V>,171 Methods = DefaultMethods<V>,172 Computed = DefaultComputed,173 PropsDef = PropsDefinition<DefaultProps>,174 Props = DefaultProps,175 RawBindings = {},176 Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,177 Extends extends ComponentOptionsMixin = ComponentOptionsMixin178> {179 data?: Data180 props?: PropsDef181 propsData?: object182 computed?: Accessors<Computed>183 methods?: Methods184 watch?: Record<string, WatchOptionsWithHandler<any> | WatchHandler<any> | Array<WatchOptionsWithHandler<any> | WatchHandler<any>>>185186 setup?: (187 this: void,188 props: Props,189 ctx: SetupContext190 ) => Promise<RawBindings> | RawBindings | ((h: CreateElement) => VNode) | void191192 el?: Element | string193 template?: string194 // hack is for functional component type inference, should not be used in user code195 render?(196 createElement: CreateElement,197 hack: RenderContext<Props>198 ): VNode | null | void199 renderError?(createElement: CreateElement, err: Error): VNode200 staticRenderFns?: ((createElement: CreateElement) => VNode)[]201202 beforeCreate?(this: V): void203 created?(): void204 beforeDestroy?(): void205 destroyed?(): void206 beforeMount?(): void207 mounted?(): void208 beforeUpdate?(): void209 updated?(): void210 activated?(): void211 deactivated?(): void212 errorCaptured?(err: Error, vm: Vue, info: string): boolean | void213 serverPrefetch?(): Promise<void>214 renderTracked?(e: DebuggerEvent): void215 renderTriggerd?(e: DebuggerEvent): void216217 directives?: { [key: string]: DirectiveFunction | DirectiveOptions }218 components?: {219 [key: string]:220 | {}221 | Component<any, any, any, any, any>222 | AsyncComponent<any, any, any, any>223 }224 transitions?: { [key: string]: object }225 filters?: { [key: string]: Function }226227 provide?: object | (() => object)228 inject?: InjectOptions229230 model?: {231 prop?: string232 event?: string233 }234235 parent?: Vue236 mixins?: (Mixin | ComponentOptions<Vue> | typeof Vue)[]237 name?: string238 // for SFC auto name inference w/ ts-loader check239 __name?: string240 // TODO: support properly inferred 'extends'241 extends?: Extends | ComponentOptions<Vue> | typeof Vue242 delimiters?: [string, string]243 comments?: boolean244 inheritAttrs?: boolean245}246247export interface FunctionalComponentOptions<248 Props = DefaultProps,249 PropDefs = PropsDefinition<Props>250> {251 name?: string252 props?: PropDefs253 model?: {254 prop?: string255 event?: string256 }257 inject?: InjectOptions258 functional: boolean259 render?(260 this: undefined,261 createElement: CreateElement,262 context: RenderContext<Props>263 ): VNode | VNode[]264}265266export interface RenderContext<Props = DefaultProps> {267 props: Props268 children: VNode[]269 slots(): any270 data: VNodeData271 parent: Vue272 listeners: { [key: string]: Function | Function[] }273 scopedSlots: { [key: string]: NormalizedScopedSlot }274 injections: any275}276277export type Prop<T> =278 | { (): T }279 | { new (...args: never[]): T & object }280 | { new (...args: string[]): Function }281282export type PropType<T> = Prop<T> | Prop<T>[]283284export type PropValidator<T> = PropOptions<T> | PropType<T>285286export interface PropOptions<T = any> {287 type?: PropType<T>288 required?: boolean289 default?: T | null | undefined | (() => T | null | undefined)290 validator?(value: unknown): boolean291}292293export type RecordPropsDefinition<T> = {294 [K in keyof T]: PropValidator<T[K]>295}296export type ArrayPropsDefinition<T> = (keyof T)[]297export type PropsDefinition<T> =298 | ArrayPropsDefinition<T>299 | RecordPropsDefinition<T>300301export interface ComputedOptions<T> {302 get?(): T303 set?(value: T): void304 cache?: boolean305}306307export type WatchHandler<T> = string | ((val: T, oldVal: T) => void)308309export interface WatchOptions {310 deep?: boolean311 immediate?: boolean312}313314export interface WatchOptionsWithHandler<T> extends WatchOptions {315 handler: WatchHandler<T>316}317318export interface DirectiveBinding extends Readonly<VNodeDirective> {319 readonly modifiers: { [key: string]: boolean }320}321322/**323 * @deprecated use {@link FunctionDirective} instead324 */325export type DirectiveFunction = (326 el: HTMLElement,327 binding: DirectiveBinding,328 vnode: VNode,329 oldVnode: VNode330) => void331332/**333 * @deprecated use {@link ObjectDirective} instead334 */335export interface DirectiveOptions {336 bind?: DirectiveFunction337 inserted?: DirectiveFunction338 update?: DirectiveFunction339 componentUpdated?: DirectiveFunction340 unbind?: DirectiveFunction341}342343export type InjectKey = string | symbol344345export type InjectOptions =346 | {347 [key: string]: InjectKey | { from?: InjectKey; default?: any }348 }349 | string[]
Findings
✓ No findings reported for this file.