From e8343e7f8225e12ee9eba6031be172b0ba947e98 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Dec 2025 21:46:48 +0000 Subject: [PATCH] Use non-null assertions in for loops and Array/ReadonlyArray syntax - Replaced unnecessary null checks with non-null assertions (!) in for loops accessing array items - Changed all [] type syntax to Array or ReadonlyArray format for consistency Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .../openapi-ts/src/openApi/3.0.x/parser/schema.ts | 11 ++++------- .../openapi-ts/src/openApi/3.1.x/parser/schema.ts | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts b/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts index 63b9f3242..161943385 100644 --- a/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts +++ b/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts @@ -91,8 +91,8 @@ const getAllDiscriminatorValues = ({ context: Context; discriminator: NonNullable; schemaRef: string; -}): string[] => { - const values: string[] = []; +}): Array => { + const values: Array = []; // Check each entry in the discriminator mapping for (const [value, mappedSchemaRef] of Object.entries( @@ -405,7 +405,7 @@ const parseAllOf = ({ isRequired: boolean; values: ReadonlyArray; }; - const discriminatorsToAdd: DiscriminatorInfo[] = []; + const discriminatorsToAdd: Array = []; const addedDiscriminators = new Set(); for (const compositionSchema of compositionSchemas) { @@ -527,10 +527,7 @@ const parseAllOf = ({ // The inline schema should be the last non-$ref item in schemaItems let inlineSchema: IR.SchemaObject | undefined; for (let i = schemaItems.length - 1; i >= 0; i--) { - const item = schemaItems[i]; - if (!item) { - continue; - } + const item = schemaItems[i]!; // Check if this is not a $ref schema by looking for properties or checking if it came from an inline schema if (item.type === 'object' || item.properties) { inlineSchema = item; diff --git a/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts b/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts index 18c553fa9..abcf3b4dc 100644 --- a/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts +++ b/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts @@ -95,8 +95,8 @@ const getAllDiscriminatorValues = ({ context: Context; discriminator: NonNullable; schemaRef: string; -}): string[] => { - const values: string[] = []; +}): Array => { + const values: Array = []; // Check each entry in the discriminator mapping for (const [value, mappedSchemaRef] of Object.entries( @@ -487,7 +487,7 @@ const parseAllOf = ({ isRequired: boolean; values: ReadonlyArray; }; - const discriminatorsToAdd: DiscriminatorInfo[] = []; + const discriminatorsToAdd: Array = []; const addedDiscriminators = new Set(); for (const compositionSchema of compositionSchemas) { @@ -608,10 +608,7 @@ const parseAllOf = ({ // The inline schema should be the last non-$ref item in schemaItems let inlineSchema: IR.SchemaObject | undefined; for (let i = schemaItems.length - 1; i >= 0; i--) { - const item = schemaItems[i]; - if (!item) { - continue; - } + const item = schemaItems[i]!; // Check if this is not a $ref schema by looking for properties or checking if it came from an inline schema if (item.type === 'object' || item.properties) { inlineSchema = item; -- 2.51.2