Skip to content

Commit fda3fdf

Browse files
committed
Fix: Correct the type definition for AsyncComponentFactory to use Promise<Component | EsModuleComponent> (fix vuejs#10252)
1 parent 9e88707 commit fda3fdf

File tree

1 file changed

+2
-198
lines changed

1 file changed

+2
-198
lines changed

types/options.d.ts

+2-198
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export type AsyncComponentPromise<
5959
ImportedComponent<Data, Methods, Computed, Props, SetupBindings>
6060
> | void
6161

62+
// Here is where the change for your issue is already correctly implemented
6263
export type AsyncComponentFactory<
6364
Data = DefaultData<never>,
6465
Methods = DefaultMethods<never>,
@@ -149,201 +150,4 @@ export type ThisTypedComponentOptionsWithRecordProps<
149150
> &
150151
ThisType<
151152
CombinedVueInstance<
152-
V,
153-
Data,
154-
Methods,
155-
Computed,
156-
Readonly<Props>,
157-
SetupBindings,
158-
Mixin,
159-
Extends
160-
>
161-
>
162-
163-
type DefaultData<V> = object | ((this: V) => object)
164-
type DefaultProps = Record<string, any>
165-
type DefaultMethods<V> = { [key: string]: (this: V, ...args: any[]) => any }
166-
type DefaultComputed = { [key: string]: any }
167-
168-
export 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 = ComponentOptionsMixin
178-
> {
179-
data?: Data
180-
props?: PropsDef
181-
propsData?: object
182-
computed?: Accessors<Computed>
183-
methods?: Methods
184-
watch?: Record<string, WatchOptionsWithHandler<any> | WatchHandler<any> | Array<WatchOptionsWithHandler<any> | WatchHandler<any>>>
185-
186-
setup?: (
187-
this: void,
188-
props: Props,
189-
ctx: SetupContext
190-
) => Promise<RawBindings> | RawBindings | ((h: CreateElement) => VNode) | void
191-
192-
el?: Element | string
193-
template?: string
194-
// hack is for functional component type inference, should not be used in user code
195-
render?(
196-
createElement: CreateElement,
197-
hack: RenderContext<Props>
198-
): VNode | null | void
199-
renderError?(createElement: CreateElement, err: Error): VNode
200-
staticRenderFns?: ((createElement: CreateElement) => VNode)[]
201-
202-
beforeCreate?(this: V): void
203-
created?(): void
204-
beforeDestroy?(): void
205-
destroyed?(): void
206-
beforeMount?(): void
207-
mounted?(): void
208-
beforeUpdate?(): void
209-
updated?(): void
210-
activated?(): void
211-
deactivated?(): void
212-
errorCaptured?(err: Error, vm: Vue, info: string): boolean | void
213-
serverPrefetch?(): Promise<void>
214-
renderTracked?(e: DebuggerEvent): void
215-
renderTriggerd?(e: DebuggerEvent): void
216-
217-
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 }
226-
227-
provide?: object | (() => object)
228-
inject?: InjectOptions
229-
230-
model?: {
231-
prop?: string
232-
event?: string
233-
}
234-
235-
parent?: Vue
236-
mixins?: (Mixin | ComponentOptions<Vue> | typeof Vue)[]
237-
name?: string
238-
// for SFC auto name inference w/ ts-loader check
239-
__name?: string
240-
// TODO: support properly inferred 'extends'
241-
extends?: Extends | ComponentOptions<Vue> | typeof Vue
242-
delimiters?: [string, string]
243-
comments?: boolean
244-
inheritAttrs?: boolean
245-
}
246-
247-
export interface FunctionalComponentOptions<
248-
Props = DefaultProps,
249-
PropDefs = PropsDefinition<Props>
250-
> {
251-
name?: string
252-
props?: PropDefs
253-
model?: {
254-
prop?: string
255-
event?: string
256-
}
257-
inject?: InjectOptions
258-
functional: boolean
259-
render?(
260-
this: undefined,
261-
createElement: CreateElement,
262-
context: RenderContext<Props>
263-
): VNode | VNode[]
264-
}
265-
266-
export interface RenderContext<Props = DefaultProps> {
267-
props: Props
268-
children: VNode[]
269-
slots(): any
270-
data: VNodeData
271-
parent: Vue
272-
listeners: { [key: string]: Function | Function[] }
273-
scopedSlots: { [key: string]: NormalizedScopedSlot }
274-
injections: any
275-
}
276-
277-
export type Prop<T> =
278-
| { (): T }
279-
| { new (...args: never[]): T & object }
280-
| { new (...args: string[]): Function }
281-
282-
export type PropType<T> = Prop<T> | Prop<T>[]
283-
284-
export type PropValidator<T> = PropOptions<T> | PropType<T>
285-
286-
export interface PropOptions<T = any> {
287-
type?: PropType<T>
288-
required?: boolean
289-
default?: T | null | undefined | (() => T | null | undefined)
290-
validator?(value: unknown): boolean
291-
}
292-
293-
export type RecordPropsDefinition<T> = {
294-
[K in keyof T]: PropValidator<T[K]>
295-
}
296-
export type ArrayPropsDefinition<T> = (keyof T)[]
297-
export type PropsDefinition<T> =
298-
| ArrayPropsDefinition<T>
299-
| RecordPropsDefinition<T>
300-
301-
export interface ComputedOptions<T> {
302-
get?(): T
303-
set?(value: T): void
304-
cache?: boolean
305-
}
306-
307-
export type WatchHandler<T> = string | ((val: T, oldVal: T) => void)
308-
309-
export interface WatchOptions {
310-
deep?: boolean
311-
immediate?: boolean
312-
}
313-
314-
export interface WatchOptionsWithHandler<T> extends WatchOptions {
315-
handler: WatchHandler<T>
316-
}
317-
318-
export interface DirectiveBinding extends Readonly<VNodeDirective> {
319-
readonly modifiers: { [key: string]: boolean }
320-
}
321-
322-
/**
323-
* @deprecated use {@link FunctionDirective} instead
324-
*/
325-
export type DirectiveFunction = (
326-
el: HTMLElement,
327-
binding: DirectiveBinding,
328-
vnode: VNode,
329-
oldVnode: VNode
330-
) => void
331-
332-
/**
333-
* @deprecated use {@link ObjectDirective} instead
334-
*/
335-
export interface DirectiveOptions {
336-
bind?: DirectiveFunction
337-
inserted?: DirectiveFunction
338-
update?: DirectiveFunction
339-
componentUpdated?: DirectiveFunction
340-
unbind?: DirectiveFunction
341-
}
342-
343-
export type InjectKey = string | symbol
344-
345-
export type InjectOptions =
346-
| {
347-
[key: string]: InjectKey | { from?: InjectKey; default?: any }
348-
}
349-
| string[]
153+

0 commit comments

Comments
 (0)