From a0522f790cf207d36598ad7e88d3eb64f4790424 Mon Sep 17 00:00:00 2001 From: Dhairya Majmudar <2022kuec2045@iiitkota.ac.in> Date: Thu, 3 Oct 2024 01:29:34 +0530 Subject: [PATCH 1/4] REF: refactoring Extensions.tsx file --- library/src/components/Extensions.tsx | 9 +++------ library/src/helpers/schema.ts | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/library/src/components/Extensions.tsx b/library/src/components/Extensions.tsx index b98d44c00..f3b37f97b 100644 --- a/library/src/components/Extensions.tsx +++ b/library/src/components/Extensions.tsx @@ -1,16 +1,13 @@ -/* eslint-disable @typescript-eslint/no-unsafe-return */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ - import React from 'react'; import { Schema } from './Schema'; +import type { SchemaInterface } from '@asyncapi/parser'; import { SchemaHelpers } from '../helpers'; interface Props { name?: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - item: any; + item: SchemaInterface; } export const Extensions: React.FunctionComponent = ({ @@ -22,7 +19,7 @@ export const Extensions: React.FunctionComponent = ({ return null; } - const schema = SchemaHelpers.jsonToSchema(extensions); + const schema: SchemaInterface = SchemaHelpers.jsonToSchema(extensions); return ( schema && ( diff --git a/library/src/helpers/schema.ts b/library/src/helpers/schema.ts index 12846eab9..af11cb632 100644 --- a/library/src/helpers/schema.ts +++ b/library/src/helpers/schema.ts @@ -264,7 +264,7 @@ export class SchemaHelpers { } // eslint-disable-next-line @typescript-eslint/no-explicit-any - static jsonToSchema(value: any): any { + static jsonToSchema(value: any): SchemaInterface { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const json = this.jsonFieldToSchema(value); // eslint-disable-next-line @typescript-eslint/no-unsafe-argument From 0431f587c57028d3984a226bd9fb561d6ee7bb0f Mon Sep 17 00:00:00 2001 From: Dhairya Majmudar <2022kuec2045@iiitkota.ac.in> Date: Thu, 3 Oct 2024 01:41:41 +0530 Subject: [PATCH 2/4] fix: types refactoring --- library/src/components/Schema.tsx | 4 +--- library/src/contexts/useSpec.ts | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/library/src/components/Schema.tsx b/library/src/components/Schema.tsx index 0ccb5bb0d..442fa9b93 100644 --- a/library/src/components/Schema.tsx +++ b/library/src/components/Schema.tsx @@ -512,9 +512,7 @@ const AdditionalItems: React.FunctionComponent = ({ if (!Array.isArray(schema.items())) { return null; } - - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any - const additionalItems = schema.additionalItems() as any; + const additionalItems = schema.additionalItems(); if (additionalItems === true || additionalItems === undefined) { return (

diff --git a/library/src/contexts/useSpec.ts b/library/src/contexts/useSpec.ts index 92b863166..b027d8a21 100644 --- a/library/src/contexts/useSpec.ts +++ b/library/src/contexts/useSpec.ts @@ -2,8 +2,7 @@ import React, { useContext } from 'react'; import { AsyncAPIDocumentInterface } from '@asyncapi/parser'; export const SpecificationContext = - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any - React.createContext(null as any); + React.createContext(null as never); export function useSpec() { return useContext(SpecificationContext); From 4945997dc1fb6def1f37b2d2ce08df1f8a5df420 Mon Sep 17 00:00:00 2001 From: Dhairya Majmudar <2022kuec2045@iiitkota.ac.in> Date: Thu, 3 Oct 2024 01:55:49 +0530 Subject: [PATCH 3/4] fix: types refactoring --- web-component/src/AsyncApiWebComponent.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/web-component/src/AsyncApiWebComponent.tsx b/web-component/src/AsyncApiWebComponent.tsx index 9bcb139ab..92b2c6267 100644 --- a/web-component/src/AsyncApiWebComponent.tsx +++ b/web-component/src/AsyncApiWebComponent.tsx @@ -26,12 +26,10 @@ function retrieveSchemaProp( let schemaFetchOptions = props.schemaFetchOptions; if (!schemaUrl || schemaUrl === 'undefined') { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any - schemaUrl = undefined as any; + schemaUrl = undefined; } if (!schemaFetchOptions) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any - schemaFetchOptions = undefined as any; + schemaFetchOptions = undefined; } let schema = props.schema || {}; @@ -50,7 +48,7 @@ function retrieveSchemaProp( export interface AsyncApiWebComponentProps extends AsyncApiProps { cssImportPath?: string; schemaFetchOptions?: RequestInit; - schemaUrl: string; + schemaUrl?: string; } export class AsyncApiWebComponent extends React.Component { From 1552664dfaf9376956ca7d4cfb800ae1d3f010a6 Mon Sep 17 00:00:00 2001 From: Dhairya Majmudar <2022kuec2045@iiitkota.ac.in> Date: Tue, 8 Oct 2024 21:42:32 +0530 Subject: [PATCH 4/4] fixing build failures --- library/src/components/Extensions.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/src/components/Extensions.tsx b/library/src/components/Extensions.tsx index f3b37f97b..5d8a87f0e 100644 --- a/library/src/components/Extensions.tsx +++ b/library/src/components/Extensions.tsx @@ -1,13 +1,15 @@ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ import React from 'react'; import { Schema } from './Schema'; -import type { SchemaInterface } from '@asyncapi/parser'; import { SchemaHelpers } from '../helpers'; interface Props { name?: string; - item: SchemaInterface; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + item: any; } export const Extensions: React.FunctionComponent = ({ @@ -19,7 +21,7 @@ export const Extensions: React.FunctionComponent = ({ return null; } - const schema: SchemaInterface = SchemaHelpers.jsonToSchema(extensions); + const schema = SchemaHelpers.jsonToSchema(extensions); return ( schema && (