Skip to content

Commit facb3c6

Browse files
committed
chore: separate params from options
1 parent bd7185c commit facb3c6

File tree

11 files changed

+519
-549
lines changed

11 files changed

+519
-549
lines changed

packages/client-fetch/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ export type {
44
ClientOptions,
55
Config,
66
CreateClientConfig,
7+
OmitNever,
78
Options,
89
OptionsLegacyParser,
10+
Params,
911
RequestOptions,
1012
RequestResult,
1113
TDataShape,

packages/client-fetch/src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,9 @@ export type OptionsLegacyParser<
164164
TData &
165165
Pick<RequestOptions<ThrowOnError>, 'body'>
166166
: OmitKeys<RequestOptions<ThrowOnError>, 'url'> & TData;
167+
168+
export type OmitNever<T> = {
169+
[K in keyof T as T[K] extends never ? never : K]: T[K];
170+
};
171+
172+
export type Params<T extends TDataShape> = OmitNever<Omit<T, 'url'>>;

packages/openapi-ts/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"typescript": "^5.5.3"
8888
},
8989
"devDependencies": {
90+
"@hey-api/client-core": "workspace:*",
9091
"@types/cross-spawn": "6.0.6",
9192
"@types/express": "4.17.21",
9293
"axios": "1.8.2",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export const nuxtTypeComposable = 'TComposable';
22
export const nuxtTypeDefault = 'DefaultT';
33
export const nuxtTypeResponse = 'ResT';
4+
5+
export const sdkId = 'sdk';

packages/openapi-ts/src/plugins/@hey-api/sdk/params.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const createParameters = ({
6161
file: TypeScriptFile;
6262
operation: IR.OperationObject;
6363
plugin: Plugin.Instance<Config>;
64-
}): Array<FunctionParameter> | undefined => {
64+
}): Array<FunctionParameter> => {
6565
const client = getClientPlugin(context.config);
6666
const isNuxtClient = client.name === '@hey-api/client-nuxt';
6767

@@ -74,7 +74,7 @@ export const createParameters = ({
7474
parameters.push({
7575
isRequired: hasOperationDataRequired(operation),
7676
name: 'params',
77-
type: `OmitNever<Omit<${identifierData.name}, 'url'>>`,
77+
type: `Params<${identifierData.name}>`,
7878
});
7979
}
8080

@@ -106,5 +106,5 @@ export const createParameters = ({
106106
});
107107
}
108108

109-
return parameters.length ? parameters : undefined;
109+
return parameters;
110110
};

0 commit comments

Comments
 (0)