Tag Archives: My debugging

Typescript generic source code error

1. The error information is as follows

2. Source code understanding

export declare type InputProps = Pick<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, 'maxLength' | 'autoComplete' | 'enterKeyHint' | 'pattern' | 'type' | 'onFocus' | 'onBlur' | 'autoCapitalize' | 'autoCorrect'> & {
    value?: string;
    defaultValue?: string;
    onChange?: (val: string) => void;
    placeholder?: string;
    disabled?: boolean;
    readOnly?: boolean;
    clearable?: boolean;
    onClear?: () => void;
    id?: string;
} & NativeProps<'--font-size' | '--color' | '--placeholder-color' | '--disabled-color'>;

React.inputhtmlattributes have the following names in react

type DetailedHTMLProps<E extends HTMLAttributes<T>, T> = ClassAttributes<T> & E;

3. Solution

The version of react declaration file is too low. The following declaration is missing