Skip to content

Commit

Permalink
chore: Merge branch 'main' into minor
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 26, 2023
2 parents 4c88ff7 + 0695c69 commit cda74be
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
- name: Run prettier
run: pnpm run format

- uses: autofix-ci/action@bee19d72e71787c12ca0f29de72f2833e437e4c9
- uses: autofix-ci/action@ea32e3a12414e6d3183163c3424a7d7a8631ad84
8 changes: 7 additions & 1 deletion packages/dts-test/ref.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,19 @@ expectType<typeof r1>(p1)
// proxyRefs: `ShallowUnwrapRef`
const r2 = {
a: ref(1),
c: computed(() => 1),
u: undefined,
obj: {
k: ref('foo')
}
},
union: Math.random() > 0 - 5 ? ref({ name: 'yo' }) : null
}
const p2 = proxyRefs(r2)
expectType<number>(p2.a)
expectType<number>(p2.c)
expectType<undefined>(p2.u)
expectType<Ref<string>>(p2.obj.k)
expectType<{ name: string } | null>(p2.union)

// toRef and toRefs
{
Expand Down
10 changes: 3 additions & 7 deletions packages/reactivity/src/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,11 @@ type BaseTypes = string | number | boolean
export interface RefUnwrapBailTypes {}

export type ShallowUnwrapRef<T> = {
[K in keyof T]: T[K] extends Ref<infer V>
? V // if `V` is `unknown` that means it does not extend `Ref` and is undefined
: T[K] extends Ref<infer V> | undefined
? unknown extends V
? undefined
: V | undefined
: T[K]
[K in keyof T]: DistrubuteRef<T[K]>
}

type DistrubuteRef<T> = T extends Ref<infer V> ? V : T

export type UnwrapRef<T> = T extends ShallowRef<infer V>
? V
: T extends Ref<infer V>
Expand Down
2 changes: 1 addition & 1 deletion packages/sfc-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"vite": "^5.0.5"
},
"dependencies": {
"@vue/repl": "^3.0.0",
"@vue/repl": "^3.1.0",
"file-saver": "^2.0.5",
"jszip": "^3.10.1",
"vue": "workspace:*"
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cda74be

Please sign in to comment.