Skip to content

Commit 635b5da

Browse files
committed
type
1 parent bd9b90c commit 635b5da

File tree

2 files changed

+10
-63
lines changed

2 files changed

+10
-63
lines changed

src/index.ts

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,70 +5,16 @@ export { decorator as Watch } from './option/watch'
55
export { decorator as Prop } from './option/props'
66
export { decorator as Inject } from './option/inject'
77
export { decorator as Emit } from './option/emit'
8+
89
import type {
9-
ComponentInternalInstance,
1010
ComponentPublicInstance,
11-
Slots,
12-
nextTick,
13-
WatchOptions,
14-
WatchStopHandle,
15-
11+
ComponentOptions
1612
} from 'vue'
1713

18-
// export declare class Base {
19-
20-
// $: ComponentInternalInstance;
21-
// $data: any//D;
22-
// $props: any//MakeDefaultsOptional extends true ? Partial<Defaults> & Omit<P & PublicProps, keyof Defaults> : P & PublicProps;
23-
// $attrs: any//Data;
24-
// $refs: any//Data;
25-
// $slots: Slots;
26-
// $root: ComponentPublicInstance | null;
27-
// $parent: ComponentPublicInstance | null;
28-
// $emit: any// EmitFn<E>;
29-
// $el: any;
30-
// $options: any//Options & MergedComponentOptionsOverride;
31-
// $forceUpdate: () => void;
32-
// $nextTick: typeof nextTick;
33-
// $watch: { (source: string | Function, cb: Function, options?: WatchOptions): WatchStopHandle };
34-
35-
// }
3614

37-
export class Base {
38-
39-
$!: ComponentInternalInstance;
40-
$data!: any//D;
41-
$props!: any//MakeDefaultsOptional extends true ? Partial<Defaults> & Omit<P & PublicProps, keyof Defaults> : P & PublicProps;
42-
$attrs!: any//Data;
43-
$refs!: any//Data;
44-
$slots!: Slots;
45-
$root!: ComponentPublicInstance | null;
46-
$parent!: ComponentPublicInstance | null;
47-
$emit!: any// EmitFn<E>;
48-
$el!: any;
49-
$options!: any//Options & MergedComponentOptionsOverride;
50-
$forceUpdate!: () => void;
51-
$nextTick!: typeof nextTick;
52-
$watch!: { (source: string | Function, cb: Function, options?: WatchOptions): WatchStopHandle };
53-
54-
55-
beforeCreate?(): void;
56-
created?(): void;
57-
beforeMount?(): void;
58-
mounted?(): void;
59-
beforeUpdate?(): void;
60-
updated?(): void;
61-
activated?(): void;
62-
deactivated?(): void;
63-
/** @deprecated use `beforeUnmount` instead */
64-
beforeDestroy?(): void;
65-
beforeUnmount?(): void;
66-
/** @deprecated use `unmounted` instead */
67-
destroyed?(): void;
68-
unmounted?(): void;
69-
renderTracked?(e: any): void;
70-
renderTriggered?(e: any): void;
71-
errorCaptured?(err: any, instance: ComponentPublicInstance | null, info: string): boolean | void;
15+
export const Base = class { } as {
16+
new(): ComponentPublicInstance
7217
}
7318

19+
7420
export const Vue = Base

src/option/methodsAndLifecycle.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { makeObject, obtainSlot } from '../utils'
22
import { Cons, OptionBuilder } from '../component'
33
import { toComponentReverse, excludeNames, getValidNames } from '../utils'
4-
const LifecycleNames = [
4+
export const LifecycleNames = [
55
"beforeCreate",
66
"created",
77
"beforeMount",
@@ -16,8 +16,9 @@ const LifecycleNames = [
1616
"unmounted",
1717
"renderTracked",
1818
"renderTriggered",
19-
"errorCaptured"
20-
]
19+
"errorCaptured",
20+
"serverPrefetch"
21+
] as const
2122

2223
export function build(cons: Cons, optionBuilder: OptionBuilder) {
2324
const slot = obtainSlot(cons.prototype)
@@ -37,7 +38,7 @@ export function build(cons: Cons, optionBuilder: OptionBuilder) {
3738
}
3839
return false
3940
}), slot).forEach(name => {
40-
if (LifecycleNames.includes(name)) {
41+
if (LifecycleNames.includes(name as any)) {
4142
LifecycleFunctions[name] = proto[name]
4243
}
4344
else {

0 commit comments

Comments
 (0)