(
a: MaybeRef<string>,
b: () => string,
c: MaybeRefOrGetter<string>,
d: ComputedRef<string>,
)
| 488 | |
| 489 | describe('toRef <-> toValue', () => { |
| 490 | function foo( |
| 491 | a: MaybeRef<string>, |
| 492 | b: () => string, |
| 493 | c: MaybeRefOrGetter<string>, |
| 494 | d: ComputedRef<string>, |
| 495 | ) { |
| 496 | const r = toRef(a) |
| 497 | expectType<Ref<string>>(r) |
| 498 | // writable |
| 499 | r.value = 'foo' |
| 500 | |
| 501 | const rb = toRef(b) |
| 502 | expectType<Readonly<Ref<string>>>(rb) |
| 503 | // @ts-expect-error ref created from getter should be readonly |
| 504 | rb.value = 'foo' |
| 505 | |
| 506 | const rc = toRef(c) |
| 507 | expectType<Readonly<Ref<string> | Ref<string>>>(rc) |
| 508 | // @ts-expect-error ref created from MaybeReadonlyRef should be readonly |
| 509 | rc.value = 'foo' |
| 510 | |
| 511 | const rd = toRef(d) |
| 512 | expectType<ComputedRef<string>>(rd) |
| 513 | // @ts-expect-error ref created from computed ref should be readonly |
| 514 | rd.value = 'foo' |
| 515 | |
| 516 | expectType<string>(toValue(a)) |
| 517 | expectType<string>(toValue(b)) |
| 518 | expectType<string>(toValue(c)) |
| 519 | expectType<string>(toValue(d)) |
| 520 | |
| 521 | return { |
| 522 | r: toValue(r), |
| 523 | rb: toValue(rb), |
| 524 | rc: toValue(rc), |
| 525 | rd: toValue(rd), |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | expectType<{ |
| 530 | r: string |
no test coverage detected