From aa11f191973b1b9abbb795b4ca5f5a94d51f8256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sampo=20Kivist=C3=B6?= Date: Sun, 10 Dec 2023 21:13:10 +0200 Subject: [PATCH] Improve FormEvent typescript type. Closes Github#1662 --- packages/inferno-mobx/__tests__/types.spec.tsx | 6 +++++- packages/inferno/src/core/types.ts | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/inferno-mobx/__tests__/types.spec.tsx b/packages/inferno-mobx/__tests__/types.spec.tsx index 437c14a4e..77564e6cc 100644 --- a/packages/inferno-mobx/__tests__/types.spec.tsx +++ b/packages/inferno-mobx/__tests__/types.spec.tsx @@ -1,4 +1,4 @@ -import { Component, render } from 'inferno'; +import { Component, FormEvent, render } from 'inferno'; import { Provider } from 'inferno-mobx'; import { observable } from 'mobx'; @@ -44,6 +44,10 @@ describe('top level context', () => { render(, container); }); + it('Should not complain about onInput event.target', () => { + render() => e.target.value} />, container); + }) + it('Should be possible to return null from render SFC', () => { // SFC const MyComponent = () => { diff --git a/packages/inferno/src/core/types.ts b/packages/inferno/src/core/types.ts index a4f25ec2d..c273acc74 100644 --- a/packages/inferno/src/core/types.ts +++ b/packages/inferno/src/core/types.ts @@ -87,7 +87,9 @@ export type ClipboardEvent = SemiSyntheticEvent & NativeClipboardEvent; export type CompositionEvent = SemiSyntheticEvent & NativeCompositionEvent; export type DragEvent = InfernoMouseEvent & NativeDragEvent; export type FocusEvent = SemiSyntheticEvent & NativeFocusEvent; -export type FormEvent = SemiSyntheticEvent; +export interface FormEvent extends SemiSyntheticEvent { + target: EventTarget & T; +} export interface ChangeEvent extends SemiSyntheticEvent { target: EventTarget & T;