Skip to content

Commit 1de486c

Browse files
committed
chore: dts-test vuejs#12978
1 parent 58638a5 commit 1de486c

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

types/test/v3/reactivity-test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
set,
1616
del
1717
} from '../../index'
18-
import { describe, expectType } from '../utils'
18+
import { IsUnion, describe, expectType } from '../utils'
1919

2020
function plainType(arg: number | Ref<number>) {
2121
// ref coercing
@@ -385,3 +385,14 @@ describe('set/del', () => {
385385
// @ts-expect-error
386386
del([], 'fse', 123)
387387
})
388+
389+
390+
{
391+
//#12978
392+
type Steps = { step: '1' } | { step: '2' }
393+
const shallowUnionGenParam = shallowRef<Steps>({ step: '1' })
394+
const shallowUnionAsCast = shallowRef({ step: '1' } as Steps)
395+
396+
expectType<IsUnion<typeof shallowUnionGenParam>>(false)
397+
expectType<IsUnion<typeof shallowUnionAsCast>>(false)
398+
}

types/test/v3/watch-test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ref, computed, watch } from '../../index'
1+
import { ref, computed, watch, shallowRef } from '../../index'
22
import { expectType } from '../utils'
33

44
const source = ref('foo')
@@ -76,3 +76,17 @@ watch([someRef, otherRef], values => {
7676
// no type error
7777
console.log(value2.a)
7878
})
79+
80+
{
81+
//#12978
82+
type Steps = { step: '1' } | { step: '2' }
83+
const shallowUnionGenParam = shallowRef<Steps>({ step: '1' })
84+
const shallowUnionAsCast = shallowRef({ step: '1' } as Steps)
85+
86+
watch(shallowUnionGenParam, value => {
87+
expectType<Steps>(value)
88+
})
89+
watch(shallowUnionAsCast, value => {
90+
expectType<Steps>(value)
91+
})
92+
}

0 commit comments

Comments
 (0)