Skip to content

Commit cc75eb1

Browse files
authored
Move v2GlobalName undefined check inside replaceClientCreation (#520)
1 parent e4f5b8f commit cc75eb1

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/transforms/v2-to-v3/client-instances/replaceClientCreation.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getClientNewExpression } from "../utils";
55
export interface ReplaceClientCreationOptions {
66
v2ClientName: string;
77
v2ClientLocalName: string;
8-
v2GlobalName: string;
8+
v2GlobalName?: string;
99
}
1010

1111
// Replace v2 client creation with v3 client creation.
@@ -14,6 +14,8 @@ export const replaceClientCreation = (
1414
source: Collection<unknown>,
1515
{ v2ClientName, v2ClientLocalName, v2GlobalName }: ReplaceClientCreationOptions
1616
): void => {
17+
if (!v2GlobalName) return;
18+
1719
source
1820
.find(j.NewExpression, getClientNewExpression({ v2GlobalName, v2ClientName }))
1921
.replaceWith((v2ClientNewExpression) =>

src/transforms/v2-to-v3/transformer.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ const transformer = async (file: FileInfo, api: API) => {
6060
removePromiseCalls(j, source, v2Options);
6161
replaceWaiterApi(j, source, v2Options);
6262

63-
if (v2GlobalName) {
64-
replaceClientCreation(j, source, { v2ClientName, v2ClientLocalName, v2GlobalName });
65-
}
66-
63+
replaceClientCreation(j, source, v2Options);
6764
replaceDocClientCreation(j, source, v2Options);
6865
}
6966

0 commit comments

Comments
 (0)