I am defining a FormField type with the following properties:
export type FormField = {
name: string;
type: string;
mandatory: boolean;
options?: FormFieldOptionsType;
visibleIfIndIsVisible?: number;
ind?: number;
value?: string;
dateCreatedAt?: string;
selectItemOtherArbitraryValueEnable?: boolean;
regex?: string;
defaultFormFieldOptionId?: string;
};
To assign a value, use the following function:
const saveFormField = (key: string, value: any) => {
let formField: FormField = {
name: reloadProps?.formField?.name ?? "",
type: reloadProps?.formField?.type ?? "",
mandatory: reloadProps?.formField?.mandatory ?? false,
regex: reloadProps?.formField?.regex ?? "",
selectItemOtherArbitraryValueEnable:
reloadProps?.formField?.selectItemOtherArbitraryValueEnable,
};
formField[key] = value;
However, when running yarn build
, an error is raised. Do you know why?
./pages/[lang]/formFieldOptions/[...eventId_formFieldId].tsx:134:5
Type error: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'FormField'.
132 | reloadProps?.formField?.selectItemOtherArbitraryValueEnable,
133 | };
> 134 | formField[key] = value;
| ^