alexplumb / material-ui-phone-number

Fork of react-phone-input-2 for the Material-UI library
MIT License
122 stars 182 forks source link

`onChange` signature doesn't look correct #69

Closed nifanic closed 4 years ago

nifanic commented 4 years ago

AFAIK onChange argument holds current value of string type.

If so, the signature should be

(e: string) => void

… but the current onChange signature is—

(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void

… because MuiPhoneNumberProps type extends standard TextFieldProps

// src/global.d.ts

export type MuiPhoneNumberProps = TextFieldProps & {
  autoFormat?: boolean;
  countryCodeEditable?: boolean;
  defaultCountry?: string;
  disableAreaCodes?: boolean;
  disableCountryCode?: boolean;
  disableDropdown?: boolean;
  dropdownClass?: string;
  enableLongNumbers?: boolean;
  excludeCountries?: string[];
  inputClass?: string;
  onlyCountries?: string[];
  preferredCountries?: string[];
};
nifanic commented 4 years ago

The original component is not offering type definitions. The above code snippets are from my codebase. Not an issue.