Skip to content

Commit

Permalink
fix: help me typecheck god
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljcafonso committed Sep 27, 2024
1 parent 282a28b commit 4e90ad2
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export default function App() {
createEffect(() => {
const html = document.documentElement;
html.classList.remove("light", "dark");
html.classList.add(ctx.selectedTheme().value);
html.dataset.theme = ctx.selectedTheme().theme;
html.classList.add(ctx.selectedTheme()!.value);
html.dataset.theme = ctx.selectedTheme()!.theme;
});

return (
Expand Down
10 changes: 5 additions & 5 deletions src/data/page-state.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { createContext, ParentProps, useContext } from "solid-js";
import { SetStoreFunction, createStore } from "solid-js/store";

type ChildSection = {
text: string | undefined;
export type ChildSection = {
text?: string | null;
id: string;
level: number;
};

type ParentSection = {
text: string | undefined;
export type ParentSection = {
text?: string | null;
id: string;
level: number;
children: ChildSection[] | [];
children: ChildSection[];
};

type PageStateStore = {
Expand Down
2 changes: 1 addition & 1 deletion src/data/theme-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const ThemeProvider = (props: ParentProps) => {
});
createEffect(() => {
if (selectedTheme()?.value)
document.cookie = `theme=${selectedTheme().value};path=/;max-age=${60 * 60 * 24 * 365}`;
document.cookie = `theme=${selectedTheme()!.value};path=/;max-age=${60 * 60 * 24 * 365}`;
});
return (
<ThemeCtx.Provider
Expand Down
2 changes: 1 addition & 1 deletion src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app"));
mount(() => <StartClient />, document.getElementById("app")!);
6 changes: 4 additions & 2 deletions src/ui/eraser-link/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default function EraserOrAnchor(props: ParentProps<{ href: string }>) {

return (
<Show
when={eraserLinkData !== null}
when={eraserLinkData}
fallback={
<a
{...props}
Expand All @@ -108,7 +108,9 @@ export default function EraserOrAnchor(props: ParentProps<{ href: string }>) {
</a>
}
>
<EraserLink linkData={eraserLinkData}>{props.children}</EraserLink>
{(eraserLinkData) => (
<EraserLink linkData={eraserLinkData()}>{props.children}</EraserLink>
)}
</Show>
);
}
4 changes: 2 additions & 2 deletions src/ui/layout/table-of-contents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
type ResolvedChildren,
} from "solid-js";
import { useLocation } from "@solidjs/router";
import { usePageState } from "~/data/page-state";
import { ParentSection, usePageState } from "~/data/page-state";
import { useI18n } from "~/i18n/i18n-context";

export const TableOfContents: Component<{ children: ResolvedChildren }> = (
Expand Down Expand Up @@ -49,7 +49,7 @@ export const TableOfContents: Component<{ children: ResolvedChildren }> = (
}

const headings = document.querySelectorAll("main h2, main h3");
const sections: unknown[] = [];
const sections: ParentSection[] = [];

if (headings) {
headings.forEach((heading) => {
Expand Down
6 changes: 3 additions & 3 deletions src/ui/pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { A } from "~/ui/i18n-anchor";
import { Show, Suspense, createMemo } from "solid-js";
import flatEntries from "solid:collection/entries";
import { coreEntries } from "solid:collection";
import { useI18n } from "~/i18n/i18n-context";

/**
* temporary until we have proper types inside collections
*/
type ReferenceCollection = (typeof flatEntries)["references"];
type LearnCollection = (typeof flatEntries)["learn"];
type ReferenceCollection = (typeof coreEntries)["reference"];
type LearnCollection = (typeof coreEntries)["learn"];

type Pagination = {
collection: ReferenceCollection | LearnCollection;
Expand Down

0 comments on commit 4e90ad2

Please sign in to comment.