Skip to content

Commit 299824e

Browse files
committed
Remove tuple label syntax that fails on TS 3.9 and type errors
1 parent 5b68e0e commit 299824e

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/components/connectAdvanced.tsx

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
import hoistStatics from 'hoist-non-react-statics'
2-
import React, {
3-
useContext,
4-
useMemo,
5-
useRef,
6-
useReducer,
7-
useLayoutEffect,
8-
} from 'react'
2+
import React, { useContext, useMemo, useRef, useReducer } from 'react'
93
import { isValidElementType, isContextConsumer } from 'react-is'
10-
import type { Store, AnyAction } from 'redux'
4+
import type { Store } from 'redux'
115
import type { SelectorFactory } from '../connect/selectorFactory'
126
import { createSubscription, Subscription } from '../utils/Subscription'
137
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'
14-
import type {
15-
DispatchProp,
16-
Matching,
17-
GetProps,
18-
AdvancedComponentDecorator,
19-
ConnectedComponent,
20-
} from '../types'
8+
import type { AdvancedComponentDecorator, ConnectedComponent } from '../types'
219

2210
import {
2311
ReactReduxContext,
@@ -38,7 +26,7 @@ const stringifyComponent = (Comp: unknown) => {
3826
}
3927

4028
function storeStateUpdatesReducer(
41-
state: [payload: unknown, counter: number],
29+
state: [unknown, number],
4230
action: { payload: unknown }
4331
) {
4432
const [, updateCount] = state
@@ -115,7 +103,7 @@ function subscribeUpdates(
115103
)
116104
} catch (e) {
117105
error = e
118-
lastThrownError = e
106+
lastThrownError = e as Error | null
119107
}
120108

121109
if (!error) {

src/hooks/useSelector.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ function useSelectorWithStoreAndSubscription<TStoreState, TSelectedState>(
5252
}
5353
} catch (err) {
5454
if (latestSubscriptionCallbackError.current) {
55-
err.message += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\n`
55+
;(
56+
err as Error
57+
).message += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\n`
5658
}
5759

5860
throw err
@@ -82,7 +84,7 @@ function useSelectorWithStoreAndSubscription<TStoreState, TSelectedState>(
8284
// is re-rendered, the selectors are called again, and
8385
// will throw again, if neither props nor store state
8486
// changed
85-
latestSubscriptionCallbackError.current = err
87+
latestSubscriptionCallbackError.current = err as Error
8688
}
8789

8890
forceRender()

0 commit comments

Comments
 (0)