Replaced Exclude with NonNullable
This commit is contained in:
		
							parent
							
								
									2e62f25fb5
								
							
						
					
					
						commit
						ed7198807f
					
				| @ -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<Props>): 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 | ||||
|                   ) | ||||
|  | ||||
| @ -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<Props>): JSX.Element { | ||||
|     languages: languages, | ||||
|     languageExtractor: (item) => item.language?.data?.attributes?.code, | ||||
|     transform: (item) => { | ||||
|       const newItem = { ...item } as Exclude<Props["scanSet"][number], null>; | ||||
|       const newItem = { ...item } as NonNullable<Props["scanSet"][number]>; | ||||
|       newItem.pages?.data.sort((a, b) => { | ||||
|         if (a.attributes?.url && b.attributes?.url) { | ||||
|           let aName = getAssetFilename(a.attributes.url); | ||||
|  | ||||
| @ -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"]; | ||||
|  | ||||
| @ -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<GetContentTextQuery["contents"]>["data"][number]["attributes"] | ||||
|   >["type"]; | ||||
|   categories?: Exclude< | ||||
|     Exclude< | ||||
|       GetContentTextQuery["contents"], | ||||
|       null | undefined | ||||
|     >["data"][number]["attributes"], | ||||
|     null | undefined | ||||
|   categories?: NonNullable< | ||||
|     NonNullable<GetContentTextQuery["contents"]>["data"][number]["attributes"] | ||||
|   >["categories"]; | ||||
|   thumbnail?: UploadImageFragment | null | undefined; | ||||
|   langui: AppStaticProps["langui"]; | ||||
|  | ||||
| @ -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<GetChronologyItemsQuery["chronologyItems"]>["data"][number]; | ||||
|   displayYear: boolean; | ||||
|   langui: AppStaticProps["langui"]; | ||||
| } | ||||
|  | ||||
| @ -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"]; | ||||
| } | ||||
|  | ||||
| @ -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<GetLanguagesQuery["languages"], null | undefined>["data"]; | ||||
|   currencies: NonNullable<GetCurrenciesQuery["currencies"]>["data"]; | ||||
|   languages: NonNullable<GetLanguagesQuery["languages"]>["data"]; | ||||
| }>; | ||||
| 
 | ||||
| export async function getAppStaticProps( | ||||
|  | ||||
| @ -4,7 +4,7 @@ import { Immutable } from "./types"; | ||||
| export function convertPrice( | ||||
|   pricePicker: Immutable<PricePickerFragment>, | ||||
|   targetCurrency: Immutable< | ||||
|     Exclude<GetCurrenciesQuery["currencies"], null | undefined>["data"][number] | ||||
|     NonNullable<GetCurrenciesQuery["currencies"]>["data"][number] | ||||
|   > | ||||
| ): number { | ||||
|   if ( | ||||
|  | ||||
| @ -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<SortContentProps>) { | ||||
|  | ||||
| @ -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<GetPostQuery["posts"]>["data"][number]["attributes"] | ||||
| >; | ||||
| 
 | ||||
| export interface PostWithTranslations extends Omit<Post, "translations"> { | ||||
|   translations: Exclude<Post["translations"], null | undefined>; | ||||
|   translations: NonNullable<Post["translations"]>; | ||||
| } | ||||
| 
 | ||||
| type Content = Exclude< | ||||
|   Exclude< | ||||
|     GetContentTextQuery["contents"], | ||||
|     null | undefined | ||||
|   >["data"][number]["attributes"], | ||||
|   null | undefined | ||||
| type Content = NonNullable< | ||||
|   NonNullable<GetContentTextQuery["contents"]>["data"][number]["attributes"] | ||||
| >; | ||||
| 
 | ||||
| export interface ContentWithTranslations extends Omit<Content, "translations"> { | ||||
|   translations: Exclude<Content["translations"], null | undefined>; | ||||
|   translations: NonNullable<Content["translations"]>; | ||||
| } | ||||
| 
 | ||||
| type ImmutableBlackList<T> = JSX.Element | React.ReactNode | Function; | ||||
|  | ||||
| @ -8,12 +8,8 @@ import { useEffect, useMemo, useState } from "react"; | ||||
| interface Props<T> { | ||||
|   items: Immutable<T[]>; | ||||
|   languages: AppStaticProps["languages"]; | ||||
|   languageExtractor: ( | ||||
|     item: Exclude<Immutable<T>, null | undefined> | ||||
|   ) => string | undefined; | ||||
|   transform?: ( | ||||
|     item: Exclude<Immutable<T>, null | undefined> | ||||
|   ) => Exclude<Immutable<T>, null | undefined>; | ||||
|   languageExtractor: (item: NonNullable<Immutable<T>>) => string | undefined; | ||||
|   transform?: (item: NonNullable<Immutable<T>>) => NonNullable<Immutable<T>>; | ||||
| } | ||||
| 
 | ||||
| function getPreferredLanguage( | ||||
|  | ||||
| @ -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"]; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -21,7 +21,7 @@ import { GetStaticPropsContext } from "next"; | ||||
| import { useState } from "react"; | ||||
| 
 | ||||
| interface Props extends AppStaticProps { | ||||
|   videos: Exclude<GetVideosPreviewQuery["videos"], null | undefined>["data"]; | ||||
|   videos: NonNullable<GetVideosPreviewQuery["videos"]>["data"]; | ||||
| } | ||||
| 
 | ||||
| export default function Videos(props: Props): JSX.Element { | ||||
|  | ||||
| @ -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<GetVideoQuery["videos"]>["data"][number]["attributes"] | ||||
|   >; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -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"]; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -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"]; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -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<GetLibraryItemsPreviewQuery["libraryItems"]>["data"]; | ||||
| } | ||||
| 
 | ||||
| type GroupLibraryItems = Map<string, Immutable<Props["items"]>>; | ||||
|  | ||||
| @ -16,7 +16,7 @@ import { GetStaticPropsContext } from "next"; | ||||
| import { useState } from "react"; | ||||
| 
 | ||||
| interface Props extends AppStaticProps { | ||||
|   posts: Exclude<GetPostsPreviewQuery["posts"], null | undefined>["data"]; | ||||
|   posts: NonNullable<GetPostsPreviewQuery["posts"]>["data"]; | ||||
| } | ||||
| 
 | ||||
| export default function News(props: Immutable<Props>): JSX.Element { | ||||
|  | ||||
| @ -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<GetErasQuery["chronologyEras"]>["data"]; | ||||
| } | ||||
| 
 | ||||
| export default function Chronology(props: Props): JSX.Element { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 DrMint
						DrMint