Skip to content

Commit

Permalink
Move declarations files to their own folder, and introduce type overr…
Browse files Browse the repository at this point in the history
…ides for react-router-redux, which imports old and incompatible redux types

In future we should consider whether we need this module, and if so migrate to https://github.com/supasate/connected-react-router
  • Loading branch information
jonathonherbert committed Mar 1, 2024
1 parent 606e420 commit 7fd21a4
Show file tree
Hide file tree
Showing 6 changed files with 2,297 additions and 2,383 deletions.
9 changes: 4 additions & 5 deletions fronts-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@
"@testing-library/jest-dom": "^5.16.5",
"@types/fetch-mock": "^6.0.4",
"@types/jest": "^29.5.1",
"@types/react": "^16.14.40",
"@types/react": "16.14.40",
"@types/react-dom": "^16.8.4",
"@types/react-modal": "^3.6.0",
"@types/react-redux": "^7.1.25",
"@types/react-router-dom": "4.2.2",
"@types/react-router-redux": "^5.0.16",
"@types/react-transition-group": "^2.0.16",
"@types/redux-form": "^8.3.5",
"@types/redux-mock-store": "^1.0.0",
"@types/sanitize-html": "^2.0.0",
"@types/styled-components": "^5.1.26",
"@types/styled-components": "5.1.32",
"@types/webpack-env": "^1.13.6",
"babel-core": "^7.0.0-0",
"babel-jest": "^29.5.0",
Expand Down Expand Up @@ -97,7 +96,7 @@
"downshift": "^3.1.7",
"fetch": "^1.1.0",
"grid-util-js": "^1.1.0",
"history": "4.7.2",
"history": "^5.3.0",
"lodash": "^4.17.21",
"lodash.throttle": "^4.1.1",
"moment": "^2.29.4",
Expand Down Expand Up @@ -138,7 +137,7 @@
"resize-observer-polyfill": "^1.5.1",
"sanitize-html": "^2.10.0",
"shallowequal": "^1.1.0",
"styled-components": "^5.3.10",
"styled-components": "5.3.11",
"ts-optchain": "^0.1.2",
"tti-polyfill": "^0.2.2",
"uuid": "^3.2.1"
Expand Down
File renamed without changes.
132 changes: 132 additions & 0 deletions fronts-client/src/declarations/modules.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
declare module '*.svg' {
const content: any;
export default content;
}

declare module '*.gif' {
const content: any;
export default content;
}

declare module '*.woff' {
const content: any;
export default content;
}

declare module '*.ttf' {
const content: any;
export default content;
}

declare module '*.woff2' {
const content: any;
export default content;
}

declare module 'grid-util-js' {
const content: any;
export default content;
}

declare module 'panda-session' {
const content: any;
export const reEstablishSession: any;
export default content;
}

declare module 'normalise-with-fields' {
export const createType: any;
export const build: any;
export const createFieldType: any;
}

declare module 'tti-polyfill' {
const content: any;
export default content;
}

// Added as @types/react-router-redux imports an older, incompatible version of redux types.
declare module 'react-router-redux' {
import {
History,
Location,
LocationDescriptor,
LocationState,
Path,
} from 'history';
import * as React from 'react';
import { match } from 'react-router';
import { Action, Dispatch, Middleware, Reducer, Store } from 'redux';
export interface ConnectedRouterProps<State> {
children?: React.ReactNode;
store?: Store<State> | undefined;
history: History;
}
export class ConnectedRouter<State> extends React.Component<
ConnectedRouterProps<State>
> {}

export const LOCATION_CHANGE = '@@router/LOCATION_CHANGE';

export interface RouterState {
location: Location | null;
}

export const routerReducer: Reducer<RouterState, Action>;

export const CALL_HISTORY_METHOD = '@@router/CALL_HISTORY_METHOD';

export function push(
location: LocationDescriptor,
state?: LocationState
): RouterAction;
export function replace(
location: LocationDescriptor,
state?: LocationState
): RouterAction;
export function go(n: number): RouterAction;
export function goBack(): RouterAction;
export function goForward(): RouterAction;

export const routerActions: {
push: typeof push;
replace: typeof replace;
go: typeof go;
goBack: typeof goBack;
goForward: typeof goForward;
};

export interface LocationActionPayload {
method: string;
args?: any[] | undefined;
}

export interface RouterAction {
type: typeof CALL_HISTORY_METHOD;
payload: LocationActionPayload;
}

export interface LocationChangeAction {
type: typeof LOCATION_CHANGE;
payload: Location & {
props?:
| {
match: {
path: string;
url: string;
params: any;
isExact: boolean;
};
location: Location;
history: History;
}
| undefined;
};
}

export function routerMiddleware(history: History): Middleware;

export function createMatchSelector(
path: string
): (state: { router: RouterState }) => match | null;
}
File renamed without changes.
46 changes: 0 additions & 46 deletions fronts-client/src/modules.d.ts

This file was deleted.

Loading

0 comments on commit 7fd21a4

Please sign in to comment.