[TS] Type Summary component properly

This commit is contained in:
Beef 2023-02-13 20:34:58 +00:00
parent 67b501b974
commit 9989dfbf0d
2 changed files with 13 additions and 7 deletions

12
src/def.d.ts vendored
View file

@ -5,6 +5,15 @@ import _Clipboard from "@react-native-clipboard/clipboard";
type MetroModules = { [id: number]: any };
// Component types
// TODO: Make these not be here?
interface SummaryProps {
label: string;
icon?: string;
noPadding?: boolean;
children: JSX.Element | JSX.Element[];
}
// Helper types for API functions
type PropIntellisense<P extends string | symbol> = Record<P, any> & Record<PropertyKey, any>;
type PropsFinder = <T extends string | symbol>(...props: T[]) => PropIntellisense<T>;
@ -312,9 +321,12 @@ interface VendettaObject {
}
ui: {
components: {
// Discord
Forms: PropIntellisense<"Form" | "FormSection">;
General: PropIntellisense<"Button" | "Text" | "View">;
Search: _React.ComponentType;
// Vendetta
Summary: (props: SummaryProps) => JSX.Element;
}
toasts: {
showToast: (content: string, asset: number) => void;

View file

@ -1,3 +1,4 @@
import { SummaryProps } from "@types";
import { getAssetIDByName } from "@ui/assets";
import { ReactNative as RN } from "@metro/common";
import { Forms } from "@ui/components";
@ -5,13 +6,6 @@ import { Forms } from "@ui/components";
// TODO: Animated would be awesome
// TODO: Destructuring Forms doesn't work here. Why?
interface SummaryProps {
label: string;
icon?: string;
noPadding?: boolean;
children: JSX.Element | JSX.Element[];
}
export default function Summary({ label, icon, noPadding = false, children }: SummaryProps) {
const [hidden, setHidden] = React.useState(true);