diff --git a/src/components/Library/ContentLine.tsx b/src/components/Library/ContentLine.tsx index a1af759..5d70725 100644 --- a/src/components/Library/ContentLine.tsx +++ b/src/components/Library/ContentLine.tsx @@ -7,15 +7,12 @@ import { Immutable } from "helpers/types"; import { useState } from "react"; interface Props { - content: Exclude< - Exclude< - Exclude< - GetLibraryItemQuery["libraryItems"], - null | undefined - >["data"][number]["attributes"], - null | undefined - >["contents"], - null | undefined + content: NonNullable< + NonNullable< + NonNullable< + GetLibraryItemQuery["libraryItems"] + >["data"][number]["attributes"] + >["contents"] >["data"][number]; parentSlug: string; langui: AppStaticProps["langui"]; @@ -43,7 +40,8 @@ export function ContentLine(props: Immutable): JSX.Element { ? prettyinlineTitle( content.attributes.content.data.attributes.translations[0] ?.pre_title, - content.attributes.content.data.attributes.translations[0]?.title, + content.attributes.content.data.attributes.translations[0] + ?.title, content.attributes.content.data.attributes.translations[0] ?.subtitle ) diff --git a/src/components/Library/ScanSet.tsx b/src/components/Library/ScanSet.tsx index 9b32509..95d98e3 100644 --- a/src/components/Library/ScanSet.tsx +++ b/src/components/Library/ScanSet.tsx @@ -13,38 +13,29 @@ import { useSmartLanguage } from "hooks/useSmartLanguage"; interface Props { openLightBox: (images: string[], index?: number) => void; - scanSet: Exclude< - Exclude< - Exclude< - Exclude< - Exclude< - GetLibraryItemScansQuery["libraryItems"], - null | undefined - >["data"][number]["attributes"], - null | undefined - >["contents"], - null | undefined - >["data"][number]["attributes"], - null | undefined - >["scan_set"], - null | undefined + scanSet: NonNullable< + NonNullable< + NonNullable< + NonNullable< + NonNullable< + GetLibraryItemScansQuery["libraryItems"] + >["data"][number]["attributes"] + >["contents"] + >["data"][number]["attributes"] + >["scan_set"] >; slug: string; title: string; languages: AppStaticProps["languages"]; langui: AppStaticProps["langui"]; - content: Exclude< - Exclude< - Exclude< - Exclude< - GetLibraryItemScansQuery["libraryItems"], - null | undefined - >["data"][number]["attributes"], - null | undefined - >["contents"], - null | undefined - >["data"][number]["attributes"], - null | undefined + content: NonNullable< + NonNullable< + NonNullable< + NonNullable< + GetLibraryItemScansQuery["libraryItems"] + >["data"][number]["attributes"] + >["contents"] + >["data"][number]["attributes"] >["content"]; } @@ -57,7 +48,7 @@ export function ScanSet(props: Immutable): JSX.Element { languages: languages, languageExtractor: (item) => item.language?.data?.attributes?.code, transform: (item) => { - const newItem = { ...item } as Exclude; + const newItem = { ...item } as NonNullable; newItem.pages?.data.sort((a, b) => { if (a.attributes?.url && b.attributes?.url) { let aName = getAssetFilename(a.attributes.url); diff --git a/src/components/Library/ScanSetCover.tsx b/src/components/Library/ScanSetCover.tsx index 907b73a..2c99825 100644 --- a/src/components/Library/ScanSetCover.tsx +++ b/src/components/Library/ScanSetCover.tsx @@ -14,15 +14,12 @@ import { useSmartLanguage } from "hooks/useSmartLanguage"; interface Props { openLightBox: (images: string[], index?: number) => void; - images: Exclude< - Exclude< - Exclude< - GetLibraryItemScansQuery["libraryItems"], - null | undefined - >["data"][number]["attributes"], - null | undefined - >["images"], - null | undefined + images: NonNullable< + NonNullable< + NonNullable< + GetLibraryItemScansQuery["libraryItems"] + >["data"][number]["attributes"] + >["images"] >; languages: AppStaticProps["languages"]; langui: AppStaticProps["langui"]; diff --git a/src/components/ThumbnailHeader.tsx b/src/components/ThumbnailHeader.tsx index 7e8dcc1..40f7724 100644 --- a/src/components/ThumbnailHeader.tsx +++ b/src/components/ThumbnailHeader.tsx @@ -14,19 +14,11 @@ interface Props { title: string | null | undefined; subtitle?: string | null | undefined; description?: string | null | undefined; - type?: Exclude< - Exclude< - GetContentTextQuery["contents"], - null | undefined - >["data"][number]["attributes"], - null | undefined + type?: NonNullable< + NonNullable["data"][number]["attributes"] >["type"]; - categories?: Exclude< - Exclude< - GetContentTextQuery["contents"], - null | undefined - >["data"][number]["attributes"], - null | undefined + categories?: NonNullable< + NonNullable["data"][number]["attributes"] >["categories"]; thumbnail?: UploadImageFragment | null | undefined; langui: AppStaticProps["langui"]; diff --git a/src/components/Wiki/Chronology/ChronologyItemComponent.tsx b/src/components/Wiki/Chronology/ChronologyItemComponent.tsx index 4b3fc5b..7f5c4c0 100644 --- a/src/components/Wiki/Chronology/ChronologyItemComponent.tsx +++ b/src/components/Wiki/Chronology/ChronologyItemComponent.tsx @@ -9,10 +9,7 @@ import { getStatusDescription } from "helpers/others"; import { Immutable } from "helpers/types"; interface Props { - item: Exclude< - GetChronologyItemsQuery["chronologyItems"], - null | undefined - >["data"][number]; + item: NonNullable["data"][number]; displayYear: boolean; langui: AppStaticProps["langui"]; } diff --git a/src/components/Wiki/Chronology/ChronologyYearComponent.tsx b/src/components/Wiki/Chronology/ChronologyYearComponent.tsx index 5758e65..c9b6daf 100644 --- a/src/components/Wiki/Chronology/ChronologyYearComponent.tsx +++ b/src/components/Wiki/Chronology/ChronologyYearComponent.tsx @@ -5,9 +5,8 @@ import { Immutable } from "helpers/types"; interface Props { year: number; - items: Exclude< - GetChronologyItemsQuery["chronologyItems"], - null | undefined + items: NonNullable< + GetChronologyItemsQuery["chronologyItems"] >["data"][number][]; langui: AppStaticProps["langui"]; } diff --git a/src/graphql/getAppStaticProps.ts b/src/graphql/getAppStaticProps.ts index 5b276d5..fee9a66 100644 --- a/src/graphql/getAppStaticProps.ts +++ b/src/graphql/getAppStaticProps.ts @@ -8,18 +8,13 @@ import { Immutable } from "helpers/types"; import { GetStaticPropsContext } from "next"; export type AppStaticProps = Immutable<{ - langui: Exclude< - Exclude< - GetWebsiteInterfaceQuery["websiteInterfaces"], - null | undefined - >["data"][number]["attributes"], - null | undefined + langui: NonNullable< + NonNullable< + GetWebsiteInterfaceQuery["websiteInterfaces"] + >["data"][number]["attributes"] >; - currencies: Exclude< - GetCurrenciesQuery["currencies"], - null | undefined - >["data"]; - languages: Exclude["data"]; + currencies: NonNullable["data"]; + languages: NonNullable["data"]; }>; export async function getAppStaticProps( diff --git a/src/helpers/numbers.ts b/src/helpers/numbers.ts index 252d8e5..0448cc3 100644 --- a/src/helpers/numbers.ts +++ b/src/helpers/numbers.ts @@ -4,7 +4,7 @@ import { Immutable } from "./types"; export function convertPrice( pricePicker: Immutable, targetCurrency: Immutable< - Exclude["data"][number] + NonNullable["data"][number] > ): number { if ( diff --git a/src/helpers/others.ts b/src/helpers/others.ts index 1745fce..d6f1197 100644 --- a/src/helpers/others.ts +++ b/src/helpers/others.ts @@ -7,19 +7,15 @@ import { AppStaticProps } from "../graphql/getAppStaticProps"; import { Immutable } from "./types"; type SortContentProps = - | Exclude< - Exclude< - GetLibraryItemQuery["libraryItems"], - null | undefined - >["data"][number]["attributes"], - null | undefined + | NonNullable< + NonNullable< + GetLibraryItemQuery["libraryItems"] + >["data"][number]["attributes"] >["contents"] - | Exclude< - Exclude< - GetLibraryItemScansQuery["libraryItems"], - null | undefined - >["data"][number]["attributes"], - null | undefined + | NonNullable< + NonNullable< + GetLibraryItemScansQuery["libraryItems"] + >["data"][number]["attributes"] >["contents"]; export function sortContent(contents: Immutable) { diff --git a/src/helpers/types.ts b/src/helpers/types.ts index 778d7d9..eb6fe98 100644 --- a/src/helpers/types.ts +++ b/src/helpers/types.ts @@ -1,28 +1,20 @@ import { GetContentTextQuery, GetPostQuery } from "graphql/generated"; import React from "react"; -type Post = Exclude< - Exclude< - GetPostQuery["posts"], - null | undefined - >["data"][number]["attributes"], - null | undefined +type Post = NonNullable< + NonNullable["data"][number]["attributes"] >; export interface PostWithTranslations extends Omit { - translations: Exclude; + translations: NonNullable; } -type Content = Exclude< - Exclude< - GetContentTextQuery["contents"], - null | undefined - >["data"][number]["attributes"], - null | undefined +type Content = NonNullable< + NonNullable["data"][number]["attributes"] >; export interface ContentWithTranslations extends Omit { - translations: Exclude; + translations: NonNullable; } type ImmutableBlackList = JSX.Element | React.ReactNode | Function; diff --git a/src/hooks/useSmartLanguage.tsx b/src/hooks/useSmartLanguage.tsx index e13ecff..4936e97 100644 --- a/src/hooks/useSmartLanguage.tsx +++ b/src/hooks/useSmartLanguage.tsx @@ -8,12 +8,8 @@ import { useEffect, useMemo, useState } from "react"; interface Props { items: Immutable; languages: AppStaticProps["languages"]; - languageExtractor: ( - item: Exclude, null | undefined> - ) => string | undefined; - transform?: ( - item: Exclude, null | undefined> - ) => Exclude, null | undefined>; + languageExtractor: (item: NonNullable>) => string | undefined; + transform?: (item: NonNullable>) => NonNullable>; } function getPreferredLanguage( diff --git a/src/pages/archives/videos/c/[uid].tsx b/src/pages/archives/videos/c/[uid].tsx index e822908..0d18307 100644 --- a/src/pages/archives/videos/c/[uid].tsx +++ b/src/pages/archives/videos/c/[uid].tsx @@ -23,9 +23,8 @@ import { import { useState } from "react"; interface Props extends AppStaticProps { - channel: Exclude< - GetVideoChannelQuery["videoChannels"], - null | undefined + channel: NonNullable< + GetVideoChannelQuery["videoChannels"] >["data"][number]["attributes"]; } diff --git a/src/pages/archives/videos/index.tsx b/src/pages/archives/videos/index.tsx index c7759b0..2b3201d 100644 --- a/src/pages/archives/videos/index.tsx +++ b/src/pages/archives/videos/index.tsx @@ -21,7 +21,7 @@ import { GetStaticPropsContext } from "next"; import { useState } from "react"; interface Props extends AppStaticProps { - videos: Exclude["data"]; + videos: NonNullable["data"]; } export default function Videos(props: Props): JSX.Element { diff --git a/src/pages/archives/videos/v/[uid].tsx b/src/pages/archives/videos/v/[uid].tsx index de984ac..3b7efe0 100644 --- a/src/pages/archives/videos/v/[uid].tsx +++ b/src/pages/archives/videos/v/[uid].tsx @@ -26,12 +26,8 @@ import { } from "next"; interface Props extends AppStaticProps { - video: Exclude< - Exclude< - GetVideoQuery["videos"], - null | undefined - >["data"][number]["attributes"], - null | undefined + video: NonNullable< + NonNullable["data"][number]["attributes"] >; } diff --git a/src/pages/library/[slug]/index.tsx b/src/pages/library/[slug]/index.tsx index 801db76..7886f0f 100644 --- a/src/pages/library/[slug]/index.tsx +++ b/src/pages/library/[slug]/index.tsx @@ -45,13 +45,11 @@ import { import { useState } from "react"; interface Props extends AppStaticProps { - item: Exclude< - GetLibraryItemQuery["libraryItems"], - null | undefined + item: NonNullable< + GetLibraryItemQuery["libraryItems"] >["data"][number]["attributes"]; - itemId: Exclude< - GetLibraryItemQuery["libraryItems"], - null | undefined + itemId: NonNullable< + GetLibraryItemQuery["libraryItems"] >["data"][number]["id"]; } diff --git a/src/pages/library/[slug]/scans.tsx b/src/pages/library/[slug]/scans.tsx index f37d841..ce183dc 100644 --- a/src/pages/library/[slug]/scans.tsx +++ b/src/pages/library/[slug]/scans.tsx @@ -26,13 +26,11 @@ import { } from "next"; interface Props extends AppStaticProps { - item: Exclude< - GetLibraryItemScansQuery["libraryItems"], - null | undefined + item: NonNullable< + GetLibraryItemScansQuery["libraryItems"] >["data"][number]["attributes"]; - itemId: Exclude< - GetLibraryItemScansQuery["libraryItems"], - null | undefined + itemId: NonNullable< + GetLibraryItemScansQuery["libraryItems"] >["data"][number]["id"]; } diff --git a/src/pages/library/index.tsx b/src/pages/library/index.tsx index ab5421e..70851c8 100644 --- a/src/pages/library/index.tsx +++ b/src/pages/library/index.tsx @@ -23,10 +23,7 @@ import { GetStaticPropsContext } from "next"; import { useEffect, useState } from "react"; interface Props extends AppStaticProps { - items: Exclude< - GetLibraryItemsPreviewQuery["libraryItems"], - null | undefined - >["data"]; + items: NonNullable["data"]; } type GroupLibraryItems = Map>; diff --git a/src/pages/news/index.tsx b/src/pages/news/index.tsx index 416af55..e1b51ad 100644 --- a/src/pages/news/index.tsx +++ b/src/pages/news/index.tsx @@ -16,7 +16,7 @@ import { GetStaticPropsContext } from "next"; import { useState } from "react"; interface Props extends AppStaticProps { - posts: Exclude["data"]; + posts: NonNullable["data"]; } export default function News(props: Immutable): JSX.Element { diff --git a/src/pages/wiki/chronology.tsx b/src/pages/wiki/chronology.tsx index 5dd81a0..a867a01 100644 --- a/src/pages/wiki/chronology.tsx +++ b/src/pages/wiki/chronology.tsx @@ -16,14 +16,10 @@ import { prettySlug } from "helpers/formatters"; import { GetStaticPropsContext } from "next"; interface Props extends AppStaticProps { - chronologyItems: Exclude< - GetChronologyItemsQuery["chronologyItems"], - null | undefined - >["data"]; - chronologyEras: Exclude< - GetErasQuery["chronologyEras"], - null | undefined + chronologyItems: NonNullable< + GetChronologyItemsQuery["chronologyItems"] >["data"]; + chronologyEras: NonNullable["data"]; } export default function Chronology(props: Props): JSX.Element {