fix type errors for non-existent hyperglass.json file

This commit is contained in:
thatmattlove 2024-03-01 23:58:55 -05:00
parent 16b4f60aef
commit 125d73d281
2 changed files with 12 additions and 9 deletions

View file

@ -1,18 +1,19 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { Meta, Layout } from '~/components';
import { HyperglassProvider } from '~/context';
import * as config from '../hyperglass.json';
import type { AppProps } from 'next/app'; import type { AppProps } from 'next/app';
import { Layout, Meta } from '~/components';
import { HyperglassProvider } from '~/context';
import type { Config } from '~/types'; import type { Config } from '~/types';
// Declare imported JSON type to avoid type errors when file is not present (testing).
const config = (await import('../hyperglass.json')) as unknown as Config;
const queryClient = new QueryClient(); const queryClient = new QueryClient();
const App = (props: AppProps): JSX.Element => { const App = (props: AppProps): JSX.Element => {
const { Component, pageProps } = props; const { Component, pageProps } = props;
return ( return (
<QueryClientProvider client={queryClient}> <QueryClientProvider client={queryClient}>
<HyperglassProvider config={config as unknown as Config}> <HyperglassProvider config={config}>
<Meta /> <Meta />
<Layout> <Layout>
<Component {...pageProps} /> <Component {...pageProps} />

View file

@ -1,13 +1,15 @@
import fs from 'fs'; import fs from 'fs';
import Document, { Html, Head, Main, NextScript } from 'next/document';
import { ColorModeScript } from '@chakra-ui/react'; import { ColorModeScript } from '@chakra-ui/react';
import { CustomJavascript, CustomHtml, Favicon } from '~/elements'; import Document, { Html, Head, Main, NextScript } from 'next/document';
import { CustomHtml, CustomJavascript, Favicon } from '~/elements';
import { googleFontUrl } from '~/util'; import { googleFontUrl } from '~/util';
import favicons from '../favicon-formats'; import favicons from '../favicon-formats';
import config from '../hyperglass.json';
import type { DocumentContext, DocumentInitialProps } from 'next/document'; import type { DocumentContext, DocumentInitialProps } from 'next/document';
import type { ThemeConfig } from '~/types'; import type { Config, ThemeConfig } from '~/types';
// Declare imported JSON type to avoid type errors when file is not present (testing).
const config = (await import('../hyperglass.json')) as unknown as Config;
interface DocumentExtra interface DocumentExtra
extends DocumentInitialProps, extends DocumentInitialProps,