Skip to content

Commit

Permalink
Typescript fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
IstoraMandiri committed Jul 24, 2023
1 parent 52da20c commit f51d4b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Below are the upcoming features and improvements.
- Cleanup, replace all `any` types
- Allow users to handle 404s
- multiple links in one PR
- Fix unwrapDynamic, formContext types

### Update Docs

Expand Down
12 changes: 8 additions & 4 deletions src/components/contribution/fields/choice/choiceInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,20 @@ export type Props = {
};

const dynamicProps = ["title", "info"] as const;
type DynamicProps = (typeof dynamicProps)[number];

export type ChoiceCompProps = Omit<Props, "name"> & {
// TODO fix this in UnwrapDynamic
type NonDynamic = Omit<Props, DynamicProps | "name">;
type Unwrapped = NonDynamic &
UnwrapDynamic<Pick<Props, DynamicProps>, DynamicProps>;

export type ChoiceCompProps = Unwrapped & {
handleChange: (value: string | undefined) => void;
field: { value?: string | string[] };
inline?: boolean;
};

function ChoiceInput(
props: UnwrapDynamic<Props, (typeof dynamicProps)[number]>
) {
function ChoiceInput(props: UnwrapDynamic<Props, DynamicProps>) {
const { multiple, validation, name } = props;
const [field, meta, helpers] = useField(name);
const inline = props.as == "buttons-inline";
Expand Down
2 changes: 2 additions & 0 deletions src/components/contribution/formContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { createContext, useContext } from "react";
export const FormContext = createContext<{
formik: FormikContext;
config: ConfigWithContribution;
// TODO fix this
// @ts-ignore
}>({});

export function useForm() {
Expand Down

1 comment on commit f51d4b2

@vercel
Copy link

@vercel vercel bot commented on f51d4b2 Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.