Skip to content

Commit 7137519

Browse files
authored
Rename getV2ClientTypeNames to getClientTypeNames (#459)
1 parent 86fa6d7 commit 7137519

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

src/transforms/v2-to-v3/apis/getClientWaiterCallExpression.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { CallExpression } from "jscodeshift";
33
import { ClientIdentifier } from "./getClientIdentifiers";
44

55
export const getClientWaiterCallExpression = (
6-
v2ClientId: ClientIdentifier,
6+
clientId: ClientIdentifier,
77
waiterState: string
88
): CallExpression => ({
99
type: "CallExpression",
1010
callee: {
1111
type: "MemberExpression",
12-
object: v2ClientId,
12+
object: clientId,
1313
property: { type: "Identifier", name: "waitFor" },
1414
},
1515
// @ts-expect-error Type 'string' is not assignable to type 'RegExp'

src/transforms/v2-to-v3/modules/removeV2ClientModule.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Collection, JSCodeshift } from "jscodeshift";
22

33
import { PACKAGE_NAME } from "../config";
4-
import { getV2ClientTypeNames } from "../ts-type";
4+
import { getClientTypeNames } from "../ts-type";
55
import { getClientDeepImportPath } from "../utils";
66
import { hasImportEquals } from "./hasImportEquals";
77
import { hasRequire } from "./hasRequire";
@@ -39,10 +39,10 @@ export const removeV2ClientModule = (
3939
removeImportDefault(j, source, defaultOptions);
4040
removeImportNamed(j, source, namedOptions);
4141

42-
const v2ClientTypeNames = getV2ClientTypeNames(j, source, options);
43-
for (const v2ClientTypeName of v2ClientTypeNames) {
42+
const clientTypeNames = getClientTypeNames(j, source, options);
43+
for (const clientTypeName of clientTypeNames) {
4444
removeImportNamed(j, source, {
45-
localName: v2ClientTypeName,
45+
localName: clientTypeName,
4646
sourceValue: deepImportPath,
4747
});
4848
}

src/transforms/v2-to-v3/ts-type/getV2ClientTypeNames.ts renamed to src/transforms/v2-to-v3/ts-type/getClientTypeNames.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Collection, Identifier, JSCodeshift, TSQualifiedName, TSTypeReference }
33
import { getImportSpecifiers } from "../modules";
44
import { getClientDeepImportPath, getClientTSTypeRef } from "../utils";
55

6-
export interface GetV2ClientTypeNamesOptions {
6+
export interface GetClientTypeNamesOptions {
77
v2ClientName: string;
88
v2GlobalName?: string;
99
v2ClientLocalName: string;
@@ -21,26 +21,26 @@ const getRightIdentifierName = (
2121
.filter((node) => node.type === "Identifier")
2222
.map((node) => (node as Identifier).name);
2323

24-
export const getV2ClientTypeNames = (
24+
export const getClientTypeNames = (
2525
j: JSCodeshift,
2626
source: Collection<unknown>,
27-
{ v2ClientLocalName, v2ClientName, v2GlobalName }: GetV2ClientTypeNamesOptions
27+
{ v2ClientLocalName, v2ClientName, v2GlobalName }: GetClientTypeNamesOptions
2828
): string[] => {
29-
const v2ClientTypeNames = [];
29+
const clientTypeNames = [];
3030

3131
if (v2GlobalName) {
3232
const globalTSTypeRef = getClientTSTypeRef({
3333
v2ClientName,
3434
v2GlobalName,
3535
withoutRightSection: true,
3636
});
37-
v2ClientTypeNames.push(...getRightIdentifierName(j, source, globalTSTypeRef));
37+
clientTypeNames.push(...getRightIdentifierName(j, source, globalTSTypeRef));
3838
}
3939

4040
const clientTSTypeRef = getClientTSTypeRef({ v2ClientLocalName, withoutRightSection: true });
41-
v2ClientTypeNames.push(...getRightIdentifierName(j, source, clientTSTypeRef));
41+
clientTypeNames.push(...getRightIdentifierName(j, source, clientTSTypeRef));
4242

43-
v2ClientTypeNames.push(
43+
clientTypeNames.push(
4444
...getImportSpecifiers(j, source, getClientDeepImportPath(v2ClientName))
4545
.filter(
4646
(importSpecifier) =>
@@ -51,5 +51,5 @@ export const getV2ClientTypeNames = (
5151
.map((importSpecifier) => (importSpecifier.local as Identifier).name)
5252
);
5353

54-
return [...new Set(v2ClientTypeNames)];
54+
return [...new Set(clientTypeNames)];
5555
};

src/transforms/v2-to-v3/ts-type/getV3ClientTypesCount.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Collection, JSCodeshift } from "jscodeshift";
22

33
import { CLIENT_TYPES_MAP } from "../config";
4-
import { getV2ClientTypeNames, GetV2ClientTypeNamesOptions } from "./getV2ClientTypeNames";
4+
import { getClientTypeNames, GetClientTypeNamesOptions } from "./getClientTypeNames";
55

66
const arrayBracketRegex = /<([\w]+)>/g;
77
const recordBracketRegex = /<string, ([\w]+)>/g;
@@ -17,19 +17,19 @@ const getTypesFromString = (str: string): string[] => {
1717
export const getV3ClientTypesCount = (
1818
j: JSCodeshift,
1919
source: Collection<unknown>,
20-
options: GetV2ClientTypeNamesOptions
20+
options: GetClientTypeNamesOptions
2121
) => {
2222
const { v2ClientName } = options;
2323

24-
const v2ClientTypeNames = getV2ClientTypeNames(j, source, options);
24+
const clientTypeNames = getClientTypeNames(j, source, options);
2525
const clientTypesMap = CLIENT_TYPES_MAP[v2ClientName];
2626
const v3ClientUnavailableTypes = Object.keys(clientTypesMap);
2727

28-
return v2ClientTypeNames.filter((v2ClientTypeName) => {
29-
if (!v3ClientUnavailableTypes.includes(v2ClientTypeName)) {
28+
return clientTypeNames.filter((clientTypeName) => {
29+
if (!v3ClientUnavailableTypes.includes(clientTypeName)) {
3030
return true;
3131
}
32-
const typesFromString = getTypesFromString(clientTypesMap[v2ClientTypeName]);
32+
const typesFromString = getTypesFromString(clientTypesMap[clientTypeName]);
3333
return typesFromString.some((type) => !nativeTypes.includes(type));
3434
}).length;
3535
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * from "./getV2ClientTypeNames";
1+
export * from "./getClientTypeNames";
22
export * from "./getV3ClientTypeReference";
33
export * from "./getV3ClientTypesCount";
44
export * from "./replaceTSTypeReference";

src/transforms/v2-to-v3/ts-type/replaceTSTypeReference.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Collection, Identifier, JSCodeshift, TSQualifiedName, TSTypeReference } from "jscodeshift";
22

33
import { getClientTSTypeRef } from "../utils";
4-
import { getV2ClientTypeNames } from "./getV2ClientTypeNames";
4+
import { getClientTypeNames } from "./getClientTypeNames";
55
import { getV3ClientTypeReference } from "./getV3ClientTypeReference";
66

77
export interface ReplaceTSTypeReferenceOptions {
@@ -56,15 +56,15 @@ export const replaceTSTypeReference = (
5656
});
5757

5858
// Replace type reference to client type with modules.
59-
const v2ClientTypeNames = getV2ClientTypeNames(j, source, {
59+
const clientTypeNames = getClientTypeNames(j, source, {
6060
v2ClientLocalName,
6161
v2ClientName,
6262
v2GlobalName,
6363
});
6464

65-
for (const v2ClientTypeName of v2ClientTypeNames) {
65+
for (const clientTypeName of clientTypeNames) {
6666
source
67-
.find(j.TSTypeReference, { typeName: { type: "Identifier", name: v2ClientTypeName } })
67+
.find(j.TSTypeReference, { typeName: { type: "Identifier", name: clientTypeName } })
6868
.replaceWith((v2ClientType) => {
6969
const v2ClientTypeName = getIdentifierName(v2ClientType.node);
7070
return getV3ClientTypeReference(j, { v2ClientName, v2ClientTypeName, v2ClientLocalName });

0 commit comments

Comments
 (0)