Skip to content

Commit 7c99f30

Browse files
committed
(frontend) imrpove typing of props.children
1 parent f0fcd56 commit 7c99f30

File tree

6 files changed

+12
-18
lines changed

6 files changed

+12
-18
lines changed

frontend/src/MainApp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useParams, A } from '@solidjs/router';
2-
import { Component, For, Show, createResource, createSignal } from 'solid-js';
2+
import { Component, For, ParentProps, Show, createResource, createSignal } from 'solid-js';
33
import Header from './components/header';
44
import { useApi } from './contexts/ApiProvider';
55
import { DrawerProvider } from './contexts/DrawerProvider';
@@ -30,7 +30,7 @@ function performBookOrNoteSort(rows: Note[] | Book[], method: SortChoice) {
3030
}
3131
}
3232

33-
const MainApp: Component = (props) => {
33+
const MainApp: Component<ParentProps> = (props) => {
3434
const params = useParams()
3535
const { api } = useApi()
3636
const { pushToast } = useToast()

frontend/src/components/modals/base.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import type { Component, JSX } from 'solid-js';
1+
import type { Component, ParentProps } from 'solid-js';
22

3-
type BaseModalProps = {
3+
type BaseModalProps = ParentProps & {
44
title: string
5-
children: JSX.Element
65
}
76

87
const BaseModal: Component<BaseModalProps> = (props) => {

frontend/src/components/show_or_redirect.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { JSX, Show } from "solid-js";
1+
import { ParentProps, Show } from "solid-js";
22
import Redirect from "./redirect";
33

4-
type ShowOrRedirectProps = {
4+
type ShowOrRedirectProps = ParentProps & {
55
when: () => boolean
66
redirectTo: string
7-
children: JSX.Element
87
}
98

109
export default function ShowOrRedirect(props: ShowOrRedirectProps) {

frontend/src/components/with_api_select.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import { Component, JSX, createSignal, onMount } from "solid-js";
1+
import { Component, ParentProps, createSignal, onMount } from "solid-js";
22
import { useApi } from "../contexts/ApiProvider";
33
import { ToastType, useToast } from "../contexts/ToastProvider";
44
import Api from "../core/api";
55

6-
type WithApiSelectProps = {
7-
children: JSX.Element
8-
}
9-
10-
const WithApiSelect: Component<WithApiSelectProps> = (props) => {
6+
const WithApiSelect: Component<ParentProps> = (props) => {
117
const { apiDetails, setApiDetails } = useApi()
128
const { pushToast } = useToast()
139
const [apiUrl, setApiUrl] = createSignal(apiDetails().apiServer)

frontend/src/contexts/DrawerProvider.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { JSX, createContext, useContext } from "solid-js"
1+
import { ParentProps, createContext, useContext } from "solid-js"
22
import { optionExpect } from "../core/core"
33
import { Book, Note } from "../core/types"
44

@@ -20,8 +20,7 @@ export const useDrawer = () => {
2020
return optionExpect(ctx, "current drawer context was undefined")
2121
}
2222

23-
type DrawerProviderProps = DrawerContextProps & {
24-
children: JSX.Element
23+
type DrawerProviderProps = DrawerContextProps & ParentProps & {
2524
}
2625

2726
export const DrawerProvider = (props: DrawerProviderProps) => {

frontend/src/wrapper.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { ToastProvider, Toasts } from "./contexts/ToastProvider";
22
import { Modal, ModalProvider } from "./contexts/ModalProvider";
33
import { ApiProvider } from "./contexts/ApiProvider";
44
import { CurrentUserProvider } from "./contexts/CurrentUserProvider";
5+
import { ParentProps } from "solid-js";
56

6-
export default function Wrapper(props) {
7+
export default function Wrapper(props: ParentProps) {
78
return (
89
<ToastProvider>
910
<Toasts />

0 commit comments

Comments
 (0)