Skip to content

Commit 23c37fb

Browse files
committed
prettier + internal type fixes
1 parent f042c81 commit 23c37fb

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

packages/history/index.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,11 @@ export interface MemoryHistory<S extends State = State> extends History<S> {
312312
index: number;
313313
}
314314

315-
const readOnly: <T extends unknown>(obj: T) => T = __DEV__
316-
? obj => Object.freeze(obj)
317-
: obj => obj;
315+
const readOnly: <T>(obj: T) => Readonly<T> = __DEV__
316+
? (obj) => Object.freeze(obj)
317+
: (obj) => obj;
318318

319-
function warning(cond: boolean, message: string) {
319+
function warning(cond: any, message: string) {
320320
if (!cond) {
321321
// eslint-disable-next-line no-console
322322
if (typeof console !== 'undefined') console.warn(message);
@@ -545,7 +545,7 @@ export function createBrowserHistory(
545545
window.addEventListener(BeforeUnloadEventType, promptBeforeUnload);
546546
}
547547

548-
return function() {
548+
return function () {
549549
unblock();
550550

551551
// Remove the beforeunload listener so the document may
@@ -582,9 +582,11 @@ export function createHashHistory(
582582
let globalHistory = window.history;
583583

584584
function getIndexAndLocation(): [number, Location] {
585-
let { pathname = '/', search = '', hash = '' } = parsePath(
586-
window.location.hash.substr(1)
587-
);
585+
let {
586+
pathname = '/',
587+
search = '',
588+
hash = ''
589+
} = parsePath(window.location.hash.substr(1));
588590
let state = globalHistory.state || {};
589591
return [
590592
state.idx,
@@ -804,7 +806,7 @@ export function createHashHistory(
804806
window.addEventListener(BeforeUnloadEventType, promptBeforeUnload);
805807
}
806808

807-
return function() {
809+
return function () {
808810
unblock();
809811

810812
// Remove the beforeunload listener so the document may
@@ -845,7 +847,7 @@ export function createMemoryHistory(
845847
options: MemoryHistoryOptions = {}
846848
): MemoryHistory {
847849
let { initialEntries = ['/'], initialIndex } = options;
848-
let entries: Location[] = initialEntries.map(entry => {
850+
let entries: Location[] = initialEntries.map((entry) => {
849851
let location = readOnly<Location>({
850852
pathname: '/',
851853
search: '',
@@ -1016,20 +1018,18 @@ function createEvents<F extends Function>(): Events<F> {
10161018
},
10171019
push(fn: F) {
10181020
handlers.push(fn);
1019-
return function() {
1020-
handlers = handlers.filter(handler => handler !== fn);
1021+
return function () {
1022+
handlers = handlers.filter((handler) => handler !== fn);
10211023
};
10221024
},
10231025
call(arg) {
1024-
handlers.forEach(fn => fn && fn(arg));
1026+
handlers.forEach((fn) => fn && fn(arg));
10251027
}
10261028
};
10271029
}
10281030

10291031
function createKey() {
1030-
return Math.random()
1031-
.toString(36)
1032-
.substr(2, 8);
1032+
return Math.random().toString(36).substr(2, 8);
10331033
}
10341034

10351035
/**

0 commit comments

Comments
 (0)