types(reactivity): computed types remove as
(#367)
This commit is contained in:
parent
42bf9ca3e5
commit
abfb2ec8ed
@ -25,17 +25,20 @@ export function computed<T>(
|
|||||||
export function computed<T>(
|
export function computed<T>(
|
||||||
getterOrOptions: ComputedGetter<T> | WritableComputedOptions<T>
|
getterOrOptions: ComputedGetter<T> | WritableComputedOptions<T>
|
||||||
) {
|
) {
|
||||||
const isReadonly = isFunction(getterOrOptions)
|
let getter: ComputedGetter<T>
|
||||||
const getter = isReadonly
|
let setter: ComputedSetter<T>
|
||||||
? (getterOrOptions as ComputedGetter<T>)
|
|
||||||
: (getterOrOptions as WritableComputedOptions<T>).get
|
if (isFunction(getterOrOptions)) {
|
||||||
const setter = isReadonly
|
getter = getterOrOptions
|
||||||
? __DEV__
|
setter = __DEV__
|
||||||
? () => {
|
? () => {
|
||||||
console.warn('Write operation failed: computed value is readonly')
|
console.warn('Write operation failed: computed value is readonly')
|
||||||
}
|
}
|
||||||
: NOOP
|
: NOOP
|
||||||
: (getterOrOptions as WritableComputedOptions<T>).set
|
} else {
|
||||||
|
getter = getterOrOptions.get
|
||||||
|
setter = getterOrOptions.set
|
||||||
|
}
|
||||||
|
|
||||||
let dirty = true
|
let dirty = true
|
||||||
let value: T
|
let value: T
|
||||||
|
Loading…
Reference in New Issue
Block a user