Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop pre-TS-4.1 types and workarounds #2249

Merged
merged 2 commits into from
Apr 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
fail-fast: false
matrix:
node: ['14.x']
ts: ['4.1', '4.2', '4.3', '4.4', '4.5', '4.6.1-rc', 'next']
ts: ['4.1', '4.2', '4.3', '4.4', '4.5', '4.6', '4.7.0-beta', 'next']
steps:
- name: Checkout repo
uses: actions/checkout@v2
Expand All @@ -123,10 +123,6 @@ jobs:

- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./jest.config.js ./src/tests/*.* ./src/query/tests/*.*

- name: "@ts-ignore stuff that didn't exist pre-4.1 in the tests"
if: ${{ matrix.ts < 4.1 }}
run: sed -i -e 's/@pre41-ts-ignore/@ts-ignore/' -e '/pre41-remove-start/,/pre41-remove-end/d' ./src/tests/*.* ./src/query/tests/*.ts*

- name: Test types
run: |
yarn tsc --version
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/query/react/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { capitalize } from '../utils'
import { safeAssign } from '../tsHelpers'
import type { BaseQueryFn } from '@reduxjs/toolkit/dist/query/baseQueryTypes'

import type { HooksWithUniqueNames } from './versionedTypes'
import type { HooksWithUniqueNames } from './namedHooks'

import {
useDispatch as rrUseDispatch,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import type { UseMutation, UseLazyQuery, UseQuery } from '../buildHooks'
import type { UseMutation, UseLazyQuery, UseQuery } from './buildHooks'
import type {
DefinitionType,
EndpointDefinitions,
MutationDefinition,
QueryDefinition,
} from '@reduxjs/toolkit/dist/query/endpointDefinitions'

// For TS 4.1 and later, we can use string literal types to define
// the exact names of each endpoint's exported hooks
export type HooksWithUniqueNames<Definitions extends EndpointDefinitions> =
keyof Definitions extends infer Keys
? Keys extends string
Expand Down
8 changes: 0 additions & 8 deletions packages/toolkit/src/query/react/versionedTypes/index.ts

This file was deleted.

10 changes: 0 additions & 10 deletions packages/toolkit/src/query/react/versionedTypes/package.dist.json

This file was deleted.

9 changes: 0 additions & 9 deletions packages/toolkit/src/query/react/versionedTypes/ts40Types.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/toolkit/src/query/tests/buildHooks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1828,14 +1828,10 @@ describe('hooks with createApi defaults set', () => {

const storeRef = setupApiStore(api)

// @pre41-ts-ignore
expectExactType(api.useGetPostsQuery)(api.endpoints.getPosts.useQuery)
// @pre41-ts-ignore
expectExactType(api.useUpdatePostMutation)(
// @pre41-ts-ignore
api.endpoints.updatePost.useMutation
)
// @pre41-ts-ignore
expectExactType(api.useAddPostMutation)(api.endpoints.addPost.useMutation)

test('useQueryState serves a deeply memoized value and does not rerender unnecessarily', async () => {
Expand Down
6 changes: 0 additions & 6 deletions packages/toolkit/src/query/tests/unionTypes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ describe.skip('TS only tests', () => {
expectType<never>(result)
}
})
// pre41-remove-start
test('useQuery TS4.1 union', () => {
const result = api.useTestQuery()

Expand Down Expand Up @@ -207,7 +206,6 @@ describe.skip('TS only tests', () => {
expectType<never>(result)
}
})
// pre41-remove-end

test('useLazyQuery union', () => {
const [_trigger, result] = api.endpoints.test.useLazyQuery()
Expand Down Expand Up @@ -275,7 +273,6 @@ describe.skip('TS only tests', () => {
}
})

// pre41-remove-start
test('useLazyQuery TS4.1 union', () => {
const [_trigger, result] = api.useLazyTestQuery()

Expand Down Expand Up @@ -341,7 +338,6 @@ describe.skip('TS only tests', () => {
expectType<never>(result)
}
})
// pre41-remove-end

test('queryHookResult (without selector) union', () => {
const useQueryStateResult = api.endpoints.test.useQueryState()
Expand Down Expand Up @@ -501,7 +497,6 @@ describe.skip('TS only tests', () => {
})(result)
})

// pre41-remove-start
test('useMutation TS4.1 union', () => {
const [_trigger, result] = api.useMutationMutation()

Expand Down Expand Up @@ -552,5 +547,4 @@ describe.skip('TS only tests', () => {
expectType<never>(result)
}
})
// pre41-remove-end
})