Skip to content

Commit 1e1aec4

Browse files
committed
update file to fix ts-ignore errors
1 parent 0a25a4f commit 1e1aec4

File tree

2 files changed

+16
-35
lines changed

2 files changed

+16
-35
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"clean": "lerna run clean",
1919
"build": "lerna run build --stream",
2020
"lint": "lerna run lint --parallel",
21+
"test": "NODE_OPTIONS=--no-deprecation jest",
2122
"symlink": "symlink-workspace --logLevel error",
2223
"postinstall": "yarn symlink"
2324
},

packages/schema-sdk/src/openapi.ts

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ const shouldIncludeOperation = (
6868
path: string,
6969
method: MethodType
7070
) => {
71-
// @ts-ignore
72-
const operation: Operation = pathItem[method];
71+
const operation: Operation | undefined = pathItem[method];
7372

7473
if (!operation) return false;
7574

@@ -80,7 +79,7 @@ const shouldIncludeOperation = (
8079

8180
if (!shouldIncludeByPath) return false;
8281

83-
const shouldIncludeByTag = operation.tags.some((tag) =>
82+
const shouldIncludeByTag = (operation.tags || []).some((tag) =>
8483
shouldInclude(tag, {
8584
include: options.paths?.includeTags ?? [],
8685
exclude: options.paths?.excludeTags ?? [],
@@ -313,32 +312,19 @@ export function generateOpenApiParams(
313312
['get', 'post', 'put', 'delete', 'options', 'head', 'patch'].forEach(
314313
(method) => {
315314
if (Object.prototype.hasOwnProperty.call(pathItem, method)) {
316-
// @ts-ignore
317-
const operation: Operation = pathItem[method];
318-
if (!shouldIncludeOperation(options, pathItem, path, method as any))
315+
const operation: Operation | undefined = pathItem[method as keyof OpenAPIPathItem] as Operation | undefined;
316+
if (!operation || !shouldIncludeOperation(options, pathItem, path, method as any))
319317
return;
320318

321-
// @ts-ignore
322-
const methodType:
323-
| 'get'
324-
| 'post'
325-
| 'put'
326-
| 'delete'
327-
| 'options'
328-
| 'head'
329-
| 'patch' = method;
319+
const methodType = method as MethodType;
330320

331-
// @ts-ignore
332-
const opParamMethod: ParameterInterfaces = opParams[method];
321+
const opParamMethod: ParameterInterfaces = opParams[methodType];
333322

334323
const props: t.TSPropertySignature[] = [];
335324

336325
Object.keys(opParamMethod).forEach((key) => {
337-
// @ts-ignore
338-
const params: Parameter[] = opParamMethod[key];
339-
// @ts-ignore
340-
const paramType: 'query' | 'body' | 'formData' | 'header' | 'path' =
341-
key;
326+
const params: Parameter[] = opParamMethod[key as keyof ParameterInterfaces];
327+
const paramType = key as 'query' | 'body' | 'formData' | 'header' | 'path';
342328

343329
// only include body sometimes
344330
if (
@@ -446,13 +432,11 @@ export function getOpenApiParams(
446432
['get', 'post', 'put', 'delete', 'options', 'head', 'patch'].forEach(
447433
(method) => {
448434
if (Object.prototype.hasOwnProperty.call(pathItem, method)) {
449-
// @ts-ignore
450-
const operation: Operation = pathItem[method];
451-
if (!shouldIncludeOperation(options, pathItem, path, method as any))
435+
const operation: Operation | undefined = pathItem[method as keyof OpenAPIPathItem] as Operation | undefined;
436+
if (!operation || !shouldIncludeOperation(options, pathItem, path, method as any))
452437
return;
453438

454-
// @ts-ignore
455-
const opParamMethod: ParameterInterfaces = opParams[method];
439+
const opParamMethod: ParameterInterfaces = opParams[method as keyof OpParameterInterfaces];
456440

457441
// push Path-Level params into op
458442
opParamMethod.path.push(...opParams.pathLevel.path);
@@ -642,8 +626,7 @@ function generateGVKOpsStatements(
642626
// Extract GVK metadata from paths section (where it actually exists in many schemas)
643627
Object.entries(patchedSchema.paths).forEach(([path, pathItem]) => {
644628
METHOD_TYPES.forEach((m) => {
645-
// @ts-ignore
646-
const operation: Operation = (pathItem as any)[m];
629+
const operation: Operation | undefined = pathItem[m as keyof OpenAPIPathItem] as Operation | undefined;
647630
if (!operation || !shouldIncludeOperation(options, pathItem, path, m as any)) return;
648631

649632
// Check for GVK metadata in the operation
@@ -677,8 +660,7 @@ function generateGVKOpsStatements(
677660
const pathBaseToDef = new Map<string, string>();
678661
Object.entries(patchedSchema.paths).forEach(([path, pathItem]) => {
679662
METHOD_TYPES.forEach((m) => {
680-
// @ts-ignore
681-
const operation: Operation = (pathItem as any)[m];
663+
const operation: Operation | undefined = pathItem[m as keyof OpenAPIPathItem] as Operation | undefined;
682664
if (!operation || !shouldIncludeOperation(options, pathItem, path, m as any)) return;
683665
const retDef = getRefDefName(operation.responses?.['200']);
684666
const bodyParam = (operation.parameters || []).find((p) => p.in === 'body' && (p.schema as any)?.$ref);
@@ -695,8 +677,7 @@ function generateGVKOpsStatements(
695677
const map = new Map<string, GVKEntry>();
696678
Object.entries(patchedSchema.paths).forEach(([path, pathItem]) => {
697679
METHOD_TYPES.forEach((m) => {
698-
// @ts-ignore
699-
const operation: Operation = (pathItem as any)[m];
680+
const operation: Operation | undefined = pathItem[m as keyof OpenAPIPathItem] as Operation | undefined;
700681
if (!operation || !shouldIncludeOperation(options, pathItem, path, m as any)) return;
701682
const kind = classifyOperation(operation.operationId, m);
702683
if (kind === 'watch' || kind === 'unknown') return;
@@ -954,8 +935,7 @@ function buildInterfaceRenameMapFromSchema(
954935
// Extract GVK metadata from paths section (where it actually exists in many schemas)
955936
Object.entries(schema.paths).forEach(([path, pathItem]) => {
956937
METHOD_TYPES.forEach((m) => {
957-
// @ts-ignore
958-
const operation: Operation = (pathItem as any)[m];
938+
const operation: Operation | undefined = pathItem[m as keyof OpenAPIPathItem] as Operation | undefined;
959939
if (!operation || !shouldIncludeOperation(options, pathItem, path, m as any)) return;
960940

961941
// Check for GVK metadata in the operation

0 commit comments

Comments
 (0)