Skip to content

Commit 402ed5a

Browse files
committed
chore(scripts): remove type assertions from getClientReqRespTypesMap
1 parent a777b79 commit 402ed5a

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

scripts/generateClientTypesMap/getClientReqRespTypesMap.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import jscodeshift, {
2-
type Identifier,
3-
type TSFunctionType,
4-
type TSQualifiedName,
5-
type TSTypeReference,
6-
} from "jscodeshift";
1+
import jscodeshift from "jscodeshift";
72

83
import { getTypesSource } from "./getTypesSource";
94

@@ -23,58 +18,58 @@ export const getClientReqRespTypesMap = async (
2318
if (classMethod.key.name === "constructor") return;
2419
if (classMethod.key.name.startsWith("waitFor")) return;
2520

26-
const classMethodKeyName = (classMethod.key as Identifier).name;
21+
const classMethodKeyName = classMethod.key.name;
2722
const commandName = classMethodKeyName.charAt(0).toUpperCase() + classMethodKeyName.slice(1);
2823

2924
if (classMethod.params.length !== 2) return;
3025
if (classMethod.params[0].type !== "Identifier") return;
3126
if (classMethod.params[0].name !== "params") return;
3227

33-
const params = classMethod.params[0] as Identifier;
28+
const params = classMethod.params[0];
3429

3530
if (!params.typeAnnotation) return;
3631
if (!params.typeAnnotation.typeAnnotation) return;
3732
if (params.typeAnnotation.typeAnnotation.type !== "TSTypeReference") return;
38-
const paramsTypeRef = params.typeAnnotation.typeAnnotation as TSTypeReference;
33+
const paramsTypeRef = params.typeAnnotation.typeAnnotation;
3934

4035
if (!paramsTypeRef.typeName) return;
4136
if (paramsTypeRef.typeName.type !== "TSQualifiedName") return;
42-
const paramsTypeRefName = paramsTypeRef.typeName as TSQualifiedName;
37+
const paramsTypeRefName = paramsTypeRef.typeName;
4338

4439
if (!paramsTypeRefName.right) return;
4540
if (paramsTypeRefName.right.type !== "Identifier") return;
46-
const paramsTypeName = paramsTypeRefName.right as Identifier;
41+
const paramsTypeName = paramsTypeRefName.right;
4742
const requestTypeName = paramsTypeName.name;
4843

4944
clientTypesMap[requestTypeName] = `${commandName}CommandInput`;
5045

5146
if (classMethod.params[1].type !== "Identifier") return;
5247
if (classMethod.params[1].name !== "callback") return;
53-
const callback = classMethod.params[1] as Identifier;
48+
const callback = classMethod.params[1];
5449

5550
if (!callback.typeAnnotation) return;
5651
if (!callback.typeAnnotation.typeAnnotation) return;
5752
if (callback.typeAnnotation.typeAnnotation.type !== "TSFunctionType") return;
58-
const callbackTypeRef = callback.typeAnnotation.typeAnnotation as TSFunctionType;
53+
const callbackTypeRef = callback.typeAnnotation.typeAnnotation;
5954

6055
if (!callbackTypeRef.parameters) return;
6156
if (callbackTypeRef.parameters.length !== 2) return;
6257
if (callbackTypeRef.parameters[1].type !== "Identifier") return;
63-
const responseType = callbackTypeRef.parameters[1] as Identifier;
58+
const responseType = callbackTypeRef.parameters[1];
6459

6560
if (!responseType.typeAnnotation) return;
6661
if (responseType.typeAnnotation.type !== "TSTypeAnnotation") return;
6762
if (!responseType.typeAnnotation.typeAnnotation) return;
6863
if (responseType.typeAnnotation.typeAnnotation.type !== "TSTypeReference") return;
69-
const responseTypeRef = responseType.typeAnnotation.typeAnnotation as TSTypeReference;
64+
const responseTypeRef = responseType.typeAnnotation.typeAnnotation;
7065

7166
if (!responseTypeRef.typeName) return;
7267
if (responseTypeRef.typeName.type !== "TSQualifiedName") return;
73-
const responseTypeRefName = responseTypeRef.typeName as TSQualifiedName;
68+
const responseTypeRefName = responseTypeRef.typeName;
7469

7570
if (!responseTypeRefName.right) return;
7671
if (responseTypeRefName.right.type !== "Identifier") return;
77-
const responseTypeName = (responseTypeRefName.right as Identifier).name;
72+
const responseTypeName = responseTypeRefName.right.name;
7873

7974
clientTypesMap[responseTypeName] = `${commandName}CommandOutput`;
8075
});

0 commit comments

Comments
 (0)