Skip to content

Commit 328cf16

Browse files
committed
fix: remove reach/router dep if not needed
1 parent 9e221fd commit 328cf16

File tree

5 files changed

+48
-8
lines changed

5 files changed

+48
-8
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redux-first-history",
3-
"version": "5.0.9",
3+
"version": "5.0.10",
44
"description": "Redux First History - Redux history binding support react-router - @reach/router - wouter",
55
"main": "build/es5/index.js",
66
"module": "build/es6/index.js",
@@ -50,7 +50,7 @@
5050
"@testing-library/react": "^12.1.0",
5151
"@types/history": "^4.7.9",
5252
"@types/jest": "^27.0.2",
53-
"@types/reach__router": "^1.3.9",
53+
"@types/reach__router": "^1.3.10",
5454
"@types/react": "^17.0.24",
5555
"@typescript-eslint/eslint-plugin": "^4.31.2",
5656
"@typescript-eslint/parser": "^4.31.2",

src/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { History, Location } from 'history';
2-
import type { History as ReachHistory } from '@reach/router';
32
import type { Middleware, Reducer, Store } from 'redux';
3+
import type { ReachHistory } from './reachify.types';
44
import {
55
go,
66
goBack,

src/reachify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// eslint-disable-next-line import/no-unresolved
2-
import { History as ReachHistory } from '@reach/router';
32
import { History } from 'history';
3+
import { ReachHistory } from './reachify.types';
44

55
export const reachify = (reduxHistory: History & { listenObject: boolean }): ReachHistory => {
66
let transitioning = false;

src/reachify.types.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/reach__router/index.d.ts
2+
/**
3+
* cloning reach router types so the packages does not depends on reach/router types if not used.
4+
* to be removed in v6 and deprecate reach-router
5+
*/
6+
7+
interface HLocation<S = unknown> {
8+
pathname: string;
9+
search: string;
10+
state: S;
11+
hash: string;
12+
key?: string | undefined;
13+
}
14+
type WindowLocation<S = unknown> = Window['location'] & HLocation<S>;
15+
16+
type HistoryActionType = 'PUSH' | 'POP';
17+
type HistoryLocation = WindowLocation & { state?: any };
18+
interface HistoryListenerParameter {
19+
location: HistoryLocation;
20+
action: HistoryActionType;
21+
}
22+
type HistoryListener = (parameter: HistoryListenerParameter) => void;
23+
type HistoryUnsubscribe = () => void;
24+
25+
interface NavigateOptions<TState> {
26+
state?: TState | undefined;
27+
replace?: boolean | undefined;
28+
}
29+
interface NavigateFn {
30+
// eslint-disable-next-line @typescript-eslint/ban-types
31+
(to: string, options?: NavigateOptions<{}>): Promise<void>;
32+
(to: number): Promise<void>;
33+
}
34+
35+
export interface ReachHistory {
36+
readonly location: HistoryLocation;
37+
readonly transitioning: boolean;
38+
listen: (listener: HistoryListener) => HistoryUnsubscribe;
39+
navigate: NavigateFn;
40+
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,10 +751,10 @@
751751
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.4.tgz#fcf7205c25dff795ee79af1e30da2c9790808f11"
752752
integrity sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==
753753

754-
"@types/reach__router@^1.3.9":
755-
version "1.3.9"
756-
resolved "https://registry.yarnpkg.com/@types/reach__router/-/reach__router-1.3.9.tgz#d3aaac0072665c81063cc6c557c18dadd642b226"
757-
integrity sha512-N6rqQqTTAV/zKLfK3iq9Ww3wqCEhTZvsilhl0zI09zETdVq1QGmJH6+/xnj8AFUWIrle2Cqo+PGM/Ltr1vBb9w==
754+
"@types/reach__router@^1.3.10":
755+
version "1.3.10"
756+
resolved "https://registry.yarnpkg.com/@types/reach__router/-/reach__router-1.3.10.tgz#141d500213a452d9d9d71d5ad96c4104094f55a3"
757+
integrity sha512-iHAFGaVOrWi00/q7oBybggGsz5TOmwOW4M1H9sT7i9lly4qFC8XOgsdf6jUsoaOz2sknFHALEtZqCoDbokdJ2Q==
758758
dependencies:
759759
"@types/react" "*"
760760

0 commit comments

Comments
 (0)