Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: types refactoring #1063

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
1 change: 0 additions & 1 deletion library/src/components/Extensions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line should be removed

import React from 'react';

import { Schema } from './Schema';
Expand Down
4 changes: 1 addition & 3 deletions library/src/components/Schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,7 @@ const AdditionalItems: React.FunctionComponent<AdditionalItemsProps> = ({
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 (
<p className="mt-2 text-xs text-gray-700">
Expand Down
3 changes: 1 addition & 2 deletions library/src/contexts/useSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AsyncAPIDocumentInterface>(null as any);
React.createContext<AsyncAPIDocumentInterface>(null as never);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your changes here is unnecessarily strict and semantically incorrect in this scenario. I'd suggest we use the existing type :)


export function useSpec() {
return useContext(SpecificationContext);
Expand Down
2 changes: 1 addition & 1 deletion library/src/helpers/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions web-component/src/AsyncApiWebComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {};
Expand All @@ -50,7 +48,7 @@ function retrieveSchemaProp(
export interface AsyncApiWebComponentProps extends AsyncApiProps {
cssImportPath?: string;
schemaFetchOptions?: RequestInit;
schemaUrl: string;
schemaUrl?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DhairyaMajmudar the schemaUrl is not an optional value

}

export class AsyncApiWebComponent extends React.Component<AsyncApiWebComponentProps> {
Expand Down
Loading