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

[history] Fix partial error #4563

Merged
merged 3 commits into from Jan 16, 2024
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
138 changes: 138 additions & 0 deletions definitions/npm/history_v4.9.x/flow_v0.201.x-/history_v4.9.x.js
@@ -0,0 +1,138 @@
declare module 'history' {
declare function Unblock(): void;

declare export type Action = 'PUSH' | 'REPLACE' | 'POP';

declare export type BrowserLocation = {
pathname: string,
search: string,
hash: string,
// Browser and Memory specific
state: {...},
key: string,
...
};

declare interface IBrowserHistory {
length: number;
location: BrowserLocation;
action: Action;
push(path: string, state?: {...}): void;
push(location: Partial<BrowserLocation>): void;
replace(path: string, state?: {...}): void;
replace(location: Partial<BrowserLocation>): void;
go(n: number): void;
goBack(): void;
goForward(): void;
listen((location: BrowserLocation, action: Action) => void): void;
block(message: string): typeof Unblock;
block(
(location: BrowserLocation, action: Action) => string
): typeof Unblock;
}

declare export type BrowserHistory = IBrowserHistory;

declare type BrowserHistoryOpts = {
basename?: string,
forceRefresh?: boolean,
getUserConfirmation?: (
message: string,
callback: (willContinue: boolean) => void
) => void,
...
};

declare function createBrowserHistory(
opts?: BrowserHistoryOpts
): BrowserHistory;

declare export type MemoryLocation = {
pathname: string,
search: string,
hash: string,
// Browser and Memory specific
state: {...},
key: string,
...
};

declare interface IMemoryHistory {
length: number;
location: MemoryLocation;
action: Action;
index: number;
entries: Array<string>;
push(path: string, state?: {...}): void;
push(location: Partial<MemoryLocation>): void;
replace(path: string, state?: {...}): void;
replace(location: Partial<MemoryLocation>): void;
go(n: number): void;
goBack(): void;
goForward(): void;
// Memory only
canGo(n: number): boolean;
listen((location: MemoryLocation, action: Action) => void): void;
block(message: string): typeof Unblock;
block((location: MemoryLocation, action: Action) => string): typeof Unblock;
}

declare export type MemoryHistory = IMemoryHistory;

declare type MemoryHistoryOpts = {
initialEntries?: Array<string>,
initialIndex?: number,
keyLength?: number,
getUserConfirmation?: (
message: string,
callback: (willContinue: boolean) => void
) => void,
...
};

declare function createMemoryHistory(opts?: MemoryHistoryOpts): MemoryHistory;

declare export type HashLocation = {
pathname: string,
search: string,
hash: string,
...
};

declare interface IHashHistory {
length: number;
location: HashLocation;
action: Action;
push(path: string, state?: {...}): void;
push(location: Partial<HashLocation>): void;
replace(path: string, state?: {...}): void;
replace(location: Partial<HashLocation>): void;
go(n: number): void;
goBack(): void;
goForward(): void;
listen((location: HashLocation, action: Action) => void): void;
block(message: string): typeof Unblock;
block((location: HashLocation, action: Action) => string): typeof Unblock;
push(path: string): void;
}

declare export type HashHistory = IHashHistory;

declare type HashHistoryOpts = {
basename?: string,
hashType: 'slash' | 'noslash' | 'hashbang',
getUserConfirmation?: (
message: string,
callback: (willContinue: boolean) => void
) => void,
...
};

declare function createHashHistory(opts?: HashHistoryOpts): HashHistory;

declare function parsePath(path: string): BrowserLocation | MemoryLocation | HashLocation;

declare function createPath(
path: BrowserLocation | MemoryLocation | HashLocation
): string;
}