Skip to content

Commit

Permalink
Improve FormEvent typescript type. Closes Github#1662
Browse files Browse the repository at this point in the history
  • Loading branch information
Havunen committed Dec 10, 2023
1 parent a6b49d3 commit c337fdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/inferno-mobx/__tests__/types.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, render } from 'inferno';
import { Component, FormEvent, render } from 'inferno';
import { Provider } from 'inferno-mobx';
import { observable } from 'mobx';

Expand Down Expand Up @@ -44,6 +44,10 @@ describe('top level context', () => {
render(<MyComponent />, container);
});

it('Should not complain about onInput event.target', () => {
render(<input onInput={(e: FormEvent<HTMLInputElement>) => e.target.value} />, container);
})

it('Should be possible to return null from render SFC', () => {
// SFC
const MyComponent = () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/inferno/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export type ClipboardEvent<T> = SemiSyntheticEvent<T> & NativeClipboardEvent;
export type CompositionEvent<T> = SemiSyntheticEvent<T> & NativeCompositionEvent;
export type DragEvent<T> = InfernoMouseEvent<T> & NativeDragEvent;
export type FocusEvent<T> = SemiSyntheticEvent<T> & NativeFocusEvent;
export type FormEvent<T> = SemiSyntheticEvent<T>;
export interface FormEvent<T> extends SemiSyntheticEvent<T> {
target: EventTarget & T;
}

export interface ChangeEvent<T> extends SemiSyntheticEvent<T> {
target: EventTarget & T;
Expand Down

0 comments on commit c337fdd

Please sign in to comment.