Skip to content

Commit 35ac3b6

Browse files
committed
fix(cli): fix extendPackage type def in d.ts
since Function belongs to object, so a Function which return type is not object is still assignable to 'object | () => return type'. we need exclude Function from object. releated: microsoft/TypeScript#38254 https://stackoverflow.com/questions/24613955/is-there-a-type-in-typescript-for-anything-except-functions
1 parent 50e10b9 commit 35ac3b6

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

packages/@vue/cli/types/index.d.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,16 @@ interface OnPromptCompleteCb<T> {
3030
options: {
3131
useConfigFiles: boolean
3232
plugins: Record<string, any>
33-
},
33+
}
3434
): void
3535
}
36+
type ExtendPackageOptions =
37+
| {
38+
prune?: boolean
39+
merge?: boolean
40+
warnIncompatibleVersions?: boolean
41+
}
42+
| boolean
3643

3744
type Preset = Partial<{
3845
[props: string]: any
@@ -116,14 +123,12 @@ declare class GeneratorAPI {
116123
* if two dependency version ranges don't intersect.
117124
*/
118125
extendPackage(
119-
fields: object | ((pkg: Record<string, any>) => object),
120-
options?:
121-
| {
122-
prune?: boolean
123-
merge?: boolean
124-
warnIncompatibleVersions?: boolean
125-
}
126-
| boolean,
126+
fields: (pkg: Record<string, any>) => object,
127+
options?: ExtendPackageOptions
128+
): void
129+
extendPackage<T extends object>(
130+
fields: T extends Function ? never : T,
131+
options?: ExtendPackageOptions
127132
): void
128133

129134
/**

0 commit comments

Comments
 (0)