Skip to content

Commit c66d565

Browse files
Copilotmrlubos
andcommitted
Fix typecheck error: use typeof string check instead of Array.isArray for ReadonlyArray
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
1 parent bcd0a87 commit c66d565

4 files changed

Lines changed: 16 additions & 12 deletions

File tree

packages/openapi-python/src/generate/__tests__/client.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import path from 'node:path';
55
*/
66
function outputHeaderToPrefix(header: unknown): string {
77
if (header == null || typeof header === 'function') return '';
8-
const lines = Array.isArray(header)
9-
? (header as string[]).flatMap((line) => line.split(/\r?\n/))
10-
: (header as string).split(/\r?\n/);
8+
const lines =
9+
typeof header === 'string'
10+
? header.split(/\r?\n/)
11+
: (header as string[]).flatMap((line) => line.split(/\r?\n/));
1112
const content = lines.join('\n');
1213
return content ? `${content}\n\n` : '';
1314
}

packages/openapi-python/src/generate/client.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ function getClientBundlePaths(pluginName: string): {
6060
*/
6161
function outputHeaderToPrefix(header: OutputHeader): string {
6262
if (header == null || typeof header === 'function') return '';
63-
const lines = Array.isArray(header)
64-
? header.flatMap((line) => line.split(/\r?\n/))
65-
: header.split(/\r?\n/);
63+
const lines =
64+
typeof header === 'string'
65+
? header.split(/\r?\n/)
66+
: header.flatMap((line) => line.split(/\r?\n/));
6667
const content = lines.join('\n');
6768
return content ? `${content}\n\n` : '';
6869
}

packages/openapi-ts/src/generate/__tests__/client.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import path from 'node:path';
55
*/
66
function outputHeaderToPrefix(header: unknown): string {
77
if (header == null || typeof header === 'function') return '';
8-
const lines = Array.isArray(header)
9-
? (header as string[]).flatMap((line) => line.split(/\r?\n/))
10-
: (header as string).split(/\r?\n/);
8+
const lines =
9+
typeof header === 'string'
10+
? header.split(/\r?\n/)
11+
: (header as string[]).flatMap((line) => line.split(/\r?\n/));
1112
const content = lines.join('\n');
1213
return content ? `${content}\n\n` : '';
1314
}

packages/openapi-ts/src/generate/client.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ function getClientBundlePaths(pluginName: string): {
6060
*/
6161
function outputHeaderToPrefix(header: OutputHeader): string {
6262
if (header == null || typeof header === 'function') return '';
63-
const lines = Array.isArray(header)
64-
? header.flatMap((line) => line.split(/\r?\n/))
65-
: header.split(/\r?\n/);
63+
const lines =
64+
typeof header === 'string'
65+
? header.split(/\r?\n/)
66+
: header.flatMap((line) => line.split(/\r?\n/));
6667
const content = lines.join('\n');
6768
return content ? `${content}\n\n` : '';
6869
}

0 commit comments

Comments
 (0)