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

feat(warn): throws if history is missing #844

Merged
merged 3 commits into from Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions __tests__/router.spec.ts
Expand Up @@ -93,6 +93,11 @@ describe('Router', () => {
createDom()
})

it('fails if history option is missing', () => {
// @ts-ignore
expect(() => createRouter({ routes })).toThrow()
posva marked this conversation as resolved.
Show resolved Hide resolved
})

it('starts at START_LOCATION', () => {
const history = createMemoryHistory()
const router = createRouter({ history, routes })
Expand Down
5 changes: 5 additions & 0 deletions src/router.ts
Expand Up @@ -343,6 +343,11 @@ export function createRouter(options: RouterOptions): Router {
let parseQuery = options.parseQuery || originalParseQuery
let stringifyQuery = options.stringifyQuery || originalStringifyQuery
let routerHistory = options.history
if (__DEV__ && !routerHistory)
throw new Error(
'Missing required history option of RouterOptions.\n' +
'See more at https://next.router.vuejs.org/api/#createrouter'
posva marked this conversation as resolved.
Show resolved Hide resolved
)

const beforeGuards = useCallbacks<NavigationGuardWithThis<undefined>>()
const beforeResolveGuards = useCallbacks<NavigationGuardWithThis<undefined>>()
Expand Down