Skip to content

Commit

Permalink
chore: types
Browse files Browse the repository at this point in the history
  • Loading branch information
yofukashino committed Jan 29, 2025
1 parent 5dc6a77 commit 133ebff
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 6 deletions.
66 changes: 61 additions & 5 deletions src/renderer/modules/common/components.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,63 @@
import type { LoaderType } from "@components";
import type { ClickableCompType } from "@components/Clickable";
import type { NoticeType } from "@components/Notice";
import type { OriginalTextType } from "@components/Text";
import type { ButtonType } from "../components/ButtonItem";
import type { CheckboxType } from "../components/CheckboxItem";
import type { ContextMenuType } from "../components/ContextMenu";
import type { DividerType } from "../components/Divider";
import type { FormItemCompType } from "../components/FormItem";
import type { FormNoticeType } from "../components/FormNotice";
import type { FormTextCompType, FormTextTypeKey } from "../components/FormText";
import type { ModalType } from "../components/Modal";
import type { RadioType } from "../components/RadioItem";
import type { SelectCompType } from "../components/SelectItem";
import type { SliderCompType } from "../components/SliderItem";
import type { SwitchItemType, SwitchType } from "../components/SwitchItem";
import type { TextAreaType } from "../components/TextArea";
import type { TextInputType } from "../components/TextInput";
import type { OriginalTooltipType } from "../components/Tooltip";
import { waitForProps } from "../webpack";
import type { CreateToast, ShowToast } from "./toast";

export default await waitForProps<Record<string, unknown>>([
"ConfirmModal",
"ToastPosition",
"Text",
]);
// Expand this as needed
type DiscordComponents = {
createToast: CreateToast;
showToast: ShowToast;
Text: OriginalTextType;
} & Record<
string,
| ButtonType
| CheckboxType
| ClickableCompType
| DividerType
| FormItemCompType
| FormNoticeType
| SwitchItemType
| FormTextCompType
| Record<FormTextTypeKey, string>
| NoticeType
| NoticeType["HelpMessageTypes"]
| ContextMenuType["ContextMenu"]
| ContextMenuType["MenuCheckboxItem"]
| ContextMenuType["MenuControlItem"]
| ContextMenuType["MenuGroup"]
| ContextMenuType["MenuItem"]
| ContextMenuType["MenuRadioItem"]
| ContextMenuType["MenuSeparator"]
| ModalType["ModalCloseButton"]
| ModalType["ModalContent"]
| ModalType["ModalFooter"]
| ModalType["ModalHeader"]
| ModalType["ModalRoot"]
| RadioType
| SelectCompType
| SliderCompType
| LoaderType
| SwitchType
| TextAreaType
| TextInputType
| OriginalTooltipType
>;

export default await waitForProps<DiscordComponents>("ConfirmModal", "ToastPosition", "Text");
2 changes: 1 addition & 1 deletion src/renderer/modules/components/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export type OriginalTextType = React.FC<CustomTextProps>;
export type TextType = OriginalTextType &
Record<"Normal" | "H1" | "H2" | "H3" | "H4" | "Eyebrow", OriginalTextType>;

const { Text: TextComp } = components as { Text: TextType };
const TextComp = components.Text;

function TextWithDefaultProps(defaultProps: CustomTextProps) {
return (props: CustomTextProps) => {
Expand Down

0 comments on commit 133ebff

Please sign in to comment.