From eafd92c4576174a5c0f85cb64eacc072e66ca2c6 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Thu, 9 Jun 2022 03:45:12 +0800 Subject: [PATCH] fix(types): tidy types for `useAsyncData` (#5340) --- packages/nuxt/src/app/composables/asyncData.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/app/composables/asyncData.ts b/packages/nuxt/src/app/composables/asyncData.ts index 40ab34494a..e4ef53c819 100644 --- a/packages/nuxt/src/app/composables/asyncData.ts +++ b/packages/nuxt/src/app/composables/asyncData.ts @@ -5,7 +5,14 @@ import { NuxtApp, useNuxtApp } from '#app' export type _Transform = (input: Input) => Output -export type PickFrom> = T extends Array ? T : T extends Record ? Pick : T +export type PickFrom> = T extends Array + ? T + : T extends Record + ? keyof T extends K[number] + ? T // Exact same keys as the target, skip Pick + : Pick + : T + export type KeysOf = Array export type KeyOfRes = KeysOf>