Skip to content

Commit

Permalink
fix: Nullable fields can be undefined in Relay.js 16
Browse files Browse the repository at this point in the history
  • Loading branch information
yomybaby committed Nov 1, 2023
1 parent 9224c4f commit 7c32867
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion react/src/components/EndpointStatusTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react';
import { useFragment } from 'react-relay';

interface EndpointStatusTagProps {
endpointFrgmt: EndpointStatusTagFragment$key | null;
endpointFrgmt?: EndpointStatusTagFragment$key | null;
}
const EndpointStatusTag: React.FC<EndpointStatusTagProps> = ({
endpointFrgmt,
Expand Down
2 changes: 1 addition & 1 deletion react/src/components/ImageMetaIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useBackendaiImageMetaData } from '../hooks';
import React from 'react';

const ImageMetaIcon: React.FC<{
image: string | null;
image?: string | null;
style?: React.CSSProperties;
border?: boolean;
alt?: string | null;
Expand Down
2 changes: 1 addition & 1 deletion react/src/components/ModelServiceSettingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useTranslation } from 'react-i18next';
import { useFragment } from 'react-relay';

interface Props extends BAIModalProps {
endpointFrgmt: ModelServiceSettingModal_endpoint$key | null;
endpointFrgmt?: ModelServiceSettingModal_endpoint$key | null;
onRequestClose: (success?: boolean) => void;
}

Expand Down
2 changes: 1 addition & 1 deletion react/src/components/SessionKernelTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useBackendaiImageMetaData } from '../hooks';
import React from 'react';

const SessionKernelTag: React.FC<{
image: string | null;
image?: string | null;
style?: React.CSSProperties;
border?: boolean;
}> = ({ image, style = {} }, bordered) => {
Expand Down
4 changes: 2 additions & 2 deletions react/src/helper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ export const offset_to_cursor = (offset: number): string => {
return window.btoa(`arrayconnection:${offset}`);
};

export function filterNonNullItems<T extends { [key: string]: any }>(
arr: ReadonlyArray<T | null> | null | undefined,
export function filterNonNullItems<T>(

Check warning on line 215 in react/src/helper/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
arr: ReadonlyArray<T | null | undefined> | null | undefined,
): T[] {
if (arr === null || arr === undefined) {
return [];
Expand Down
4 changes: 2 additions & 2 deletions react/src/pages/RoutingListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ const RoutingListPage: React.FC<RoutingListPageProps> = () => {
});
const openSessionErrorModal = (session: string) => {
if (endpoint === null) return;
const { errors } = endpoint;
const firstMatchedSessionError = errors.find(
const errors = endpoint?.errors;

Check warning on line 179 in react/src/pages/RoutingListPage.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
const firstMatchedSessionError = errors?.find(
({ session_id }) => session === session_id,
);

Check warning on line 182 in react/src/pages/RoutingListPage.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
setSelectedSessionErrorForModal(firstMatchedSessionError || null);
Expand Down

0 comments on commit 7c32867

Please sign in to comment.