mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-13 05:20:25 +00:00
React: Constrain typed changed events to inputs, selects and textareas
This commit is contained in:
@@ -674,3 +674,18 @@ class SyntheticEventTargetValue extends React.Component<{}, { value: string }> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
React.DOM.input({
|
||||
onChange: event => {
|
||||
// `event.target` is guaranteed to be HTMLInputElement
|
||||
event.target.value;
|
||||
}
|
||||
});
|
||||
|
||||
// A ChangeEvent is a valid FormEvent (maintain compatibility with existing
|
||||
// event handlers)
|
||||
|
||||
type InputChangeEvent = React.ChangeEvent<HTMLInputElement>;
|
||||
type InputFormEvent = React.FormEvent<HTMLInputElement>;
|
||||
const changeEvent:InputChangeEvent = undefined as any;
|
||||
const formEvent:InputFormEvent = changeEvent;
|
||||
|
||||
Reference in New Issue
Block a user