diff --git a/packages/core/src/component.ts b/packages/core/src/component.ts index c221a1dc..5099b396 100644 --- a/packages/core/src/component.ts +++ b/packages/core/src/component.ts @@ -29,8 +29,6 @@ export interface FunctionalComponent
{ export type ComponentType = ComponentClass | FunctionalComponent -// this interface is merged with the class type -// to represent a mounted component export interface ComponentInstance
extends InternalComponent { $vnode: MountedVNode $data: D @@ -40,7 +38,7 @@ export interface ComponentInstance
extends InternalComponent { $slots: Slots $root: ComponentInstance $children: ComponentInstance[] - $options: ComponentOptions
+ $options: ComponentOptions , slots: Slots, attrs: Data): any
diff --git a/packages/core/src/componentComputed.ts b/packages/core/src/componentComputed.ts
index 074adcc9..19fd0ad0 100644
--- a/packages/core/src/componentComputed.ts
+++ b/packages/core/src/componentComputed.ts
@@ -1,4 +1,4 @@
-import { EMPTY_OBJ } from './utils'
+import { EMPTY_OBJ, NOOP } from './utils'
import { computed, stop, ComputedGetter } from '@vue/observer'
import { ComponentClass, ComponentInstance } from './component'
import { ComponentComputedOptions } from './componentOptions'
@@ -43,7 +43,9 @@ export function initializeComputed(
> = (instance._computedGetters = {})
const proxy = instance.$proxy
for (const key in computedOptions) {
- handles[key] = computed(computedOptions[key], proxy)
+ const option = computedOptions[key]
+ const getter = typeof option === 'function' ? option : option.get || NOOP
+ handles[key] = computed(getter, proxy)
}
instance.$computed = new Proxy(
{},
diff --git a/packages/core/src/componentOptions.ts b/packages/core/src/componentOptions.ts
index eca1c8f9..60bd1cb3 100644
--- a/packages/core/src/componentOptions.ts
+++ b/packages/core/src/componentOptions.ts
@@ -1,20 +1,14 @@
-import { MergedComponent, ComponentInstance } from './component'
+import { ComponentInstance } from './component'
import { Slots } from './vdom'
export type Data = Record & M & C
-> {
- data?: (this: This) => Partial
+export interface ComponentOptions , slots: Slots, attrs: Data) => any
+ render?: (this: This, props: Readonly, slots: Slots, attrs: Data) => any
inheritAttrs?: boolean
displayName?: string
// TODO other options
@@ -39,7 +33,13 @@ export interface PropOptions & { el?: any }) {
+ constructor(options: any) {
super()
if (!options) {
return
@@ -49,8 +43,8 @@ class Vue<
}
}
-interface Vue {
- $mount(el: any): MergedComponent & M & C
+interface Vue {
+ $mount(el: any): any
}
export default Vue