material-ui For Mui Select Component SelectectProps Having some type error on production build

2fjabf4q  于 3个月前  发布在  其他
关注(0)|答案(2)|浏览(31)
TS2322: Type '{ options: { id: number; name: string; }[]; color: string; label: string; defaultValue: number; value: number; handleChange: (e: SelectChangeEvent<unknown>) => void; }' is not assignable to type 'IntrinsicAttributes & CustomSelectBoxProps'.
  Property 'color' does not exist on type 'IntrinsicAttributes & CustomSelectBoxProps'.
    89 |                     <CustomSelectBox
    90 |                         options={prefixSuffixContent}
  > 91 |                         color="secondary"
       |                         ^^^^^
    92 |                         label="Select Format"
    93 |                         defaultValue={IS_NUMERIC}
    94 |                         value={prefixSuffixValue}

这在生产构建中出现了。在本地构建中它是好的。

这是我自定义的扩展属性类型:

import { InputBaseProps, SelectChangeEvent, SelectProps } from "@mui/material";

export type OptionsType = {
    id: string | number;
    name: string;
};
export interface CustomSelectBoxProps extends SelectProps {
    /**
     * The variant to use.
     * @default 'outlined'
     */
    variant?: "standard" | "outlined" | "filled";
    /**
     * The size of the component.
     */
    size?: InputBaseProps["size"];
    /**
     * See [OutlinedInput#label](/material-ui/api/outlined-input/#props)
     */
    label?: React.ReactNode;
    register?: object | any;
    fieldDisable?: InputBaseProps["disabled"];
    defaultValue?: InputBaseProps["defaultValue"];
    value?: InputBaseProps["value"];
    handleBlur?: React.FocusEventHandler<any> | null;
    handleChange?: ((event: SelectChangeEvent<unknown>, child: React.ReactNode) => void) | null;
    options: any[];
    customClass?: string;
    inputLabelSize?: "small" | "normal";
    disableItems?: any[];
}
<CustomSelectBox
                                options={prefixSuffixContent}
                                color="secondary"
                                register={field}
                                label="Select Format"
                            />
u7up0aaq

u7up0aaq1#

你使用的是哪个版本的Material UI?
你能在Codesandbox或者一个我们可以克隆的仓库中提供一个复制品吗?

相关问题