From 4cc7cbabf6dce8e5e684622d538db6241fbc0a7b Mon Sep 17 00:00:00 2001 From: Mike Deverell Date: Tue, 25 Oct 2016 11:35:40 -0400 Subject: [PATCH] [enzyme] state() with no props as an "S" (state type) return type (#12211) * clarify and fix 'options' object types; Hammer.Manager requires an EventTarget, not HTMLElement * fix RecognizerTuple type * `state()` with no props has an `S` (state type) return value --- enzyme/enzyme-tests.tsx | 2 +- enzyme/enzyme.d.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/enzyme/enzyme-tests.tsx b/enzyme/enzyme-tests.tsx index e5d56200cb..b87a759861 100644 --- a/enzyme/enzyme-tests.tsx +++ b/enzyme/enzyme-tests.tsx @@ -204,7 +204,7 @@ namespace ShallowWrapperTest { } function test_state() { - shallowWrapper.state(); + const state: MyComponentState = shallowWrapper.state(); shallowWrapper.state('key'); const tmp: String = shallowWrapper.state('key'); } diff --git a/enzyme/enzyme.d.ts b/enzyme/enzyme.d.ts index 5a53f8bf20..85a72127c1 100644 --- a/enzyme/enzyme.d.ts +++ b/enzyme/enzyme.d.ts @@ -204,8 +204,9 @@ declare module "enzyme" { * Returns the state hash for the root node of the wrapper. Optionally pass in a prop name and it will return just that value. * @param [key] */ - state(key?: string): any; - state(key?: string): T; + state(): S; + state(key: string): any; + state(key: string): T; /** * Returns the context hash for the root node of the wrapper. Optionally pass in a prop name and it will return just that value.