Skip to content

Commit b1abac0

Browse files
committedAug 7, 2024··
fix: Revert "fix(types/ref): allow getter and setter types to be unrelated (#11442)"
This reverts commit e0b2975. This change requires TypeScript 5.1 so it is moved to a minor release.
1 parent 3a56315 commit b1abac0

File tree

4 files changed

+4
-23
lines changed

4 files changed

+4
-23
lines changed
 

‎packages/dts-test/ref.test-d.ts

-10
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,6 @@ describe('ref with generic', <T extends { name: string }>() => {
172172
expectType<string>(ss.value.name)
173173
})
174174

175-
describe('allow getter and setter types to be unrelated', <T>() => {
176-
const a = { b: ref(0) }
177-
const c = ref(a)
178-
c.value = a
179-
180-
const d = {} as T
181-
const e = ref(d)
182-
e.value = d
183-
})
184-
185175
// shallowRef
186176
type Status = 'initial' | 'ready' | 'invalidating'
187177
const shallowStatus = shallowRef<Status>('initial')

‎packages/dts-test/watch.test-d.ts

-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
type ComputedRef,
3-
type MaybeRef,
43
type Ref,
54
computed,
65
defineComponent,
@@ -204,10 +203,3 @@ defineComponent({
204203
expectType<{ foo: string }>(value)
205204
})
206205
}
207-
208-
{
209-
const css: MaybeRef<string> = ''
210-
watch(ref(css), value => {
211-
expectType<string>(value)
212-
})
213-
}

‎packages/reactivity/src/ref.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ import { warn } from './warning'
3030
declare const RefSymbol: unique symbol
3131
export declare const RawSymbol: unique symbol
3232

33-
export interface Ref<T = any, S = T> {
34-
get value(): T
35-
set value(_: S)
33+
export interface Ref<T = any> {
34+
value: T
3635
/**
3736
* Type differentiator only.
3837
* We need this to be in public d.ts but don't want it to show up in IDE
@@ -109,7 +108,7 @@ export function isRef(r: any): r is Ref {
109108
* @param value - The object to wrap in the ref.
110109
* @see {@link https://vuejs.org/api/reactivity-core.html#ref}
111110
*/
112-
export function ref<T>(value: T): Ref<UnwrapRef<T>, UnwrapRef<T> | T>
111+
export function ref<T>(value: T): Ref<UnwrapRef<T>>
113112
export function ref<T = any>(): Ref<T | undefined>
114113
export function ref(value?: unknown) {
115114
return createRef(value, false)

‎packages/runtime-core/src/apiWatch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import { useSSRContext } from './helpers/useSsrContext'
4646

4747
export type WatchEffect = (onCleanup: OnCleanup) => void
4848

49-
export type WatchSource<T = any> = Ref<T, any> | ComputedRef<T> | (() => T)
49+
export type WatchSource<T = any> = Ref<T> | ComputedRef<T> | (() => T)
5050

5151
export type WatchCallback<V = any, OV = any> = (
5252
value: V,

0 commit comments

Comments
 (0)
Please sign in to comment.