Clean up typing and formatting

This commit is contained in:
Connor Bryan 2018-07-12 13:04:22 -05:00
parent 6b2a8eedbc
commit 1c601f58e4
4 changed files with 17 additions and 6 deletions

View File

@ -18,7 +18,7 @@ interface OwnProps {
placeholder?: string; placeholder?: string;
value?: string; value?: string;
dropdownThreshold?: number; dropdownThreshold?: number;
onChangeOverride?: (ev: React.FormEvent<HTMLInputElement>) => void; onChangeOverride?(ev: React.FormEvent<HTMLInputElement>): void;
} }
interface StateProps { interface StateProps {

View File

@ -8,12 +8,24 @@ import { addressBookSelectors } from 'features/addressBook';
import { Address, Identicon } from 'components/ui'; import { Address, Identicon } from 'components/ui';
import './AddressFieldDropdown.scss'; import './AddressFieldDropdown.scss';
/**
* @desc The `onChangeOverride` prop needs to work
* with actual events, but also needs a value to be directly passed in
* occasionally. This interface allows us to skip all of the other FormEvent
* properties and methods.
*/
interface FakeFormEvent {
currentTarget: {
value: string;
};
}
interface StateProps { interface StateProps {
value?: string; value?: string;
dropdownThreshold?: number; dropdownThreshold?: number;
onChangeOverride?: (ev: React.FormEvent<HTMLInputElement>) => void;
labelAddresses: ReturnType<typeof addressBookSelectors.getLabelAddresses>; labelAddresses: ReturnType<typeof addressBookSelectors.getLabelAddresses>;
currentTo: ReturnType<typeof transactionSelectors.getToRaw>; currentTo: ReturnType<typeof transactionSelectors.getToRaw>;
onChangeOverride?(ev: React.FormEvent<HTMLInputElement> | FakeFormEvent): void;
} }
interface DispatchProps { interface DispatchProps {

View File

@ -18,8 +18,8 @@ interface OwnProps {
showIdenticon?: boolean; showIdenticon?: boolean;
value?: string; value?: string;
dropdownThreshold?: number; dropdownThreshold?: number;
onChangeOverride?: (ev: React.FormEvent<HTMLInputElement>) => void;
withProps(props: CallbackProps): React.ReactElement<any> | null; withProps(props: CallbackProps): React.ReactElement<any> | null;
onChangeOverride?(ev: React.FormEvent<HTMLInputElement>): void;
} }
interface State { interface State {
@ -113,8 +113,8 @@ interface DefaultAddressFieldProps {
showIdenticon?: boolean; showIdenticon?: boolean;
value?: string; value?: string;
dropdownThreshold?: number; dropdownThreshold?: number;
onChangeOverride?: (ev: React.FormEvent<HTMLInputElement>) => void;
withProps(props: CallbackProps): React.ReactElement<any> | null; withProps(props: CallbackProps): React.ReactElement<any> | null;
onChangeOverride?(ev: React.FormEvent<HTMLInputElement>): void;
} }
const DefaultAddressField: React.SFC<DefaultAddressFieldProps> = ({ const DefaultAddressField: React.SFC<DefaultAddressFieldProps> = ({

View File

@ -32,8 +32,8 @@ interface OwnProps {
className?: string; className?: string;
value?: string; value?: string;
dropdownThreshold?: number; dropdownThreshold?: number;
onChangeOverride?: (ev: React.FormEvent<HTMLInputElement>) => void;
onChange(ev: React.FormEvent<HTMLInputElement>): void; onChange(ev: React.FormEvent<HTMLInputElement>): void;
onChangeOverride?(ev: React.FormEvent<HTMLInputElement>): void;
onFocus(ev: React.FormEvent<HTMLInputElement>): void; onFocus(ev: React.FormEvent<HTMLInputElement>): void;
onBlur(ev: React.FormEvent<HTMLInputElement>): void; onBlur(ev: React.FormEvent<HTMLInputElement>): void;
withProps(props: CallbackProps): React.ReactElement<any> | null; withProps(props: CallbackProps): React.ReactElement<any> | null;
@ -63,7 +63,6 @@ type Props = OwnProps & StateProps;
class AddressInputFactoryClass extends Component<Props> { class AddressInputFactoryClass extends Component<Props> {
public render() { public render() {
const { const {
className,
label, label,
currentTo, currentTo,
onChange, onChange,