2016-08-24 03:01:30 +08:00
import {
2016-10-01 01:57:38 +08:00
Component ,
AsyncComponent ,
2016-08-24 03:01:30 +08:00
ComponentOptions ,
2016-09-05 18:53:34 +08:00
FunctionalComponentOptions ,
2017-10-07 02:45:14 +08:00
WatchOptionsWithHandler ,
2016-08-24 03:01:30 +08:00
WatchHandler ,
DirectiveOptions ,
2017-10-07 02:45:14 +08:00
DirectiveFunction ,
RecordPropsDefinition ,
ThisTypedComponentOptionsWithArrayProps ,
ThisTypedComponentOptionsWithRecordProps ,
WatchOptions ,
2016-11-04 08:37:20 +08:00
} from "./options" ;
2019-03-06 05:46:56 +08:00
import { VNode , VNodeData , VNodeChildren , NormalizedScopedSlot } from "./vnode" ;
2016-09-06 21:28:17 +08:00
import { PluginFunction , PluginObject } from "./plugin" ;
2016-08-24 03:01:30 +08:00
2017-10-07 02:45:14 +08:00
export interface CreateElement {
2017-11-27 22:28:38 +08:00
( tag? : string | Component < any , any , any , any > | AsyncComponent < any , any , any , any > | ( ( ) = > Component ) , children? : VNodeChildren ) : VNode ;
( tag? : string | Component < any , any , any , any > | AsyncComponent < any , any , any , any > | ( ( ) = > Component ) , data? : VNodeData , children? : VNodeChildren ) : VNode ;
2016-10-09 02:15:36 +08:00
}
2017-10-07 02:45:14 +08:00
export interface Vue {
2018-12-01 12:30:31 +08:00
readonly $el : Element ;
2017-10-16 02:26:08 +08:00
readonly $options : ComponentOptions < Vue > ;
2016-08-24 03:01:30 +08:00
readonly $parent : Vue ;
readonly $root : Vue ;
readonly $children : Vue [ ] ;
2017-10-07 02:45:14 +08:00
readonly $refs : { [ key : string ] : Vue | Element | Vue [ ] | Element [ ] } ;
2018-12-01 12:31:45 +08:00
readonly $slots : { [ key : string ] : VNode [ ] | undefined } ;
2019-03-01 06:03:28 +08:00
readonly $scopedSlots : { [ key : string ] : NormalizedScopedSlot | undefined } ;
2016-08-24 03:01:30 +08:00
readonly $isServer : boolean ;
2017-10-07 02:45:14 +08:00
readonly $data : Record < string , any > ;
readonly $props : Record < string , any > ;
2017-05-12 10:21:25 +08:00
readonly $ssrContext : any ;
2017-07-11 16:46:54 +08:00
readonly $vnode : VNode ;
2017-10-07 02:45:14 +08:00
readonly $attrs : Record < string , string > ;
readonly $listeners : Record < string , Function | Function [ ] > ;
2016-08-24 03:01:30 +08:00
2017-11-27 22:30:58 +08:00
$mount ( elementOrSelector? : Element | string , hydrating? : boolean ) : this ;
2016-08-24 03:01:30 +08:00
$forceUpdate ( ) : void ;
$destroy ( ) : void ;
$set : typeof Vue . set ;
$delete : typeof Vue . delete ;
$watch (
2017-02-10 15:06:24 +08:00
expOrFn : string ,
2017-10-07 02:45:14 +08:00
callback : ( this : this , n : any , o : any ) = > void ,
2017-02-10 15:06:24 +08:00
options? : WatchOptions
) : ( ( ) = > void ) ;
$watch < T > (
2017-02-11 19:25:17 +08:00
expOrFn : ( this : this ) = > T ,
2017-10-07 02:45:14 +08:00
callback : ( this : this , n : T , o : T ) = > void ,
2016-08-24 03:01:30 +08:00
options? : WatchOptions
) : ( ( ) = > void ) ;
2017-02-16 07:39:53 +08:00
$on ( event : string | string [ ] , callback : Function ) : this ;
2018-12-01 12:41:27 +08:00
$once ( event : string | string [ ] , callback : Function ) : this ;
2017-03-03 11:51:57 +08:00
$off ( event? : string | string [ ] , callback? : Function ) : this ;
2016-08-24 03:01:30 +08:00
$emit ( event : string , . . . args : any [ ] ) : this ;
2016-11-26 01:08:42 +08:00
$nextTick ( callback : ( this : this ) = > void ) : void ;
$nextTick ( ) : Promise < void > ;
2016-10-09 02:15:36 +08:00
$createElement : CreateElement ;
2017-10-07 02:45:14 +08:00
}
2017-10-25 12:45:15 +08:00
export type CombinedVueInstance < Instance extends Vue , Data , Methods , Computed , Props > = Data & Methods & Computed & Props & Instance ;
2017-10-07 02:45:14 +08:00
export type ExtendedVue < Instance extends Vue , Data , Methods , Computed , Props > = VueConstructor < CombinedVueInstance < Instance , Data , Methods , Computed , Props > & Vue > ;
2017-12-19 22:34:35 +08:00
export interface VueConfiguration {
silent : boolean ;
optionMergeStrategies : any ;
devtools : boolean ;
productionTip : boolean ;
performance : boolean ;
errorHandler ( err : Error , vm : Vue , info : string ) : void ;
warnHandler ( msg : string , vm : Vue , trace : string ) : void ;
ignoredElements : ( string | RegExp ) [ ] ;
keyCodes : { [ key : string ] : number | number [ ] } ;
2018-08-17 04:26:02 +08:00
async : boolean ;
2017-12-19 22:34:35 +08:00
}
2017-10-07 02:45:14 +08:00
export interface VueConstructor < V extends Vue = Vue > {
new < Data = object , Methods = object , Computed = object , PropNames extends string = never > ( options? : ThisTypedComponentOptionsWithArrayProps < V , Data , Methods , Computed , PropNames > ) : CombinedVueInstance < V , Data , Methods , Computed , Record < PropNames , any > > ;
2018-12-01 13:23:58 +08:00
// ideally, the return type should just contain Props, not Record<keyof Props, any>. But TS requires to have Base constructors with the same return type.
2017-10-07 02:45:14 +08:00
new < Data = object , Methods = object , Computed = object , Props = object > ( options? : ThisTypedComponentOptionsWithRecordProps < V , Data , Methods , Computed , Props > ) : CombinedVueInstance < V , Data , Methods , Computed , Record < keyof Props , any > > ;
new ( options? : ComponentOptions < V > ) : CombinedVueInstance < V , object , object , object , Record < keyof object , any > > ;
2017-11-27 22:28:38 +08:00
extend < Data , Methods , Computed , PropNames extends string = never > ( options? : ThisTypedComponentOptionsWithArrayProps < V , Data , Methods , Computed , PropNames > ) : ExtendedVue < V , Data , Methods , Computed , Record < PropNames , any > > ;
2017-10-07 02:45:14 +08:00
extend < Data , Methods , Computed , Props > ( options? : ThisTypedComponentOptionsWithRecordProps < V , Data , Methods , Computed , Props > ) : ExtendedVue < V , Data , Methods , Computed , Props > ;
2018-03-09 02:55:52 +08:00
extend < PropNames extends string = never > ( definition : FunctionalComponentOptions < Record < PropNames , any > , PropNames [ ] > ) : ExtendedVue < V , {} , {} , {} , Record < PropNames , any > > ;
extend < Props > ( definition : FunctionalComponentOptions < Props , RecordPropsDefinition < Props > > ) : ExtendedVue < V , {} , {} , {} , Props > ;
2017-10-07 02:45:14 +08:00
extend ( options? : ComponentOptions < V > ) : ExtendedVue < V , {} , {} , {} , {} > ;
2019-03-01 05:54:07 +08:00
nextTick < T > ( callback : ( this : T ) = > void , context? : T ) : void ;
2017-10-07 02:45:14 +08:00
nextTick ( ) : Promise < void >
2018-12-01 12:28:52 +08:00
set < T > ( object : object , key : string | number , value : T ) : T ;
2017-10-07 02:45:14 +08:00
set < T > ( array : T [ ] , key : number , value : T ) : T ;
2018-12-01 12:28:52 +08:00
delete ( object : object , key : string | number ) : void ;
2017-10-07 02:45:14 +08:00
delete < T > ( array : T [ ] , key : number ) : void ;
directive (
id : string ,
definition? : DirectiveOptions | DirectiveFunction
) : DirectiveOptions ;
filter ( id : string , definition? : Function ) : Function ;
2016-08-24 03:01:30 +08:00
2017-10-07 02:45:14 +08:00
component ( id : string ) : VueConstructor ;
component < VC extends VueConstructor > ( id : string , constructor : VC ) : VC ;
component < Data , Methods , Computed , Props > ( id : string , definition : AsyncComponent < Data , Methods , Computed , Props > ) : ExtendedVue < V , Data , Methods , Computed , Props > ;
2017-11-27 22:28:38 +08:00
component < Data , Methods , Computed , PropNames extends string = never > ( id : string , definition? : ThisTypedComponentOptionsWithArrayProps < V , Data , Methods , Computed , PropNames > ) : ExtendedVue < V , Data , Methods , Computed , Record < PropNames , any > > ;
2017-10-07 02:45:14 +08:00
component < Data , Methods , Computed , Props > ( id : string , definition? : ThisTypedComponentOptionsWithRecordProps < V , Data , Methods , Computed , Props > ) : ExtendedVue < V , Data , Methods , Computed , Props > ;
2018-03-09 02:55:52 +08:00
component < PropNames extends string > ( id : string , definition : FunctionalComponentOptions < Record < PropNames , any > , PropNames [ ] > ) : ExtendedVue < V , {} , {} , {} , Record < PropNames , any > > ;
component < Props > ( id : string , definition : FunctionalComponentOptions < Props , RecordPropsDefinition < Props > > ) : ExtendedVue < V , {} , {} , {} , Props > ;
2017-10-07 02:45:14 +08:00
component ( id : string , definition? : ComponentOptions < V > ) : ExtendedVue < V , {} , {} , {} , {} > ;
2018-12-11 00:53:57 +08:00
use < T > ( plugin : PluginObject < T > | PluginFunction < T > , options? : T ) : VueConstructor < V > ;
use ( plugin : PluginObject < any > | PluginFunction < any > , . . . options : any [ ] ) : VueConstructor < V > ;
mixin ( mixin : VueConstructor | ComponentOptions < Vue > ) : VueConstructor < V > ;
2017-10-07 02:45:14 +08:00
compile ( template : string ) : {
render ( createElement : typeof Vue . prototype . $createElement ) : VNode ;
staticRenderFns : ( ( ) = > VNode ) [ ] ;
} ;
2019-01-11 11:44:55 +08:00
observable < T > ( obj : T ) : T ;
2021-03-30 17:46:53 +08:00
util : {
warn ( msg : string , vm? : InstanceType < VueConstructor > ) : void ;
} ;
2017-12-19 22:34:35 +08:00
config : VueConfiguration ;
2019-02-06 11:20:03 +08:00
version : string ;
2016-08-24 03:01:30 +08:00
}
2017-10-07 02:45:14 +08:00
export const Vue : VueConstructor ;