mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
rename createBrowserHistory to createHistory
`createBrowserHistory ` was only introduced in the `history@4.0.0-1` prior to that the `createHistory` was used. So if you will install `@types/history@^2.0.0` and `history@^2.0.0`(or even `^3.x.x`) it will break with the next error: ``` ./src/client/history.ts (1,10): error TS2305: Module ‘”/@types/history/index"' has no exported member 'createHistory'. ``` This commit brings the `createHistory` back thus solves the issue for `history@^2.x.x` and `history@^3.x.x`.
This commit is contained in:
parent
d7ee5b897b
commit
ef8a64d27c
@ -1,4 +1,4 @@
|
||||
import { createBrowserHistory, createLocation, useBasename, useBeforeUnload, useQueries } from 'history'
|
||||
import { createHistory, createLocation, useBasename, useBeforeUnload, useQueries } from 'history'
|
||||
|
||||
import { getUserConfirmation } from 'history/lib/DOMUtils'
|
||||
|
||||
@ -10,7 +10,7 @@ let doSomethingAsync: () => Promise<Function>;
|
||||
let input = { value: "" };
|
||||
|
||||
{
|
||||
let history = createBrowserHistory()
|
||||
let history = createHistory()
|
||||
|
||||
// Listen for changes to the current location. The
|
||||
// listener is called once immediately.
|
||||
@ -46,7 +46,7 @@ let input = { value: "" };
|
||||
}
|
||||
|
||||
{
|
||||
let history = createBrowserHistory()
|
||||
let history = createHistory()
|
||||
|
||||
// Pushing a path string.
|
||||
history.push('/the/path')
|
||||
@ -63,7 +63,7 @@ let input = { value: "" };
|
||||
}
|
||||
|
||||
{
|
||||
let history = createBrowserHistory()
|
||||
let history = createHistory()
|
||||
history.listenBefore(function(location) {
|
||||
if (input.value !== '')
|
||||
return 'Are you sure you want to leave this page?'
|
||||
@ -75,7 +75,7 @@ let input = { value: "" };
|
||||
}
|
||||
|
||||
{
|
||||
let history = createBrowserHistory({
|
||||
let history = createHistory({
|
||||
getUserConfirmation(message, callback) {
|
||||
callback(window.confirm(message)) // The default behavior
|
||||
}
|
||||
@ -83,7 +83,7 @@ let input = { value: "" };
|
||||
}
|
||||
|
||||
{
|
||||
let history = useBeforeUnload(createBrowserHistory)()
|
||||
let history = useBeforeUnload(createHistory)()
|
||||
|
||||
history.listenBeforeUnload(function() {
|
||||
return 'Are you sure you want to leave this page?'
|
||||
@ -91,7 +91,7 @@ let input = { value: "" };
|
||||
}
|
||||
|
||||
{
|
||||
let history = useQueries(createBrowserHistory)()
|
||||
let history = useQueries(createHistory)()
|
||||
|
||||
history.listen(function(location) {
|
||||
console.log(location.query)
|
||||
@ -99,7 +99,7 @@ let input = { value: "" };
|
||||
}
|
||||
|
||||
{
|
||||
let history = useQueries(createBrowserHistory)({
|
||||
let history = useQueries(createHistory)({
|
||||
parseQueryString: function(queryString) {
|
||||
// TODO: return a parsed version of queryString
|
||||
return {};
|
||||
@ -116,7 +116,7 @@ let input = { value: "" };
|
||||
|
||||
{
|
||||
// Run our app under the /base URL.
|
||||
let history = useBasename(createBrowserHistory)({
|
||||
let history = useBasename(createHistory)({
|
||||
basename: '/base'
|
||||
})
|
||||
|
||||
@ -128,4 +128,4 @@ let input = { value: "" };
|
||||
|
||||
history.createPath('/the/path') // /base/the/path
|
||||
history.push('/the/path') // push /base/the/path
|
||||
}
|
||||
}
|
||||
|
||||
2
history/v2/index.d.ts
vendored
2
history/v2/index.d.ts
vendored
@ -127,7 +127,7 @@ export interface Module {
|
||||
};
|
||||
}
|
||||
|
||||
export { default as createBrowserHistory } from "./lib/createBrowserHistory";
|
||||
export { default as createHistory } from "./lib/createBrowserHistory";
|
||||
export { default as createHashHistory } from "./lib/createHashHistory";
|
||||
export { default as createMemoryHistory } from "./lib/createMemoryHistory";
|
||||
export { default as createLocation } from "./lib/createLocation";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user