Skip to content

Commit

Permalink
chore: dts-test vuejs#12978
Browse files Browse the repository at this point in the history
  • Loading branch information
simlevesque committed Mar 9, 2023
1 parent 58638a5 commit 1de486c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
13 changes: 12 additions & 1 deletion types/test/v3/reactivity-test.ts
Expand Up @@ -15,7 +15,7 @@ import {
set,
del
} from '../../index'
import { describe, expectType } from '../utils'
import { IsUnion, describe, expectType } from '../utils'

function plainType(arg: number | Ref<number>) {
// ref coercing
Expand Down Expand Up @@ -385,3 +385,14 @@ describe('set/del', () => {
// @ts-expect-error
del([], 'fse', 123)
})


{
//#12978
type Steps = { step: '1' } | { step: '2' }
const shallowUnionGenParam = shallowRef<Steps>({ step: '1' })
const shallowUnionAsCast = shallowRef({ step: '1' } as Steps)

expectType<IsUnion<typeof shallowUnionGenParam>>(false)
expectType<IsUnion<typeof shallowUnionAsCast>>(false)
}
16 changes: 15 additions & 1 deletion types/test/v3/watch-test.ts
@@ -1,4 +1,4 @@
import { ref, computed, watch } from '../../index'
import { ref, computed, watch, shallowRef } from '../../index'
import { expectType } from '../utils'

const source = ref('foo')
Expand Down Expand Up @@ -76,3 +76,17 @@ watch([someRef, otherRef], values => {
// no type error
console.log(value2.a)
})

{
//#12978
type Steps = { step: '1' } | { step: '2' }
const shallowUnionGenParam = shallowRef<Steps>({ step: '1' })
const shallowUnionAsCast = shallowRef({ step: '1' } as Steps)

watch(shallowUnionGenParam, value => {
expectType<Steps>(value)
})
watch(shallowUnionAsCast, value => {
expectType<Steps>(value)
})
}

0 comments on commit 1de486c

Please sign in to comment.