types: avoid plain objects with value being mistaken as refs

This commit is contained in:
Evan You
2019-09-05 18:32:19 -04:00
parent 9b90e673e8
commit 6c7cbb0dc9
4 changed files with 35 additions and 19 deletions

View File

@@ -5,7 +5,12 @@ import { reactive } from './reactive'
export const knownRefs = new WeakSet()
export const isRefSymbol = Symbol()
export interface Ref<T> {
// this is a type-only field to avoid objects with 'value' property being
// treated as a ref by TypeScript
[isRefSymbol]: true
value: UnwrapNestedRefs<T>
}