Skip to content

Commit 498ba58

Browse files
authored
[typescript-fetch] Removed functions that are unused when withoutRuntime is true. (#12101)
* [typescript-fetch] remove unused function when withoutRuntimeCheks option to true * [typescript-fetch] update samples
1 parent f88024a commit 498ba58

File tree

2 files changed

+4
-10
lines changed
  • modules/openapi-generator/src/main/resources/typescript-fetch
  • samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src

2 files changed

+4
-10
lines changed

modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,12 @@ export interface RequestOpts {
217217
body?: HTTPBody;
218218
}
219219

220+
{{^withoutRuntimeChecks}}
220221
export function exists(json: any, key: string) {
221222
const value = json[key];
222223
return value !== null && value !== undefined;
223224
}
225+
{{/withoutRuntimeChecks}}
224226

225227
export function querystring(params: HTTPQuery, prefix: string = ''): string {
226228
return Object.keys(params)
@@ -244,12 +246,14 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string {
244246
.join('&');
245247
}
246248

249+
{{^withoutRuntimeChecks}}
247250
export function mapValues(data: any, fn: (item: any) => any) {
248251
return Object.keys(data).reduce(
249252
(acc, key) => ({ ...acc, [key]: fn(data[key]) }),
250253
{}
251254
);
252255
}
256+
{{/withoutRuntimeChecks}}
253257

254258
export function canConsumeForm(consumes: Consume[]): boolean {
255259
for (const consume of consumes) {

samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,6 @@ export interface RequestOpts {
228228
body?: HTTPBody;
229229
}
230230

231-
export function exists(json: any, key: string) {
232-
const value = json[key];
233-
return value !== null && value !== undefined;
234-
}
235231

236232
export function querystring(params: HTTPQuery, prefix: string = ''): string {
237233
return Object.keys(params)
@@ -255,12 +251,6 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string {
255251
.join('&');
256252
}
257253

258-
export function mapValues(data: any, fn: (item: any) => any) {
259-
return Object.keys(data).reduce(
260-
(acc, key) => ({ ...acc, [key]: fn(data[key]) }),
261-
{}
262-
);
263-
}
264254

265255
export function canConsumeForm(consumes: Consume[]): boolean {
266256
for (const consume of consumes) {

0 commit comments

Comments
 (0)