Skip to content

Commit 03ce764

Browse files
committed
fix: type error caused by missing nuxt type
1 parent 8c9a2eb commit 03ce764

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

build.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { defineBuildConfig } from 'unbuild';
22

33
export default defineBuildConfig({
44
entries: ['src/module'],
5+
56
externals: [
67
'./node_modules/nuxt/dist/app',
78
'ofetch',
89
'nuxt/app/defaults',
910
'nitropack/types',
10-
'./node_modules/nuxt/dist/app/composables/asyncData',
11+
//'./node_modules/nuxt/dist/app/composables/asyncData',
1112
'vue',
1213
'nuxt/schema',
1314
'node:path',

src/runtime/fetchTypes.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ import type { NitroFetchRequest, AvailableRouterMethod } from 'nitropack/types';
1111
import type {
1212
PickFrom,
1313
KeysOf,
14-
} from '../../node_modules/nuxt/dist/app/composables/asyncData';
15-
import type { Ref } from 'vue';
16-
import type {
1714
HasRequiredProperties,
1815
OmitStrict,
1916
ComputedOptions,
2017
PlainObject,
2118
} from './typeUtils';
19+
import type { Ref } from 'vue';
2220
export type { FetchOptions } from 'ofetch';
2321
export type { ComputedOptions } from './typeUtils';
2422

src/runtime/typeUtils.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,24 @@ export type ComputedOptions<T extends Record<string, any>> = {
1616
};
1717

1818
export type PlainObject = { [key: string]: any };
19+
20+
/** @see {@link https://github.com/nuxt/nuxt/blob/017d1bed05b83e889d51c27d251a69c326ca7beb/packages/nuxt/src/app/composables/asyncData.ts#L21} */
21+
export type PickFrom<T, K extends Array<string>> =
22+
T extends Array<any>
23+
? T
24+
: T extends Record<string, any>
25+
? keyof T extends K[number]
26+
? T
27+
: K[number] extends never
28+
? T
29+
: Pick<T, K[number]>
30+
: T;
31+
32+
/** @see {@link https://github.com/nuxt/nuxt/blob/017d1bed05b83e889d51c27d251a69c326ca7beb/packages/nuxt/src/app/composables/asyncData.ts#L21} */
33+
export type KeysOf<T> = Array<
34+
T extends T // Include all keys of union types, not just common keys
35+
? keyof T extends string
36+
? keyof T
37+
: never
38+
: never
39+
>;

0 commit comments

Comments
 (0)