@@ -4,32 +4,32 @@ import {
44import isEqual from "lodash.isequal" ;
55import { useQuery } from "@tanstack/react-query" ;
66import type {
7- ComponentReloadPropsOpts , ConfigurableProp , V1Component ,
7+ ComponentReloadPropsOpts , ConfigurableProp , ConfigurableProps , ConfiguredProps , V1Component ,
88} from "@pipedream/sdk" ;
99import { useFrontendClient } from "./frontend-client-context" ;
1010import type { ComponentFormProps } from "../components/ComponentForm" ;
1111
12- export type DynamicProps = { id : string ; configurable_props : any ; } ; // TODO
12+ export type DynamicProps < T extends ConfigurableProps > = { id : string ; configurable_props : T ; } ; // TODO
1313
14- export type FormContext = {
15- component : V1Component ; // XXX <T>
16- configurableProps : any [ ] ; // dynamicProps.configurable_props || props.component.configurable_props
17- configuredProps : Record < string , any > ; // TODO
18- dynamicProps ?: DynamicProps ; // lots of calls require dynamicProps?.id, so need to expose
14+ export type FormContext < T extends ConfigurableProps > = {
15+ component : V1Component < T > ;
16+ configurableProps : T ; // dynamicProps.configurable_props || props.component.configurable_props
17+ configuredProps : ConfiguredProps < T > ;
18+ dynamicProps ?: DynamicProps < T > ; // lots of calls require dynamicProps?.id, so need to expose
1919 dynamicPropsQueryIsFetching ?: boolean ;
2020 id : string ;
2121 isValid : boolean ;
2222 optionalPropIsEnabled : ( prop : ConfigurableProp ) => boolean ;
2323 optionalPropSetEnabled : ( prop : ConfigurableProp , enabled : boolean ) => void ;
2424 props : ComponentFormProps ;
2525 queryDisabledIdx ?: number ;
26- setConfiguredProp : ( idx : number , value : any ) => void ; // XXX would be nice to have type safety here
26+ setConfiguredProp : ( idx : number , value : unknown ) => void ; // XXX type safety for value (T will rarely be static right?)
2727 setSubmitting : ( submitting : boolean ) => void ;
2828 submitting : boolean ;
2929 userId : string ;
3030} ;
3131
32- export const FormContext = createContext < FormContext | undefined > ( undefined ) ;
32+ export const FormContext = createContext < FormContext < any /* XXX fix */ > | undefined > ( undefined ) ; // eslint-disable-line @typescript-eslint/no-explicit-any
3333
3434export const useFormContext = ( ) => {
3535 const context = useContext ( FormContext ) ;
@@ -50,7 +50,7 @@ type FormContextProviderProps = {
5050
5151export const FormContextProvider : React . FC < FormContextProviderProps > = ( {
5252 children, props,
53- } ) => {
53+ } : FormContextProviderProps ) => {
5454 const client = useFrontendClient ( ) ;
5555
5656 const id = useId ( ) ;
0 commit comments