diff --git a/packages/reactivity/src/computed.ts b/packages/reactivity/src/computed.ts index 3bb3c3e2..c22a33e4 100644 --- a/packages/reactivity/src/computed.ts +++ b/packages/reactivity/src/computed.ts @@ -33,8 +33,8 @@ export function computed( } : (getterOrOptions as WritableComputedOptions).set - let dirty: boolean = true - let value: any = undefined + let dirty = true + let value: T const runner = effect(getter, { lazy: true, diff --git a/packages/reactivity/src/effect.ts b/packages/reactivity/src/effect.ts index a147e613..a542e3b6 100644 --- a/packages/reactivity/src/effect.ts +++ b/packages/reactivity/src/effect.ts @@ -160,8 +160,8 @@ export function trigger( // never been tracked return } - const effects: Set = new Set() - const computedRunners: Set = new Set() + const effects = new Set() + const computedRunners = new Set() if (type === OperationTypes.CLEAR) { // collection being cleared, trigger all effects for target depsMap.forEach(dep => { diff --git a/packages/reactivity/src/reactive.ts b/packages/reactivity/src/reactive.ts index 28c74720..b703154e 100644 --- a/packages/reactivity/src/reactive.ts +++ b/packages/reactivity/src/reactive.ts @@ -15,20 +15,20 @@ import { ReactiveEffect } from './effect' // raw Sets to reduce memory overhead. export type Dep = Set export type KeyToDepMap = Map -export const targetMap: WeakMap = new WeakMap() +export const targetMap = new WeakMap() // WeakMaps that store {raw <-> observed} pairs. -const rawToReactive: WeakMap = new WeakMap() -const reactiveToRaw: WeakMap = new WeakMap() -const rawToReadonly: WeakMap = new WeakMap() -const readonlyToRaw: WeakMap = new WeakMap() +const rawToReactive = new WeakMap() +const reactiveToRaw = new WeakMap() +const rawToReadonly = new WeakMap() +const readonlyToRaw = new WeakMap() // WeakSets for values that are marked readonly or non-reactive during // observable creation. -const readonlyValues: WeakSet = new WeakSet() -const nonReactiveValues: WeakSet = new WeakSet() +const readonlyValues = new WeakSet() +const nonReactiveValues = new WeakSet() -const collectionTypes: Set = new Set([Set, Map, WeakMap, WeakSet]) +const collectionTypes = new Set([Set, Map, WeakMap, WeakSet]) const observableValueRE = /^\[object (?:Object|Array|Map|Set|WeakMap|WeakSet)\]$/ const canObserve = (value: any): boolean => {