Skip to content

Commit

Permalink
Add todo comments to remove certain test blocks
Browse files Browse the repository at this point in the history
  - Added todo comments to remove certain test blocks after removal of `TypedStructuredSelectorCreator`.
  • Loading branch information
aryaemami59 committed Jan 5, 2024
1 parent 7f1588c commit 9b4b7ac
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/createStructuredSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ export type RootStateSelectors<RootState = any> = {
}

/**
* @deprecated Please use {@linkcode StructuredSelectorCreator.withTypes createStructuredSelector.withTypes<RootState>()} instead. This type will be removed in the future.
* @template RootState - The type of the root state object.
*
* @since 5.0.0
* @public
* @deprecated Please use {@linkcode StructuredSelectorCreator.withTypes createStructuredSelector.withTypes<RootState>()} instead. This type will be removed in the future.
*/
export type TypedStructuredSelectorCreator<RootState = any> =
/**
Expand Down
3 changes: 3 additions & 0 deletions type-tests/createStructuredSelector.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const rootState: RootState = {
}

describe('createStructuredSelector', () => {

// TODO: Remove this test block once `TypedStructuredSelectorCreator` is removed.
test('TypedStructuredSelectorCreator should lock down state type', () => {
const createStructuredAppSelector: TypedStructuredSelectorCreator<RootState> =
createStructuredSelector
Expand Down Expand Up @@ -112,6 +114,7 @@ describe('createStructuredSelector', () => {
>(structuredSelector.lastResult())
})

// TODO: Remove this test block once `TypedStructuredSelectorCreator` is removed.
test('TypedStructuredSelectorCreator should correctly infer memoize and argsMemoize', () => {
const createSelectorLru = createSelectorCreator({
memoize: lruMemoize,
Expand Down
1 change: 1 addition & 0 deletions type-tests/createStructuredSelector.withTypes.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ describe('createStructuredSelector.withTypes<RootState>()', () => {
>(structuredAppSelector.lastResult())
})

// TODO: Remove this test block once `TypedStructuredSelectorCreator` is removed.
test('should work alongside TypedStructuredSelectorCreator', () => {
const createStructuredAppSelector: TypedStructuredSelectorCreator<RootState> =
createStructuredSelector.withTypes<RootState>()
Expand Down
25 changes: 5 additions & 20 deletions typescript_test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
createSelector,
createSelectorCreator,
createStructuredSelector,
referenceEqualityCheck,
lruMemoize
lruMemoize,
referenceEqualityCheck
} from 'reselect'
import { expectExactType } from './typesTestUtils'

Expand Down Expand Up @@ -748,8 +748,8 @@ function testCreateStructuredSelector() {
bar: number
}

const typedStructuredSelectorCreator: TypedStructuredSelectorCreator<RootState> =
createStructuredSelector
const typedStructuredSelectorCreator =
createStructuredSelector.withTypes<RootState>()

const selector = typedStructuredSelectorCreator({
foo: state => state.foo,
Expand All @@ -772,12 +772,10 @@ function testCreateStructuredSelector() {
})

typedStructuredSelectorCreator({
// @ts-expect-error
bar: state => state.foo
})

typedStructuredSelectorCreator({
// @ts-expect-error
baz: state => state.foo
})

Expand Down Expand Up @@ -820,6 +818,7 @@ function testCreateStructuredSelector() {
selectorGenerics({ bar: '42' })
}

// TODO: Remove this function once `TypedStructuredSelectorCreator` is removed.
function testTypedCreateStructuredSelector() {
type RootState = {
foo: string
Expand Down Expand Up @@ -921,20 +920,6 @@ function testStructuredSelectorTypeParams() {
// bar: selectBar,
// ^^^ because this is missing, an error is thrown
})

const typedStructuredSelectorCreator: TypedStructuredSelectorCreator<GlobalState> =
createStructuredSelector

// This works
typedStructuredSelectorCreator({
foo: selectFoo,
bar: selectBar
})

// // So does this
// typedStructuredSelectorCreator<Omit<GlobalState, 'bar'>>({
// foo: selectFoo
// })
}

function multiArgMemoize<F extends (...args: any[]) => any>(
Expand Down

0 comments on commit 9b4b7ac

Please sign in to comment.