Repository: reduxjs/redux-toolkit
Pull request #1027 (2021-04-30 11:04:06)

add export for `copyWithStructuralSharing`, run CI against `dist`


Patch:
diff --git a/etc/rtk-query-react.api.md b/etc/rtk-query-react.api.md
index ea0a452b..25a54e1b 100644
--- a/etc/rtk-query-react.api.md
+++ b/etc/rtk-query-react.api.md
@@ -1,167 +1,170 @@
-## API Report File for "@reduxjs/toolkit"
-
-> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
-
-```ts
-
-import { ActionCreatorWithoutPayload } from '@reduxjs/toolkit';
-import { AnyAction } from '@reduxjs/toolkit';
-import { batch } from 'react-redux';
-import { Context } from 'react';
-import { ReactReduxContextValue } from 'react-redux';
-import { SerializedError } from '@reduxjs/toolkit';
-import { ThunkDispatch } from '@reduxjs/toolkit';
-import { useDispatch } from 'react-redux';
-import { useSelector } from 'react-redux';
-import { useStore } from 'react-redux';
-
-// @public (undocumented)
-export type Api<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string, Enhancers extends ModuleName = CoreModule> = Id<Id<UnionToIntersection<ApiModules<BaseQuery, Definitions, ReducerPath, TagTypes>[Enhancers]>> & {
-    injectEndpoints<NewDefinitions extends EndpointDefinitions>(_: {
-        endpoints: (build: EndpointBuilder<BaseQuery, TagTypes, ReducerPath>) => NewDefinitions;
-        overrideExisting?: boolean;
-    }): Api<BaseQuery, Definitions & NewDefinitions, ReducerPath, TagTypes, Enhancers>;
-    enhanceEndpoints<NewTagTypes extends string = never>(_: {
-        addEntityTypes?: readonly NewTagTypes[];
-        addTagTypes?: readonly NewTagTypes[];
-        endpoints?: ReplaceTagTypes<Definitions, TagTypes | NoInfer<NewTagTypes>> extends infer NewDefinitions ? {
-            [K in keyof NewDefinitions]?: Partial<NewDefinitions[K]> | ((definition: NewDefinitions[K]) => void);
-        } : never;
-    }): Api<BaseQuery, ReplaceTagTypes<Definitions, TagTypes | NewTagTypes>, ReducerPath, TagTypes | NewTagTypes, Enhancers>;
-}>;
-
-// @public (undocumented)
-export interface ApiModules<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string> {
-}
-
-// @public
-export function ApiProvider<A extends Api<any, {}, any, any>>(props: {
-    children: any;
-    api: A;
-    setupListeners?: Parameters<typeof setupListeners>[1];
-    context?: Context<ReactReduxContextValue>;
-}): JSX.Element;
-
-// @public (undocumented)
-export type ApiWithInjectedEndpoints<ApiDefinition extends Api<any, any, any, any>, Injections extends ApiDefinition extends Api<infer B, any, infer R, infer E> ? [Api<B, any, R, E>, ...Api<B, any, R, E>[]] : never> = Omit<ApiDefinition, 'endpoints'> & Omit<Injections, 'endpoints'> & {
-    endpoints: ApiDefinition['endpoints'] & Partial<UnionToIntersection<Injections[number]['endpoints']>>;
-};
-
-// @public (undocumented)
-export type BaseQueryEnhancer<AdditionalArgs = unknown, AdditionalDefinitionExtraOptions = unknown, Config = void> = <BaseQuery extends BaseQueryFn>(baseQuery: BaseQuery, config: Config) => BaseQueryFn<BaseQueryArg<BaseQuery> & AdditionalArgs, BaseQueryResult<BaseQuery>, BaseQueryError<BaseQuery>, BaseQueryExtraOptions<BaseQuery> & AdditionalDefinitionExtraOptions>;
-
-// @public (undocumented)
-export type BaseQueryFn<Args = any, Result = unknown, Error = unknown, DefinitionExtraOptions = {}, Meta = {}> = (args: Args, api: BaseQueryApi, extraOptions: DefinitionExtraOptions) => MaybePromise<QueryReturnValue<Result, Error, Meta>>;
-
-// @public
-export function buildCreateApi<Modules extends [Module<any>, ...Module<any>[]]>(...modules: Modules): CreateApi<Modules[number]['name']>;
-
-// @public
-export const coreModule: () => Module<CoreModule>;
-
-// @public (undocumented)
-export type CreateApi<Modules extends ModuleName> = {
-    <BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string = 'api', TagTypes extends string = never>(options: CreateApiOptions<BaseQuery, Definitions, ReducerPath, TagTypes>): Api<BaseQuery, Definitions, ReducerPath, TagTypes, Modules>;
-};
-
-// @public (undocumented)
-export const createApi: CreateApi<typeof coreModuleName | typeof reactHooksModuleName>;
-
-// @public (undocumented)
-export interface CreateApiOptions<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string = 'api', TagTypes extends string = never> {
-    baseQuery: BaseQuery;
-    endpoints(build: EndpointBuilder<BaseQuery, TagTypes, ReducerPath>): Definitions;
-    // @deprecated (undocumented)
-    entityTypes?: readonly TagTypes[];
-    keepUnusedDataFor?: number;
-    reducerPath?: ReducerPath;
-    refetchOnFocus?: boolean;
-    refetchOnMountOrArgChange?: boolean | number;
-    refetchOnReconnect?: boolean;
-    serializeQueryArgs?: SerializeQueryArgs<BaseQueryArg<BaseQuery>>;
-    tagTypes?: readonly TagTypes[];
-}
-
-// @public (undocumented)
-export type EndpointDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string> = QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath> | MutationDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>;
-
-// @public (undocumented)
-export type EndpointDefinitions = Record<string, EndpointDefinition<any, any, any, any>>;
-
-// @public
-export function fakeBaseQuery<ErrorType>(): BaseQueryFn<void, NEVER, ErrorType, {}>;
-
-// @public (undocumented)
-export interface FetchArgs extends CustomRequestInit {
-    // (undocumented)
-    body?: any;
-    // (undocumented)
-    params?: Record<string, any>;
-    // (undocumented)
-    responseHandler?: ResponseHandler;
-    // (undocumented)
-    url: string;
-    // (undocumented)
-    validateStatus?: (response: Response, body: any) => boolean;
-}
-
-// @public
-export function fetchBaseQuery({ baseUrl, prepareHeaders, fetchFn, ...baseFetchOptions }?: FetchBaseQueryArgs): BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>;
-
-// @public (undocumented)
-export interface FetchBaseQueryError {
-    // (undocumented)
-    data: unknown;
-    // (undocumented)
-    status: number;
-}
-
-// @public (undocumented)
-export type Module<Name extends ModuleName> = {
-    name: Name;
-    init<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string>(api: Api<BaseQuery, EndpointDefinitions, ReducerPath, TagTypes, ModuleName>, options: Required<CreateApiOptions<BaseQuery, Definitions, ReducerPath, TagTypes>>, context: ApiContext<Definitions>): {
-        injectEndpoint(endpointName: string, definition: EndpointDefinition<any, any, any, any>): void;
-    };
-};
-
-// @public (undocumented)
-export type MutationDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string, Context = Record<string, any>> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> & MutationExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath, Context>;
-
-// @public (undocumented)
-export type QueryDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string, Context = Record<string, any>> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> & QueryExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath, Context>;
-
-// @public
-export enum QueryStatus {
-    // (undocumented)
-    fulfilled = "fulfilled",
-    // (undocumented)
-    pending = "pending",
-    // (undocumented)
-    rejected = "rejected",
-    // (undocumented)
-    uninitialized = "uninitialized"
-}
-
-// @public
-export const reactHooksModule: ({ batch, useDispatch, useSelector, useStore, }?: ReactHooksModuleOptions) => Module<ReactHooksModule>;
-
-// @public
-export const retry: BaseQueryEnhancer<unknown, StaggerOptions, void | StaggerOptions> & {
-    fail: typeof fail_2;
-};
-
-// @public
-export function setupListeners(dispatch: ThunkDispatch<any, any, any>, customHandler?: (dispatch: ThunkDispatch<any, any, any>, actions: {
-    onFocus: typeof onFocus;
-    onFocusLost: typeof onFocusLost;
-    onOnline: typeof onOnline;
-    onOffline: typeof onOffline;
-}) => () => void): () => void;
-
-// @public (undocumented)
-export const skipSelector: unique symbol;
-
-
-// (No @packageDocumentation comment for this package)
-
-```
+## API Report File for "@reduxjs/toolkit"
+
+> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
+
+```ts
+
+import { ActionCreatorWithoutPayload } from '@reduxjs/toolkit';
+import { AnyAction } from '@reduxjs/toolkit';
+import { batch } from 'react-redux';
+import { Context } from 'react';
+import { ReactReduxContextValue } from 'react-redux';
+import { SerializedError } from '@reduxjs/toolkit';
+import { ThunkDispatch } from '@reduxjs/toolkit';
+import { useDispatch } from 'react-redux';
+import { useSelector } from 'react-redux';
+import { useStore } from 'react-redux';
+
+// @public (undocumented)
+export type Api<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string, Enhancers extends ModuleName = CoreModule> = Id<Id<UnionToIntersection<ApiModules<BaseQuery, Definitions, ReducerPath, TagTypes>[Enhancers]>> & {
+    injectEndpoints<NewDefinitions extends EndpointDefinitions>(_: {
+        endpoints: (build: EndpointBuilder<BaseQuery, TagTypes, ReducerPath>) => NewDefinitions;
+        overrideExisting?: boolean;
+    }): Api<BaseQuery, Definitions & NewDefinitions, ReducerPath, TagTypes, Enhancers>;
+    enhanceEndpoints<NewTagTypes extends string = never>(_: {
+        addEntityTypes?: readonly NewTagTypes[];
+        addTagTypes?: readonly NewTagTypes[];
+        endpoints?: ReplaceTagTypes<Definitions, TagTypes | NoInfer<NewTagTypes>> extends infer NewDefinitions ? {
+            [K in keyof NewDefinitions]?: Partial<NewDefinitions[K]> | ((definition: NewDefinitions[K]) => void);
+        } : never;
+    }): Api<BaseQuery, ReplaceTagTypes<Definitions, TagTypes | NewTagTypes>, ReducerPath, TagTypes | NewTagTypes, Enhancers>;
+}>;
+
+// @public (undocumented)
+export interface ApiModules<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string> {
+}
+
+// @public
+export function ApiProvider<A extends Api<any, {}, any, any>>(props: {
+    children: any;
+    api: A;
+    setupListeners?: Parameters<typeof setupListeners>[1];
+    context?: Context<ReactReduxContextValue>;
+}): JSX.Element;
+
+// @public (undocumented)
+export type ApiWithInjectedEndpoints<ApiDefinition extends Api<any, any, any, any>, Injections extends ApiDefinition extends Api<infer B, any, infer R, infer E> ? [Api<B, any, R, E>, ...Api<B, any, R, E>[]] : never> = Omit<ApiDefinition, 'endpoints'> & Omit<Injections, 'endpoints'> & {
+    endpoints: ApiDefinition['endpoints'] & Partial<UnionToIntersection<Injections[number]['endpoints']>>;
+};
+
+// @public (undocumented)
+export type BaseQueryEnhancer<AdditionalArgs = unknown, AdditionalDefinitionExtraOptions = unknown, Config = void> = <BaseQuery extends BaseQueryFn>(baseQuery: BaseQuery, config: Config) => BaseQueryFn<BaseQueryArg<BaseQuery> & AdditionalArgs, BaseQueryResult<BaseQuery>, BaseQueryError<BaseQuery>, BaseQueryExtraOptions<BaseQuery> & AdditionalDefinitionExtraOptions>;
+
+// @public (undocumented)
+export type BaseQueryFn<Args = any, Result = unknown, Error = unknown, DefinitionExtraOptions = {}, Meta = {}> = (args: Args, api: BaseQueryApi, extraOptions: DefinitionExtraOptions) => MaybePromise<QueryReturnValue<Result, Error, Meta>>;
+
+// @public
+export function buildCreateApi<Modules extends [Module<any>, ...Module<any>[]]>(...modules: Modules): CreateApi<Modules[number]['name']>;
+
+// @public (undocumented)
+export function copyWithStructuralSharing<T>(oldObj: any, newObj: T): T;
+
+// @public
+export const coreModule: () => Module<CoreModule>;
+
+// @public (undocumented)
+export type CreateApi<Modules extends ModuleName> = {
+    <BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string = 'api', TagTypes extends string = never>(options: CreateApiOptions<BaseQuery, Definitions, ReducerPath, TagTypes>): Api<BaseQuery, Definitions, ReducerPath, TagTypes, Modules>;
+};
+
+// @public (undocumented)
+export const createApi: CreateApi<typeof coreModuleName | typeof reactHooksModuleName>;
+
+// @public (undocumented)
+export interface CreateApiOptions<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string = 'api', TagTypes extends string = never> {
+    baseQuery: BaseQuery;
+    endpoints(build: EndpointBuilder<BaseQuery, TagTypes, ReducerPath>): Definitions;
+    // @deprecated (undocumented)
+    entityTypes?: readonly TagTypes[];
+    keepUnusedDataFor?: number;
+    reducerPath?: ReducerPath;
+    refetchOnFocus?: boolean;
+    refetchOnMountOrArgChange?: boolean | number;
+    refetchOnReconnect?: boolean;
+    serializeQueryArgs?: SerializeQueryArgs<BaseQueryArg<BaseQuery>>;
+    tagTypes?: readonly TagTypes[];
+}
+
+// @public (undocumented)
+export type EndpointDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string> = QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath> | MutationDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>;
+
+// @public (undocumented)
+export type EndpointDefinitions = Record<string, EndpointDefinition<any, any, any, any>>;
+
+// @public
+export function fakeBaseQuery<ErrorType>(): BaseQueryFn<void, NEVER, ErrorType, {}>;
+
+// @public (undocumented)
+export interface FetchArgs extends CustomRequestInit {
+    // (undocumented)
+    body?: any;
+    // (undocumented)
+    params?: Record<string, any>;
+    // (undocumented)
+    responseHandler?: ResponseHandler;
+    // (undocumented)
+    url: string;
+    // (undocumented)
+    validateStatus?: (response: Response, body: any) => boolean;
+}
+
+// @public
+export function fetchBaseQuery({ baseUrl, prepareHeaders, fetchFn, ...baseFetchOptions }?: FetchBaseQueryArgs): BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>;
+
+// @public (undocumented)
+export interface FetchBaseQueryError {
+    // (undocumented)
+    data: unknown;
+    // (undocumented)
+    status: number;
+}
+
+// @public (undocumented)
+export type Module<Name extends ModuleName> = {
+    name: Name;
+    init<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string>(api: Api<BaseQuery, EndpointDefinitions, ReducerPath, TagTypes, ModuleName>, options: Required<CreateApiOptions<BaseQuery, Definitions, ReducerPath, TagTypes>>, context: ApiContext<Definitions>): {
+        injectEndpoint(endpointName: string, definition: EndpointDefinition<any, any, any, any>): void;
+    };
+};
+
+// @public (undocumented)
+export type MutationDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string, Context = Record<string, any>> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> & MutationExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath, Context>;
+
+// @public (undocumented)
+export type QueryDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string, Context = Record<string, any>> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> & QueryExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath, Context>;
+
+// @public
+export enum QueryStatus {
+    // (undocumented)
+    fulfilled = "fulfilled",
+    // (undocumented)
+    pending = "pending",
+    // (undocumented)
+    rejected = "rejected",
+    // (undocumented)
+    uninitialized = "uninitialized"
+}
+
+// @public
+export const reactHooksModule: ({ batch, useDispatch, useSelector, useStore, }?: ReactHooksModuleOptions) => Module<ReactHooksModule>;
+
+// @public
+export const retry: BaseQueryEnhancer<unknown, StaggerOptions, void | StaggerOptions> & {
+    fail: typeof fail_2;
+};
+
+// @public
+export function setupListeners(dispatch: ThunkDispatch<any, any, any>, customHandler?: (dispatch: ThunkDispatch<any, any, any>, actions: {
+    onFocus: typeof onFocus;
+    onFocusLost: typeof onFocusLost;
+    onOnline: typeof onOnline;
+    onOffline: typeof onOffline;
+}) => () => void): () => void;
+
+// @public (undocumented)
+export const skipSelector: unique symbol;
+
+
+// (No @packageDocumentation comment for this package)
+
+```
diff --git a/etc/rtk-query.api.md b/etc/rtk-query.api.md
index 1a046705..53ded28e 100644
--- a/etc/rtk-query.api.md
+++ b/etc/rtk-query.api.md
@@ -1,150 +1,153 @@
-## API Report File for "@reduxjs/toolkit"
-
-> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
-
-```ts
-
-import { ActionCreatorWithoutPayload } from '@reduxjs/toolkit';
-import { AnyAction } from '@reduxjs/toolkit';
-import { SerializedError } from '@reduxjs/toolkit';
-import { ThunkDispatch } from '@reduxjs/toolkit';
-
-// @public (undocumented)
-export type Api<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string, Enhancers extends ModuleName = CoreModule> = Id<Id<UnionToIntersection<ApiModules<BaseQuery, Definitions, ReducerPath, TagTypes>[Enhancers]>> & {
-    injectEndpoints<NewDefinitions extends EndpointDefinitions>(_: {
-        endpoints: (build: EndpointBuilder<BaseQuery, TagTypes, ReducerPath>) => NewDefinitions;
-        overrideExisting?: boolean;
-    }): Api<BaseQuery, Definitions & NewDefinitions, ReducerPath, TagTypes, Enhancers>;
-    enhanceEndpoints<NewTagTypes extends string = never>(_: {
-        addEntityTypes?: readonly NewTagTypes[];
-        addTagTypes?: readonly NewTagTypes[];
-        endpoints?: ReplaceTagTypes<Definitions, TagTypes | NoInfer<NewTagTypes>> extends infer NewDefinitions ? {
-            [K in keyof NewDefinitions]?: Partial<NewDefinitions[K]> | ((definition: NewDefinitions[K]) => void);
-        } : never;
-    }): Api<BaseQuery, ReplaceTagTypes<Definitions, TagTypes | NewTagTypes>, ReducerPath, TagTypes | NewTagTypes, Enhancers>;
-}>;
-
-// @public (undocumented)
-export interface ApiModules<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string> {
-}
-
-// @public (undocumented)
-export type ApiWithInjectedEndpoints<ApiDefinition extends Api<any, any, any, any>, Injections extends ApiDefinition extends Api<infer B, any, infer R, infer E> ? [Api<B, any, R, E>, ...Api<B, any, R, E>[]] : never> = Omit<ApiDefinition, 'endpoints'> & Omit<Injections, 'endpoints'> & {
-    endpoints: ApiDefinition['endpoints'] & Partial<UnionToIntersection<Injections[number]['endpoints']>>;
-};
-
-// @public (undocumented)
-export type BaseQueryEnhancer<AdditionalArgs = unknown, AdditionalDefinitionExtraOptions = unknown, Config = void> = <BaseQuery extends BaseQueryFn>(baseQuery: BaseQuery, config: Config) => BaseQueryFn<BaseQueryArg<BaseQuery> & AdditionalArgs, BaseQueryResult<BaseQuery>, BaseQueryError<BaseQuery>, BaseQueryExtraOptions<BaseQuery> & AdditionalDefinitionExtraOptions>;
-
-// @public (undocumented)
-export type BaseQueryFn<Args = any, Result = unknown, Error = unknown, DefinitionExtraOptions = {}, Meta = {}> = (args: Args, api: BaseQueryApi, extraOptions: DefinitionExtraOptions) => MaybePromise<QueryReturnValue<Result, Error, Meta>>;
-
-// @public
-export function buildCreateApi<Modules extends [Module<any>, ...Module<any>[]]>(...modules: Modules): CreateApi<Modules[number]['name']>;
-
-// @public
-export const coreModule: () => Module<CoreModule>;
-
-// @public (undocumented)
-export type CreateApi<Modules extends ModuleName> = {
-    <BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string = 'api', TagTypes extends string = never>(options: CreateApiOptions<BaseQuery, Definitions, ReducerPath, TagTypes>): Api<BaseQuery, Definitions, ReducerPath, TagTypes, Modules>;
-};
-
-// @public (undocumented)
-export const createApi: CreateApi<typeof coreModuleName>;
-
-// @public (undocumented)
-export interface CreateApiOptions<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string = 'api', TagTypes extends string = never> {
-    baseQuery: BaseQuery;
-    endpoints(build: EndpointBuilder<BaseQuery, TagTypes, ReducerPath>): Definitions;
-    // @deprecated (undocumented)
-    entityTypes?: readonly TagTypes[];
-    keepUnusedDataFor?: number;
-    reducerPath?: ReducerPath;
-    refetchOnFocus?: boolean;
-    refetchOnMountOrArgChange?: boolean | number;
-    refetchOnReconnect?: boolean;
-    serializeQueryArgs?: SerializeQueryArgs<BaseQueryArg<BaseQuery>>;
-    tagTypes?: readonly TagTypes[];
-}
-
-// @public (undocumented)
-export type EndpointDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string> = QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath> | MutationDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>;
-
-// @public (undocumented)
-export type EndpointDefinitions = Record<string, EndpointDefinition<any, any, any, any>>;
-
-// @public
-export function fakeBaseQuery<ErrorType>(): BaseQueryFn<void, NEVER, ErrorType, {}>;
-
-// @public (undocumented)
-export interface FetchArgs extends CustomRequestInit {
-    // (undocumented)
-    body?: any;
-    // (undocumented)
-    params?: Record<string, any>;
-    // (undocumented)
-    responseHandler?: ResponseHandler;
-    // (undocumented)
-    url: string;
-    // (undocumented)
-    validateStatus?: (response: Response, body: any) => boolean;
-}
-
-// @public
-export function fetchBaseQuery({ baseUrl, prepareHeaders, fetchFn, ...baseFetchOptions }?: FetchBaseQueryArgs): BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>;
-
-// @public (undocumented)
-export interface FetchBaseQueryError {
-    // (undocumented)
-    data: unknown;
-    // (undocumented)
-    status: number;
-}
-
-// @public (undocumented)
-export type Module<Name extends ModuleName> = {
-    name: Name;
-    init<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string>(api: Api<BaseQuery, EndpointDefinitions, ReducerPath, TagTypes, ModuleName>, options: Required<CreateApiOptions<BaseQuery, Definitions, ReducerPath, TagTypes>>, context: ApiContext<Definitions>): {
-        injectEndpoint(endpointName: string, definition: EndpointDefinition<any, any, any, any>): void;
-    };
-};
-
-// @public (undocumented)
-export type MutationDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string, Context = Record<string, any>> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> & MutationExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath, Context>;
-
-// @public (undocumented)
-export type QueryDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string, Context = Record<string, any>> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> & QueryExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath, Context>;
-
-// @public
-export enum QueryStatus {
-    // (undocumented)
-    fulfilled = "fulfilled",
-    // (undocumented)
-    pending = "pending",
-    // (undocumented)
-    rejected = "rejected",
-    // (undocumented)
-    uninitialized = "uninitialized"
-}
-
-// @public
-export const retry: BaseQueryEnhancer<unknown, StaggerOptions, void | StaggerOptions> & {
-    fail: typeof fail_2;
-};
-
-// @public
-export function setupListeners(dispatch: ThunkDispatch<any, any, any>, customHandler?: (dispatch: ThunkDispatch<any, any, any>, actions: {
-    onFocus: typeof onFocus;
-    onFocusLost: typeof onFocusLost;
-    onOnline: typeof onOnline;
-    onOffline: typeof onOffline;
-}) => () => void): () => void;
-
-// @public (undocumented)
-export const skipSelector: unique symbol;
-
-
-// (No @packageDocumentation comment for this package)
-
-```
+## API Report File for "@reduxjs/toolkit"
+
+> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
+
+```ts
+
+import { ActionCreatorWithoutPayload } from '@reduxjs/toolkit';
+import { AnyAction } from '@reduxjs/toolkit';
+import { SerializedError } from '@reduxjs/toolkit';
+import { ThunkDispatch } from '@reduxjs/toolkit';
+
+// @public (undocumented)
+export type Api<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string, Enhancers extends ModuleName = CoreModule> = Id<Id<UnionToIntersection<ApiModules<BaseQuery, Definitions, ReducerPath, TagTypes>[Enhancers]>> & {
+    injectEndpoints<NewDefinitions extends EndpointDefinitions>(_: {
+        endpoints: (build: EndpointBuilder<BaseQuery, TagTypes, ReducerPath>) => NewDefinitions;
+        overrideExisting?: boolean;
+    }): Api<BaseQuery, Definitions & NewDefinitions, ReducerPath, TagTypes, Enhancers>;
+    enhanceEndpoints<NewTagTypes extends string = never>(_: {
+        addEntityTypes?: readonly NewTagTypes[];
+        addTagTypes?: readonly NewTagTypes[];
+        endpoints?: ReplaceTagTypes<Definitions, TagTypes | NoInfer<NewTagTypes>> extends infer NewDefinitions ? {
+            [K in keyof NewDefinitions]?: Partial<NewDefinitions[K]> | ((definition: NewDefinitions[K]) => void);
+        } : never;
+    }): Api<BaseQuery, ReplaceTagTypes<Definitions, TagTypes | NewTagTypes>, ReducerPath, TagTypes | NewTagTypes, Enhancers>;
+}>;
+
+// @public (undocumented)
+export interface ApiModules<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string> {
+}
+
+// @public (undocumented)
+export type ApiWithInjectedEndpoints<ApiDefinition extends Api<any, any, any, any>, Injections extends ApiDefinition extends Api<infer B, any, infer R, infer E> ? [Api<B, any, R, E>, ...Api<B, any, R, E>[]] : never> = Omit<ApiDefinition, 'endpoints'> & Omit<Injections, 'endpoints'> & {
+    endpoints: ApiDefinition['endpoints'] & Partial<UnionToIntersection<Injections[number]['endpoints']>>;
+};
+
+// @public (undocumented)
+export type BaseQueryEnhancer<AdditionalArgs = unknown, AdditionalDefinitionExtraOptions = unknown, Config = void> = <BaseQuery extends BaseQueryFn>(baseQuery: BaseQuery, config: Config) => BaseQueryFn<BaseQueryArg<BaseQuery> & AdditionalArgs, BaseQueryResult<BaseQuery>, BaseQueryError<BaseQuery>, BaseQueryExtraOptions<BaseQuery> & AdditionalDefinitionExtraOptions>;
+
+// @public (undocumented)
+export type BaseQueryFn<Args = any, Result = unknown, Error = unknown, DefinitionExtraOptions = {}, Meta = {}> = (args: Args, api: BaseQueryApi, extraOptions: DefinitionExtraOptions) => MaybePromise<QueryReturnValue<Result, Error, Meta>>;
+
+// @public
+export function buildCreateApi<Modules extends [Module<any>, ...Module<any>[]]>(...modules: Modules): CreateApi<Modules[number]['name']>;
+
+// @public (undocumented)
+export function copyWithStructuralSharing<T>(oldObj: any, newObj: T): T;
+
+// @public
+export const coreModule: () => Module<CoreModule>;
+
+// @public (undocumented)
+export type CreateApi<Modules extends ModuleName> = {
+    <BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string = 'api', TagTypes extends string = never>(options: CreateApiOptions<BaseQuery, Definitions, ReducerPath, TagTypes>): Api<BaseQuery, Definitions, ReducerPath, TagTypes, Modules>;
+};
+
+// @public (undocumented)
+export const createApi: CreateApi<typeof coreModuleName>;
+
+// @public (undocumented)
+export interface CreateApiOptions<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string = 'api', TagTypes extends string = never> {
+    baseQuery: BaseQuery;
+    endpoints(build: EndpointBuilder<BaseQuery, TagTypes, ReducerPath>): Definitions;
+    // @deprecated (undocumented)
+    entityTypes?: readonly TagTypes[];
+    keepUnusedDataFor?: number;
+    reducerPath?: ReducerPath;
+    refetchOnFocus?: boolean;
+    refetchOnMountOrArgChange?: boolean | number;
+    refetchOnReconnect?: boolean;
+    serializeQueryArgs?: SerializeQueryArgs<BaseQueryArg<BaseQuery>>;
+    tagTypes?: readonly TagTypes[];
+}
+
+// @public (undocumented)
+export type EndpointDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string> = QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath> | MutationDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>;
+
+// @public (undocumented)
+export type EndpointDefinitions = Record<string, EndpointDefinition<any, any, any, any>>;
+
+// @public
+export function fakeBaseQuery<ErrorType>(): BaseQueryFn<void, NEVER, ErrorType, {}>;
+
+// @public (undocumented)
+export interface FetchArgs extends CustomRequestInit {
+    // (undocumented)
+    body?: any;
+    // (undocumented)
+    params?: Record<string, any>;
+    // (undocumented)
+    responseHandler?: ResponseHandler;
+    // (undocumented)
+    url: string;
+    // (undocumented)
+    validateStatus?: (response: Response, body: any) => boolean;
+}
+
+// @public
+export function fetchBaseQuery({ baseUrl, prepareHeaders, fetchFn, ...baseFetchOptions }?: FetchBaseQueryArgs): BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>;
+
+// @public (undocumented)
+export interface FetchBaseQueryError {
+    // (undocumented)
+    data: unknown;
+    // (undocumented)
+    status: number;
+}
+
+// @public (undocumented)
+export type Module<Name extends ModuleName> = {
+    name: Name;
+    init<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string>(api: Api<BaseQuery, EndpointDefinitions, ReducerPath, TagTypes, ModuleName>, options: Required<CreateApiOptions<BaseQuery, Definitions, ReducerPath, TagTypes>>, context: ApiContext<Definitions>): {
+        injectEndpoint(endpointName: string, definition: EndpointDefinition<any, any, any, any>): void;
+    };
+};
+
+// @public (undocumented)
+export type MutationDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string, Context = Record<string, any>> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> & MutationExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath, Context>;
+
+// @public (undocumented)
+export type QueryDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string, Context = Record<string, any>> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> & QueryExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath, Context>;
+
+// @public
+export enum QueryStatus {
+    // (undocumented)
+    fulfilled = "fulfilled",
+    // (undocumented)
+    pending = "pending",
+    // (undocumented)
+    rejected = "rejected",
+    // (undocumented)
+    uninitialized = "uninitialized"
+}
+
+// @public
+export const retry: BaseQueryEnhancer<unknown, StaggerOptions, void | StaggerOptions> & {
+    fail: typeof fail_2;
+};
+
+// @public
+export function setupListeners(dispatch: ThunkDispatch<any, any, any>, customHandler?: (dispatch: ThunkDispatch<any, any, any>, actions: {
+    onFocus: typeof onFocus;
+    onFocusLost: typeof onFocusLost;
+    onOnline: typeof onOnline;
+    onOffline: typeof onOffline;
+}) => () => void): () => void;
+
+// @public (undocumented)
+export const skipSelector: unique symbol;
+
+
+// (No @packageDocumentation comment for this package)
+
+```
diff --git a/jest.config.js b/jest.config.js
index d8ef40e4..8f445251 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -2,10 +2,12 @@ module.exports = {
   setupFilesAfterEnv: ['./jest.setup.js'],
   testPathIgnorePatterns: ['<rootDir>/query-old/*'],
   moduleNameMapper: {
-    '^@reduxjs/toolkit$': '<rootDir>/src/index.ts',
-    '^@reduxjs/toolkit/query$': '<rootDir>/src/query/index.ts',
-    '^@reduxjs/toolkit/query/react$': '<rootDir>/src/query/react/index.ts',
-    '^@internal/(.*)$': '<rootDir>/src/query/*',
+    '^@reduxjs/toolkit$': '<rootDir>/src/index.ts', // @remap-prod-remove-line
+    '^@reduxjs/toolkit/query$': '<rootDir>/src/query/index.ts', // @remap-prod-remove-line
+    '^@reduxjs/toolkit/query/react$': '<rootDir>/src/query/react/index.ts', // @remap-prod-remove-line
+    // this mapping is disabled as we want `dist` imports in the tests only to be used for "type-only" imports which don't play a role for jest
+    //'^@reduxjs/toolkit/dist/(.*)$': '<rootDir>/src/*',
+    '^@internal/(.*)$': '<rootDir>/src/$1',
   },
   globals: {
     'ts-jest': {
diff --git a/package-lock.json b/package-lock.json
index 0130955a..ad1b59a0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -13540,15 +13540,6 @@
       "integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==",
       "dev": true
     },
-    "typings-tester": {
-      "version": "0.3.2",
-      "resolved": "https://registry.npmjs.org/typings-tester/-/typings-tester-0.3.2.tgz",
-      "integrity": "sha512-HjGoAM2UoGhmSKKy23TYEKkxlphdJFdix5VvqWFLzH1BJVnnwG38tpC6SXPgqhfFGfHY77RlN1K8ts0dbWBQ7A==",
-      "dev": true,
-      "requires": {
-        "commander": "^2.12.2"
-      }
-    },
     "unbox-primitive": {
       "version": "1.0.1",
       "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz",
diff --git a/package.json b/package.json
index 6f95e768..695d890d 100644
--- a/package.json
+++ b/package.json
@@ -64,7 +64,6 @@
     "tsdx": "^0.14.1",
     "tslib": "^1.10.0",
     "typescript": "^4.2.3",
-    "typings-tester": "^0.3.2",
     "yargs": "^15.3.1"
   },
   "scripts": {
@@ -76,7 +75,7 @@
     "lint": "tsdx lint src",
     "prepare": "npm run build-ci",
     "test": "tsdx test --runInBand",
-    "type-tests": "cd type-tests/files && tsc"
+    "type-tests": "yarn tsc -p src/tests && yarn tsc -p src/query/tests"
   },
   "files": [
     "dist/**/*.js",
diff --git a/scripts/build.ts b/scripts/build.ts
index d6c0cd0b..d7155f0e 100644
--- a/scripts/build.ts
+++ b/scripts/build.ts
@@ -322,7 +322,7 @@ async function main({ skipExtraction = false, local = false }: BuildArgs) {
   // We need one additional package.json file in dist to support
   // versioned types for TS <4.1
   fs.copyFileSync(
-    'src/query/react/versionedTypes/package.json',
+    'src/query/react/versionedTypes/package.dist.json',
     'dist/query/react/versionedTypes/package.json'
   )
 
diff --git a/src/query/index.ts b/src/query/index.ts
index 8780398e..6289b69c 100644
--- a/src/query/index.ts
+++ b/src/query/index.ts
@@ -20,5 +20,5 @@ export { skipSelector } from './core/buildSelectors'
 export type { CreateApi, CreateApiOptions } from './createApi'
 export { buildCreateApi } from './createApi'
 export { fakeBaseQuery } from './fakeBaseQuery'
-
+export { copyWithStructuralSharing } from './utils/copyWithStructuralSharing'
 export { createApi, coreModule } from './core'
diff --git a/src/query/react/module.ts b/src/query/react/module.ts
index ed13a97c..b46d1ecb 100644
--- a/src/query/react/module.ts
+++ b/src/query/react/module.ts
@@ -12,7 +12,7 @@ import { capitalize } from '../utils'
 import { safeAssign } from '../tsHelpers'
 import { BaseQueryFn } from '../baseQueryTypes'
 
-import { HooksWithUniqueNames } from './versionedTypes/index'
+import { HooksWithUniqueNames } from './versionedTypes'
 
 import {
   useDispatch as rrUseDispatch,
diff --git a/src/query/react/versionedTypes/package.dist.json b/src/query/react/versionedTypes/package.dist.json
new file mode 100644
index 00000000..3e11bf7b
--- /dev/null
+++ b/src/query/react/versionedTypes/package.dist.json
@@ -0,0 +1,10 @@
+{
+  "typesVersions": {
+    ">=4.1": {
+      "index": ["./ts41Types.d.ts"]
+    },
+    "<4.1": {
+      "index": ["./ts40Types.d.ts"]
+    }
+  }
+}
diff --git a/src/query/react/versionedTypes/package.json b/src/query/react/versionedTypes/package.json
deleted file mode 100644
index 978648c7..00000000
--- a/src/query/react/versionedTypes/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
-  "typesVersions": {
-    ">=4.1": {
-      "index": [
-        "./ts41Types.d.ts"
-      ]
-    },
-    "<4.1": {
-      "index": [
-        "./ts40Types.d.ts"
-      ]
-    }
-  }
-}
diff --git a/tsconfig.base.json b/tsconfig.base.json
index 28ee3547..09cbbdf4 100644
--- a/tsconfig.base.json
+++ b/tsconfig.base.json
@@ -31,9 +31,13 @@
     "emitDeclarationOnly": true,
     "baseUrl": ".",
     "paths": {
-      "@reduxjs/toolkit": ["src/index.ts"],
-      "@reduxjs/toolkit/query": ["src/query/index.ts"],
-      "@reduxjs/toolkit/query/react": ["src/query/react/index.ts"],
+      "@reduxjs/toolkit": ["src/index.ts"], // @remap-prod-remove-line
+      "@reduxjs/toolkit/query": ["src/query/index.ts"], // @remap-prod-remove-line
+      "@reduxjs/toolkit/query/react": ["src/query/react/index.ts"], // @remap-prod-remove-line
+      // for type imports in tests only
+      "@reduxjs/toolkit/dist/query/*": ["src/query/*"], // @remap-prod-remove-line
+      // internal imports in tests only
+      "@internal/*": ["src/*"]
     }
   }
-}
\ No newline at end of file
+}


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index d3f8bb39..3c4e24f5 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -33,7 +33,42 @@ jobs:
           name: package
           path: reduxjs-toolkit*.tgz
 
-  test:
+  test-dist:
+    name: Test against dist
+    needs: [build]
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        node: ['14.x']
+    steps:
+      - name: Checkout repo
+        uses: actions/checkout@v2
+
+      - name: Use node ${{ matrix.node }}
+        uses: actions/setup-node@v1
+        with:
+          node-version: ${{ matrix.node }}
+
+      - uses: c-hive/gha-npm-cache@v1
+
+      - name: Install deps
+        run: npm ci --ignore-scripts
+
+      - uses: actions/download-artifact@v2
+        with:
+          name: package
+
+      - name: Install build artifact
+        run: |
+          sed -i -e '/"name": "@reduxjs\/toolkit",/d' package.json
+          npm i reduxjs-toolkit-*.tgz --ignore-scripts
+          sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./jest.config.js ./src/tests/*.* ./src/query/tests/*.*
+
+      - name: Run tests, against dist
+        run: npm test
+
+  test-types:
     name: Test Types with TypeScript ${{ matrix.ts }}
 
     needs: [build]
@@ -42,7 +77,7 @@ jobs:
       fail-fast: false
       matrix:
         node: ['14.x']
-        ts: ['3.8', '3.9', '4.0', '4.1', 'next']
+        ts: ['3.9', '4.0', '4.1', '4.2', 'next']
     steps:
       - name: Checkout repo
         uses: actions/checkout@v2
@@ -64,26 +99,15 @@ jobs:
         with:
           name: package
 
-      - name: Unpack build artifact to dist
-        run: tar -xzvf reduxjs-toolkit-*.tgz --strip-components=1 package/dist
-
-      - name: Remap @redux/toolkit from src to dist
+      - name: Install build artifact
         run: |
-          sed -i -e 's|@reduxjs/toolkit": \["./src"\]|@reduxjs/toolkit": ["."]|' ./type-tests/files/tsconfig.json
+          sed -i -e '/"name": "@reduxjs\/toolkit",/d' package.json
+          npm i reduxjs-toolkit-*.tgz --ignore-scripts
+          sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./jest.config.js ./src/tests/*.* ./src/query/tests/*.*
 
-      - name: Prefix `freeze` re-export for pre-3.7 TS versions with @ts-ignore
-        if: ${{ matrix.ts < 3.7 }}
-        run: |
-          sed -i -e "/import .* freeze .* from 'immer'/s/^/\/\/ @ts-ignore\n/" dist/typings.d.ts
-          sed -i -e "/  freeze,/s/^/  \/\/ @ts-ignore\n/" src/index.ts
-
-      - name: Use typings-tester for old TS versions
-        if: ${{ matrix.ts < 3.9 }}
-        run: |
-          sed -i -e 's/"cd type-tests.*"/"npm run test type-tests"/' package.json
-          sed -i -e 's/@ts-expect-error/typings:expect-error/' type-tests/files/*.typetest.ts
-          sed -i -e 's/@ts-expect-error/@ts-ignore/' type-tests/files/*.ts
-          mv type-tests/types.test.disabled.ts type-tests/types.test.ts
+      - 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: |
diff --git a/src/query/tests/apiProvider.test.tsx b/src/query/tests/apiProvider.test.tsx
index 09c1b548..80ed29b3 100644
--- a/src/query/tests/apiProvider.test.tsx
+++ b/src/query/tests/apiProvider.test.tsx
@@ -1,5 +1,5 @@
 import * as React from 'react'
-import { createApi, ApiProvider } from '../react'
+import { createApi, ApiProvider } from '@reduxjs/toolkit/query/react'
 import { fireEvent, render, waitFor } from '@testing-library/react'
 import { waitMs } from './helpers'
 
diff --git a/src/query/tests/buildHooks.test.tsx b/src/query/tests/buildHooks.test.tsx
index 5c5cc69a..e3395dcc 100644
--- a/src/query/tests/buildHooks.test.tsx
+++ b/src/query/tests/buildHooks.test.tsx
@@ -1,5 +1,9 @@
 import * as React from 'react'
-import { createApi, fetchBaseQuery, QueryStatus } from '../react'
+import {
+  createApi,
+  fetchBaseQuery,
+  QueryStatus,
+} from '@reduxjs/toolkit/query/react'
 import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'
 import userEvent from '@testing-library/user-event'
 import { rest } from 'msw'
@@ -14,8 +18,8 @@ import {
 } from './helpers'
 import { server } from './mocks/server'
 import { AnyAction } from 'redux'
-import { SubscriptionOptions } from '../core/apiState'
-import { SerializedError } from '../../createAsyncThunk'
+import type { SubscriptionOptions } from '@reduxjs/toolkit/dist/query/core/apiState'
+import { SerializedError } from '@reduxjs/toolkit'
 
 // Just setup a temporary in-memory counter for tests that `getIncrementedAmount`.
 // This can be used to test how many renders happen due to data changes or
@@ -1518,6 +1522,7 @@ describe('hooks with createApi defaults set', () => {
     expectExactType(api.useGetPostsQuery)(api.endpoints.getPosts.useQuery)
     // @pre41-ts-ignore
     expectExactType(api.useUpdatePostMutation)(
+      // @pre41-ts-ignore
       api.endpoints.updatePost.useMutation
     )
     // @pre41-ts-ignore
diff --git a/src/query/tests/buildMiddleware.test.tsx b/src/query/tests/buildMiddleware.test.tsx
index 4d090e2b..d1bbed99 100644
--- a/src/query/tests/buildMiddleware.test.tsx
+++ b/src/query/tests/buildMiddleware.test.tsx
@@ -1,4 +1,4 @@
-import { createApi } from '../react'
+import { createApi } from '@reduxjs/toolkit/query'
 import { actionsReducer, matchSequence, setupApiStore, waitMs } from './helpers'
 
 const baseQuery = (args?: any) => ({ data: args })
diff --git a/src/query/tests/buildSlice.test.ts b/src/query/tests/buildSlice.test.ts
index 798b30aa..e3a4a775 100644
--- a/src/query/tests/buildSlice.test.ts
+++ b/src/query/tests/buildSlice.test.ts
@@ -1,5 +1,5 @@
-import { createSlice } from '../..'
-import { createApi } from '../react'
+import { createSlice } from '@reduxjs/toolkit'
+import { createApi } from '@reduxjs/toolkit/query'
 import { setupApiStore } from './helpers'
 
 const baseQuery = (args?: any) => ({ data: args })
diff --git a/src/query/tests/buildThunks.test.tsx b/src/query/tests/buildThunks.test.tsx
index 56eff9b4..8919807e 100644
--- a/src/query/tests/buildThunks.test.tsx
+++ b/src/query/tests/buildThunks.test.tsx
@@ -1,5 +1,5 @@
-import { configureStore } from '../../' // '@reduxjs/toolkit'
-import { createApi } from '../react'
+import { configureStore } from '@reduxjs/toolkit'
+import { createApi } from '@reduxjs/toolkit/query/react'
 
 import { renderHook } from '@testing-library/react-hooks'
 import { withProvider } from './helpers'
diff --git a/src/query/tests/cleanup.test.tsx b/src/query/tests/cleanup.test.tsx
index 977edda2..1b96d723 100644
--- a/src/query/tests/cleanup.test.tsx
+++ b/src/query/tests/cleanup.test.tsx
@@ -2,7 +2,7 @@
 
 import React from 'react'
 
-import { createApi, QueryStatus } from '../react'
+import { createApi, QueryStatus } from '@reduxjs/toolkit/query/react'
 import { render, waitFor } from '@testing-library/react'
 import { setupApiStore } from './helpers'
 
diff --git a/src/query/tests/copyWithStructuralSharing.test.ts b/src/query/tests/copyWithStructuralSharing.test.ts
index ded93f9a..889414d9 100644
--- a/src/query/tests/copyWithStructuralSharing.test.ts
+++ b/src/query/tests/copyWithStructuralSharing.test.ts
@@ -1,4 +1,4 @@
-import { copyWithStructuralSharing } from '../utils/copyWithStructuralSharing'
+import { copyWithStructuralSharing } from '@reduxjs/toolkit/query'
 
 test('equal object from JSON Object', () => {
   const json = JSON.stringify({
diff --git a/src/query/tests/createApi.test.ts b/src/query/tests/createApi.test.ts
index 74a522a3..8ae5524e 100644
--- a/src/query/tests/createApi.test.ts
+++ b/src/query/tests/createApi.test.ts
@@ -1,6 +1,11 @@
-import { configureStore, createAction, createReducer } from '../..'
-import { Api, createApi, fetchBaseQuery } from '..'
-import { QueryDefinition, MutationDefinition } from '../endpointDefinitions'
+import { configureStore, createAction, createReducer } from '@reduxjs/toolkit'
+import {
+  Api,
+  createApi,
+  fetchBaseQuery,
+  MutationDefinition,
+  QueryDefinition,
+} from '@reduxjs/toolkit/query'
 import {
   ANY,
   expectType,
diff --git a/src/query/tests/errorHandling.test.tsx b/src/query/tests/errorHandling.test.tsx
index ffdfd7c4..c40e395f 100644
--- a/src/query/tests/errorHandling.test.tsx
+++ b/src/query/tests/errorHandling.test.tsx
@@ -1,5 +1,9 @@
 import * as React from 'react'
-import { BaseQueryFn, createApi, fetchBaseQuery } from '../react'
+import {
+  BaseQueryFn,
+  createApi,
+  fetchBaseQuery,
+} from '@reduxjs/toolkit/query/react'
 import { renderHook, act } from '@testing-library/react-hooks'
 import { rest } from 'msw'
 import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'
@@ -8,7 +12,7 @@ import { expectExactType, hookWaitFor, setupApiStore } from './helpers'
 import { server } from './mocks/server'
 import { fireEvent, render, waitFor, screen } from '@testing-library/react'
 import { useDispatch } from 'react-redux'
-import { AnyAction, ThunkDispatch } from '../..'
+import { AnyAction, ThunkDispatch } from '@reduxjs/toolkit'
 
 const baseQuery = fetchBaseQuery({ baseUrl: 'http://example.com' })
 
diff --git a/src/query/tests/fakeBaseQuery.test.tsx b/src/query/tests/fakeBaseQuery.test.tsx
index d5c3bd85..5b097806 100644
--- a/src/query/tests/fakeBaseQuery.test.tsx
+++ b/src/query/tests/fakeBaseQuery.test.tsx
@@ -1,5 +1,5 @@
-import { configureStore } from '../../configureStore'
-import { createApi, fakeBaseQuery } from '..'
+import { configureStore } from '@reduxjs/toolkit'
+import { createApi, fakeBaseQuery } from '@reduxjs/toolkit/query'
 
 type CustomErrorType = { type: 'Custom' }
 
diff --git a/src/query/tests/fetchBaseQuery.test.tsx b/src/query/tests/fetchBaseQuery.test.tsx
index 83131388..7bda199f 100644
--- a/src/query/tests/fetchBaseQuery.test.tsx
+++ b/src/query/tests/fetchBaseQuery.test.tsx
@@ -1,5 +1,5 @@
-import { createSlice } from '../../'
-import { createApi, fetchBaseQuery } from '..'
+import { createSlice } from '@reduxjs/toolkit'
+import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query'
 import { setupApiStore } from './helpers'
 import { default as crossFetch } from 'cross-fetch'
 
diff --git a/src/query/tests/helpers.tsx b/src/query/tests/helpers.tsx
index aac24bf8..5330e36f 100644
--- a/src/query/tests/helpers.tsx
+++ b/src/query/tests/helpers.tsx
@@ -4,8 +4,8 @@ import {
   EnhancedStore,
   Middleware,
   Store,
-} from '../../'
-import { setupListeners } from '..'
+} from '@reduxjs/toolkit'
+import { setupListeners } from '@reduxjs/toolkit/query'
 
 import { act } from '@testing-library/react-hooks'
 import React, { Reducer, useCallback } from 'react'
diff --git a/src/query/tests/invalidation.test.tsx b/src/query/tests/invalidation.test.tsx
index 4d48137e..afcd052e 100644
--- a/src/query/tests/invalidation.test.tsx
+++ b/src/query/tests/invalidation.test.tsx
@@ -1,6 +1,6 @@
-import { createApi, fakeBaseQuery } from '../react'
+import { createApi, fakeBaseQuery } from '@reduxjs/toolkit/query'
 import { setupApiStore, waitMs } from './helpers'
-import type { ResultDescription } from '../endpointDefinitions'
+import type { ResultDescription } from '@reduxjs/toolkit/dist/query/endpointDefinitions'
 
 const tagTypes = ['apple', 'pear', 'banana', 'tomato'] as const
 type TagTypes = typeof tagTypes[number]
diff --git a/src/query/tests/matchers.test.tsx b/src/query/tests/matchers.test.tsx
index 62fc15b7..848079dd 100644
--- a/src/query/tests/matchers.test.tsx
+++ b/src/query/tests/matchers.test.tsx
@@ -1,5 +1,5 @@
-import { createSlice, SerializedError } from '../../'
-import { createApi, fetchBaseQuery } from '../react'
+import { createSlice, SerializedError } from '@reduxjs/toolkit'
+import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
 import { renderHook, act } from '@testing-library/react-hooks'
 import {
   actionsReducer,
diff --git a/src/query/tests/optimisticUpdates.test.tsx b/src/query/tests/optimisticUpdates.test.tsx
index da2bbe74..ed0c72e5 100644
--- a/src/query/tests/optimisticUpdates.test.tsx
+++ b/src/query/tests/optimisticUpdates.test.tsx
@@ -1,4 +1,4 @@
-import { createApi } from '../react'
+import { createApi } from '@reduxjs/toolkit/query/react'
 import { actionsReducer, hookWaitFor, setupApiStore, waitMs } from './helpers'
 import { renderHook, act } from '@testing-library/react-hooks'
 
diff --git a/src/query/tests/queryFn.test.tsx b/src/query/tests/queryFn.test.tsx
index 1d4a7326..83bb489f 100644
--- a/src/query/tests/queryFn.test.tsx
+++ b/src/query/tests/queryFn.test.tsx
@@ -1,5 +1,10 @@
-import { configureStore } from '../../'
-import { BaseQueryFn, createApi, fetchBaseQuery, FetchBaseQueryError } from '..'
+import { configureStore } from '@reduxjs/toolkit'
+import {
+  BaseQueryFn,
+  createApi,
+  fetchBaseQuery,
+  FetchBaseQueryError,
+} from '@reduxjs/toolkit/query'
 import { Post, posts } from './mocks/server'
 import { actionsReducer, setupApiStore } from './helpers'
 
diff --git a/src/query/tests/refetchingBehaviors.test.tsx b/src/query/tests/refetchingBehaviors.test.tsx
index f4a84a4d..50b908a4 100644
--- a/src/query/tests/refetchingBehaviors.test.tsx
+++ b/src/query/tests/refetchingBehaviors.test.tsx
@@ -1,8 +1,8 @@
 import * as React from 'react'
-import { createApi, setupListeners } from '../react'
+import { createApi, setupListeners } from '@reduxjs/toolkit/query/react'
 import { act, fireEvent, render, waitFor, screen } from '@testing-library/react'
 import { setupApiStore, waitMs } from './helpers'
-import { AnyAction } from '../..'
+import { AnyAction } from '@reduxjs/toolkit'
 
 // Just setup a temporary in-memory counter for tests that `getIncrementedAmount`.
 // This can be used to test how many renders happen due to data changes or
diff --git a/src/query/tests/retry.test.ts b/src/query/tests/retry.test.ts
index 920e7799..bc2acf2f 100644
--- a/src/query/tests/retry.test.ts
+++ b/src/query/tests/retry.test.ts
@@ -1,4 +1,4 @@
-import { BaseQueryFn, createApi, retry } from '..'
+import { BaseQueryFn, createApi, retry } from '@reduxjs/toolkit/query'
 import { setupApiStore, waitMs } from './helpers'
 
 beforeEach(() => {
diff --git a/src/query/tests/tsconfig.json b/src/query/tests/tsconfig.json
new file mode 100644
index 00000000..105334e2
--- /dev/null
+++ b/src/query/tests/tsconfig.json
@@ -0,0 +1,3 @@
+{
+  "extends": "../../../tsconfig.test.json"
+}
diff --git a/src/query/tests/unionTypes.test.ts b/src/query/tests/unionTypes.test.ts
index 39cb88f4..95d4692e 100644
--- a/src/query/tests/unionTypes.test.ts
+++ b/src/query/tests/unionTypes.test.ts
@@ -1,5 +1,9 @@
-import { SerializedError } from '../..'
-import { createApi, fetchBaseQuery, FetchBaseQueryError } from '../react'
+import { SerializedError } from '@reduxjs/toolkit'
+import {
+  createApi,
+  fetchBaseQuery,
+  FetchBaseQueryError,
+} from '@reduxjs/toolkit/query/react'
 import { expectExactType, expectType } from './helpers'
 
 const api = createApi({
diff --git a/src/query/tests/utils.test.ts b/src/query/tests/utils.test.ts
index 89011d7b..4b111b2a 100644
--- a/src/query/tests/utils.test.ts
+++ b/src/query/tests/utils.test.ts
@@ -1,4 +1,9 @@
-import { isOnline, isDocumentVisible, flatten, joinUrls } from '../utils'
+import {
+  isOnline,
+  isDocumentVisible,
+  flatten,
+  joinUrls,
+} from '@internal/query/utils'
 
 afterAll(() => {
   jest.restoreAllMocks()
diff --git a/type-tests/files/MiddlewareArray.typetest.ts b/src/tests/MiddlewareArray.typetest.ts
similarity index 100%
rename from type-tests/files/MiddlewareArray.typetest.ts
rename to src/tests/MiddlewareArray.typetest.ts
diff --git a/src/tests/combinedTest.test.ts b/src/tests/combinedTest.test.ts
index 6b95423c..b210cbb3 100644
--- a/src/tests/combinedTest.test.ts
+++ b/src/tests/combinedTest.test.ts
@@ -1,10 +1,13 @@
-import { createAsyncThunk } from '../createAsyncThunk'
-import { createAction, PayloadAction } from '../createAction'
-import { createSlice } from '../createSlice'
-import { configureStore } from '../configureStore'
-import { createEntityAdapter } from '../entities/create_adapter'
-import { EntityAdapter } from '../entities/models'
-import { BookModel } from '../entities/tests/fixtures/book'
+import {
+  createAsyncThunk,
+  createAction,
+  PayloadAction,
+  createSlice,
+  configureStore,
+  createEntityAdapter,
+} from '@reduxjs/toolkit'
+import { EntityAdapter } from '@internal/entities/models'
+import { BookModel } from '@internal/entities/tests/fixtures/book'
 
 describe('Combined entity slice', () => {
   let adapter: EntityAdapter<BookModel>
diff --git a/src/tests/configureStore.test.ts b/src/tests/configureStore.test.ts
index ed1fca7a..15d18416 100644
--- a/src/tests/configureStore.test.ts
+++ b/src/tests/configureStore.test.ts
@@ -1,14 +1,18 @@
-import { configureStore } from '../configureStore'
+import {
+  configureStore,
+  StoreEnhancer,
+  StoreEnhancerStoreCreator,
+} from '@reduxjs/toolkit'
+import * as RTK from '@reduxjs/toolkit'
 import * as redux from 'redux'
-import * as devtools from '../devtoolsExtension'
-import { StoreEnhancer, StoreEnhancerStoreCreator } from 'redux'
+import * as devtools from '@internal/devtoolsExtension'
 
 describe('configureStore', () => {
   jest.spyOn(redux, 'applyMiddleware')
   jest.spyOn(redux, 'combineReducers')
   jest.spyOn(redux, 'compose')
   jest.spyOn(redux, 'createStore')
-  jest.spyOn(devtools, 'composeWithDevTools')
+  jest.spyOn(devtools, 'composeWithDevTools') // @remap-prod-remove-line
 
   const reducer: redux.Reducer = (state = {}, _action) => state
 
@@ -19,7 +23,7 @@ describe('configureStore', () => {
       configureStore({ reducer })
       expect(configureStore({ reducer })).toBeInstanceOf(Object)
       expect(redux.applyMiddleware).toHaveBeenCalled()
-      expect(devtools.composeWithDevTools).toHaveBeenCalled()
+      expect(devtools.composeWithDevTools).toHaveBeenCalled() // @remap-prod-remove-line
       expect(redux.createStore).toHaveBeenCalledWith(
         reducer,
         undefined,
@@ -38,7 +42,7 @@ describe('configureStore', () => {
       expect(configureStore({ reducer })).toBeInstanceOf(Object)
       expect(redux.combineReducers).toHaveBeenCalledWith(reducer)
       expect(redux.applyMiddleware).toHaveBeenCalled()
-      expect(devtools.composeWithDevTools).toHaveBeenCalled()
+      expect(devtools.composeWithDevTools).toHaveBeenCalled() // @remap-prod-remove-line-line
       expect(redux.createStore).toHaveBeenCalledWith(
         expect.any(Function),
         undefined,
@@ -59,7 +63,7 @@ describe('configureStore', () => {
     it('calls createStore without any middleware', () => {
       expect(configureStore({ middleware: [], reducer })).toBeInstanceOf(Object)
       expect(redux.applyMiddleware).toHaveBeenCalledWith()
-      expect(devtools.composeWithDevTools).toHaveBeenCalled()
+      expect(devtools.composeWithDevTools).toHaveBeenCalled() // @remap-prod-remove-line-line
       expect(redux.createStore).toHaveBeenCalledWith(
         reducer,
         undefined,
@@ -78,7 +82,7 @@ describe('configureStore', () => {
         expect.any(Function), // immutableCheck
         expect.any(Function) // serializableCheck
       )
-      expect(devtools.composeWithDevTools).toHaveBeenCalled()
+      expect(devtools.composeWithDevTools).toHaveBeenCalled() // @remap-prod-remove-line-line
       expect(redux.createStore).toHaveBeenCalledWith(
         reducer,
         undefined,
@@ -123,7 +127,7 @@ describe('configureStore', () => {
         Object
       )
       expect(redux.applyMiddleware).toHaveBeenCalledWith(thank)
-      expect(devtools.composeWithDevTools).toHaveBeenCalled()
+      expect(devtools.composeWithDevTools).toHaveBeenCalled() // @remap-prod-remove-line-line
       expect(redux.createStore).toHaveBeenCalledWith(
         reducer,
         undefined,
@@ -177,7 +181,7 @@ describe('configureStore', () => {
         Object
       )
       expect(redux.applyMiddleware).toHaveBeenCalled()
-      expect(devtools.composeWithDevTools).toHaveBeenCalledWith(options)
+      expect(devtools.composeWithDevTools).toHaveBeenCalledWith(options) // @remap-prod-remove-line
       expect(redux.createStore).toHaveBeenCalledWith(
         reducer,
         undefined,
@@ -190,7 +194,7 @@ describe('configureStore', () => {
     it('calls createStore with preloadedState', () => {
       expect(configureStore({ reducer })).toBeInstanceOf(Object)
       expect(redux.applyMiddleware).toHaveBeenCalled()
-      expect(devtools.composeWithDevTools).toHaveBeenCalled()
+      expect(devtools.composeWithDevTools).toHaveBeenCalled() // @remap-prod-remove-line
       expect(redux.createStore).toHaveBeenCalledWith(
         reducer,
         undefined,
@@ -206,7 +210,7 @@ describe('configureStore', () => {
         Object
       )
       expect(redux.applyMiddleware).toHaveBeenCalled()
-      expect(devtools.composeWithDevTools).toHaveBeenCalled()
+      expect(devtools.composeWithDevTools).toHaveBeenCalled() // @remap-prod-remove-line
       expect(redux.createStore).toHaveBeenCalledWith(
         reducer,
         undefined,
diff --git a/type-tests/files/configureStore.typetest.ts b/src/tests/configureStore.typetest.ts
similarity index 100%
rename from type-tests/files/configureStore.typetest.ts
rename to src/tests/configureStore.typetest.ts
diff --git a/src/tests/createAction.test.ts b/src/tests/createAction.test.ts
index ecd4b42f..b5e8b67b 100644
--- a/src/tests/createAction.test.ts
+++ b/src/tests/createAction.test.ts
@@ -1,4 +1,4 @@
-import { createAction, getType } from '../createAction'
+import { createAction, getType } from '@reduxjs/toolkit'
 
 describe('createAction', () => {
   it('should create an action', () => {
diff --git a/type-tests/files/createAction.typetest.ts b/src/tests/createAction.typetest.ts
similarity index 100%
rename from type-tests/files/createAction.typetest.ts
rename to src/tests/createAction.typetest.ts
diff --git a/src/tests/createAsyncThunk.test.ts b/src/tests/createAsyncThunk.test.ts
index b444b782..8ae9cc9f 100644
--- a/src/tests/createAsyncThunk.test.ts
+++ b/src/tests/createAsyncThunk.test.ts
@@ -1,10 +1,10 @@
 import {
   createAsyncThunk,
-  miniSerializeError,
   unwrapResult,
-} from '../createAsyncThunk'
-import { configureStore } from '../configureStore'
-import { AnyAction } from 'redux'
+  configureStore,
+  AnyAction,
+} from '@reduxjs/toolkit'
+import { miniSerializeError } from '@internal/createAsyncThunk'
 
 import {
   mockConsole,
diff --git a/type-tests/files/createAsyncThunk.typetest.ts b/src/tests/createAsyncThunk.typetest.ts
similarity index 100%
rename from type-tests/files/createAsyncThunk.typetest.ts
rename to src/tests/createAsyncThunk.typetest.ts
diff --git a/src/tests/createDraftSafeSelector.test.ts b/src/tests/createDraftSafeSelector.test.ts
index d4f70fab..1ae52b56 100644
--- a/src/tests/createDraftSafeSelector.test.ts
+++ b/src/tests/createDraftSafeSelector.test.ts
@@ -1,5 +1,4 @@
-import { createSelector } from 'reselect'
-import { createDraftSafeSelector } from '../createDraftSafeSelector'
+import { createDraftSafeSelector, createSelector } from '@reduxjs/toolkit'
 import { produce } from 'immer'
 
 type State = { value: number }
diff --git a/type-tests/files/createEntityAdapter.typetest.ts b/src/tests/createEntityAdapter.typetest.ts
similarity index 100%
rename from type-tests/files/createEntityAdapter.typetest.ts
rename to src/tests/createEntityAdapter.typetest.ts
diff --git a/src/tests/createReducer.test.ts b/src/tests/createReducer.test.ts
index b76b9970..59781c2a 100644
--- a/src/tests/createReducer.test.ts
+++ b/src/tests/createReducer.test.ts
@@ -1,7 +1,13 @@
-import { createReducer, CaseReducer } from '../createReducer'
-import { PayloadAction, createAction } from '../createAction'
-import { createNextState, Draft } from '..'
-import { Reducer, AnyAction } from 'redux'
+import {
+  createReducer,
+  CaseReducer,
+  PayloadAction,
+  createAction,
+  createNextState,
+  Draft,
+  Reducer,
+  AnyAction,
+} from '@reduxjs/toolkit'
 
 interface Todo {
   text: string
diff --git a/type-tests/files/createReducer.typetest.ts b/src/tests/createReducer.typetest.ts
similarity index 100%
rename from type-tests/files/createReducer.typetest.ts
rename to src/tests/createReducer.typetest.ts
diff --git a/src/tests/createSlice.test.ts b/src/tests/createSlice.test.ts
index 1baad4c7..d49a3097 100644
--- a/src/tests/createSlice.test.ts
+++ b/src/tests/createSlice.test.ts
@@ -1,5 +1,4 @@
-import { createSlice } from '../createSlice'
-import { createAction, PayloadAction } from '../createAction'
+import { createSlice, createAction, PayloadAction } from '@reduxjs/toolkit'
 
 describe('createSlice', () => {
   describe('when slice is undefined', () => {
diff --git a/type-tests/files/createSlice.typetest.ts b/src/tests/createSlice.typetest.ts
similarity index 100%
rename from type-tests/files/createSlice.typetest.ts
rename to src/tests/createSlice.typetest.ts
diff --git a/src/tests/getDefaultMiddleware.test.ts b/src/tests/getDefaultMiddleware.test.ts
index ca7078f4..2c94ad9c 100644
--- a/src/tests/getDefaultMiddleware.test.ts
+++ b/src/tests/getDefaultMiddleware.test.ts
@@ -1,6 +1,12 @@
-import { AnyAction, Middleware } from 'redux'
-import { getDefaultMiddleware, MiddlewareArray, configureStore } from '..'
-import thunk, { ThunkAction } from 'redux-thunk'
+import {
+  AnyAction,
+  Middleware,
+  getDefaultMiddleware,
+  MiddlewareArray,
+  configureStore,
+  ThunkAction,
+} from '@reduxjs/toolkit'
+import thunk from 'redux-thunk'
 
 describe('getDefaultMiddleware', () => {
   const ORIGINAL_NODE_ENV = process.env.NODE_ENV
@@ -12,7 +18,7 @@ describe('getDefaultMiddleware', () => {
   it('returns an array with only redux-thunk in production', () => {
     process.env.NODE_ENV = 'production'
 
-    expect(getDefaultMiddleware()).toEqual([thunk])
+    expect(getDefaultMiddleware()).toEqual([thunk]) // @remap-prod-remove-line
   })
 
   it('returns an array with additional middleware in development', () => {
diff --git a/type-tests/files/helpers.ts b/src/tests/helpers.ts
similarity index 100%
rename from type-tests/files/helpers.ts
rename to src/tests/helpers.ts
diff --git a/src/tests/immutableStateInvariantMiddleware.test.ts b/src/tests/immutableStateInvariantMiddleware.test.ts
index 080d25f7..a163ab43 100644
--- a/src/tests/immutableStateInvariantMiddleware.test.ts
+++ b/src/tests/immutableStateInvariantMiddleware.test.ts
@@ -1,10 +1,13 @@
-import { Store, MiddlewareAPI, Dispatch } from 'redux'
 import {
+  Store,
+  MiddlewareAPI,
+  Dispatch,
   createImmutableStateInvariantMiddleware,
   isImmutableDefault,
-  trackForMutations,
   ImmutableStateInvariantMiddlewareOptions,
-} from '../immutableStateInvariantMiddleware'
+} from '@reduxjs/toolkit'
+
+import { trackForMutations } from '@internal/immutableStateInvariantMiddleware'
 import { mockConsole, createConsole, getLog } from 'console-testing-library'
 
 describe('createImmutableStateInvariantMiddleware', () => {
diff --git a/src/tests/isPlainObject.test.ts b/src/tests/isPlainObject.test.ts
index 178ad487..59b04e22 100644
--- a/src/tests/isPlainObject.test.ts
+++ b/src/tests/isPlainObject.test.ts
@@ -1,4 +1,4 @@
-import isPlainObject from '../isPlainObject'
+import { isPlainObject } from '@reduxjs/toolkit'
 import vm from 'vm'
 
 describe('isPlainObject', () => {
diff --git a/type-tests/files/mapBuilders.typetest.ts b/src/tests/mapBuilders.typetest.ts
similarity index 100%
rename from type-tests/files/mapBuilders.typetest.ts
rename to src/tests/mapBuilders.typetest.ts
diff --git a/src/tests/matchers.test.ts b/src/tests/matchers.test.ts
index 7b8b2080..02f2c823 100644
--- a/src/tests/matchers.test.ts
+++ b/src/tests/matchers.test.ts
@@ -6,12 +6,12 @@ import {
   isPending,
   isRejected,
   isRejectedWithValue,
-} from '../matchers'
-import { createAction } from '../createAction'
-import { createAsyncThunk } from '../createAsyncThunk'
-import { createReducer } from '../createReducer'
-import { ThunkAction } from 'redux-thunk'
-import { AnyAction } from 'redux'
+  createAction,
+  createAsyncThunk,
+  createReducer,
+  ThunkAction,
+  AnyAction,
+} from '@reduxjs/toolkit'
 
 const thunk: ThunkAction<any, any, any, AnyAction> = () => {}
 
diff --git a/type-tests/files/matchers.typetest.ts b/src/tests/matchers.typetest.ts
similarity index 100%
rename from type-tests/files/matchers.typetest.ts
rename to src/tests/matchers.typetest.ts
diff --git a/src/tests/serializableStateInvariantMiddleware.test.ts b/src/tests/serializableStateInvariantMiddleware.test.ts
index 7929fbcb..833f5e16 100644
--- a/src/tests/serializableStateInvariantMiddleware.test.ts
+++ b/src/tests/serializableStateInvariantMiddleware.test.ts
@@ -1,16 +1,15 @@
-import { Reducer } from 'redux'
 import {
   mockConsole,
   createConsole,
   getLog,
 } from 'console-testing-library/pure'
-import { configureStore } from '../configureStore'
-
 import {
+  Reducer,
+  configureStore,
   createSerializableStateInvariantMiddleware,
   findNonSerializableValue,
   isPlain,
-} from '../serializableStateInvariantMiddleware'
+} from '@reduxjs/toolkit'
 
 // Mocking console
 let restore = () => {}
diff --git a/src/tests/tsconfig.json b/src/tests/tsconfig.json
new file mode 100644
index 00000000..36781645
--- /dev/null
+++ b/src/tests/tsconfig.json
@@ -0,0 +1,3 @@
+{
+  "extends": "../../tsconfig.test.json"
+}
diff --git a/tsconfig.test.json b/tsconfig.test.json
index eaf0c45d..62e6ee81 100644
--- a/tsconfig.test.json
+++ b/tsconfig.test.json
@@ -5,11 +5,13 @@
     "esModuleInterop": true,
     "module": "esnext",
     "moduleResolution": "node",
+    "emitDeclarationOnly": false,
     "strict": true,
     "noEmit": true,
     "target": "es2018",
     "jsx": "react",
     "baseUrl": ".",
-    "skipLibCheck": true
+    "skipLibCheck": true,
+    "noImplicitReturns": false
   }
 }
diff --git a/type-tests/files/tsconfig.json b/type-tests/files/tsconfig.json
deleted file mode 100644
index b0a5d437..00000000
--- a/type-tests/files/tsconfig.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
-  "compilerOptions": {
-    "allowSyntheticDefaultImports": true,
-    "esModuleInterop": true,
-    "module": "es2015",
-    "moduleResolution": "node",
-    "strict": true,
-    "noEmit": true,
-    "target": "es2018",
-    "baseUrl": "../..",
-    "paths": {
-      "@reduxjs/toolkit": ["./src"],
-      "@internal/*": ["./src/*"]
-    }
-  }
-}
diff --git a/type-tests/lib.ts b/type-tests/lib.ts
deleted file mode 100644
index 0128e2bd..00000000
--- a/type-tests/lib.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { check } from 'typings-tester'
-import { versionMajorMinor, sys, findConfigFile } from 'typescript'
-
-export const tsVersion = Number.parseFloat(versionMajorMinor)
-
-export const testIf = (condition: boolean) => (condition ? test : test.skip)
-
-export function checkDirectory(path: string, bail: boolean = false, depth = 1) {
-  const files = sys.readDirectory(path, ['.ts', '.tsx'], [], [], depth)
-  const tsConfigPath = findConfigFile(path, sys.fileExists)
-
-  if (!tsConfigPath) {
-    throw new Error(`Cannot find TypeScript config file in ${path}.`)
-  }
-
-  check(files, tsConfigPath, bail)
-}
-
-export function checkFile(path: string, bail: boolean = false, depth = 1) {
-  const tsConfigPath = findConfigFile(path, sys.fileExists)
-
-  if (!tsConfigPath) {
-    throw new Error(`Cannot find TypeScript config file in ${path}.`)
-  }
-
-  check([path], tsConfigPath, bail)
-}
diff --git a/type-tests/types.test.disabled.ts b/type-tests/types.test.disabled.ts
deleted file mode 100644
index 846d683c..00000000
--- a/type-tests/types.test.disabled.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { checkDirectory } from './lib'
-
-test('Types', () => {
-  checkDirectory(`${__dirname}/files`)
-})