Skip to content

Commit

Permalink
Remove tuple label syntax that fails on TS 3.9 and type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Jul 9, 2021
1 parent 5b68e0e commit 299824e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
22 changes: 5 additions & 17 deletions src/components/connectAdvanced.tsx
@@ -1,23 +1,11 @@
import hoistStatics from 'hoist-non-react-statics'
import React, {
useContext,
useMemo,
useRef,
useReducer,
useLayoutEffect,
} from 'react'
import React, { useContext, useMemo, useRef, useReducer } from 'react'
import { isValidElementType, isContextConsumer } from 'react-is'
import type { Store, AnyAction } from 'redux'
import type { Store } from 'redux'
import type { SelectorFactory } from '../connect/selectorFactory'
import { createSubscription, Subscription } from '../utils/Subscription'
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'
import type {
DispatchProp,
Matching,
GetProps,
AdvancedComponentDecorator,
ConnectedComponent,
} from '../types'
import type { AdvancedComponentDecorator, ConnectedComponent } from '../types'

import {
ReactReduxContext,
Expand All @@ -38,7 +26,7 @@ const stringifyComponent = (Comp: unknown) => {
}

function storeStateUpdatesReducer(
state: [payload: unknown, counter: number],
state: [unknown, number],
action: { payload: unknown }
) {
const [, updateCount] = state
Expand Down Expand Up @@ -115,7 +103,7 @@ function subscribeUpdates(
)
} catch (e) {
error = e
lastThrownError = e
lastThrownError = e as Error | null
}

if (!error) {
Expand Down
6 changes: 4 additions & 2 deletions src/hooks/useSelector.ts
Expand Up @@ -52,7 +52,9 @@ function useSelectorWithStoreAndSubscription<TStoreState, TSelectedState>(
}
} catch (err) {
if (latestSubscriptionCallbackError.current) {
err.message += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\n`
;(
err as Error
).message += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\n`
}

throw err
Expand Down Expand Up @@ -82,7 +84,7 @@ function useSelectorWithStoreAndSubscription<TStoreState, TSelectedState>(
// is re-rendered, the selectors are called again, and
// will throw again, if neither props nor store state
// changed
latestSubscriptionCallbackError.current = err
latestSubscriptionCallbackError.current = err as Error
}

forceRender()
Expand Down

0 comments on commit 299824e

Please sign in to comment.