diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index 5e7bb63c22f..d7f11b0d220 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -30,4 +30,4 @@ jobs: - name: Run prettier run: pnpm run format - - uses: autofix-ci/action@bee19d72e71787c12ca0f29de72f2833e437e4c9 + - uses: autofix-ci/action@ea32e3a12414e6d3183163c3424a7d7a8631ad84 diff --git a/packages/dts-test/ref.test-d.ts b/packages/dts-test/ref.test-d.ts index 62bad77c2ee..fc3c9e65e4c 100644 --- a/packages/dts-test/ref.test-d.ts +++ b/packages/dts-test/ref.test-d.ts @@ -244,13 +244,19 @@ expectType(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(p2.a) +expectType(p2.c) +expectType(p2.u) expectType>(p2.obj.k) +expectType<{ name: string } | null>(p2.union) // toRef and toRefs { diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index e156a2e1134..6a584090efc 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -477,15 +477,11 @@ type BaseTypes = string | number | boolean export interface RefUnwrapBailTypes {} export type ShallowUnwrapRef = { - [K in keyof T]: T[K] extends Ref - ? V // if `V` is `unknown` that means it does not extend `Ref` and is undefined - : T[K] extends Ref | undefined - ? unknown extends V - ? undefined - : V | undefined - : T[K] + [K in keyof T]: DistrubuteRef } +type DistrubuteRef = T extends Ref ? V : T + export type UnwrapRef = T extends ShallowRef ? V : T extends Ref diff --git a/packages/sfc-playground/package.json b/packages/sfc-playground/package.json index 6900eaf78f0..0755c46fb04 100644 --- a/packages/sfc-playground/package.json +++ b/packages/sfc-playground/package.json @@ -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:*" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 60a01d9826f..d0fadc5e0c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -357,8 +357,8 @@ importers: packages/sfc-playground: dependencies: '@vue/repl': - specifier: ^3.0.0 - version: 3.0.0 + specifier: ^3.1.0 + version: 3.1.0 file-saver: specifier: ^2.0.5 version: 2.0.5 @@ -1780,8 +1780,8 @@ packages: engines: {node: '>= 0.12.0'} dev: true - /@vue/repl@3.0.0: - resolution: {integrity: sha512-tGYibiftMo5yEuIKPWVsNuuNDejjJk0JQmvKtTm12KNLFqtGD7fWoGv1qUzcN9EAxwVeDgnT9ljRgqGVgZkyEg==} + /@vue/repl@3.1.0: + resolution: {integrity: sha512-lnR010NTkysg71Z0TVsFCTfiF5ARZbyohqymGpOxOrSuSI4o9RlSvWH6YmJdv9OHm5j69HKLVVUhXlCScMCQrg==} dev: false /@zeit/schemas@2.29.0: