Skip to content

feat: add constructor hint #3626

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

Merged
merged 1 commit into from
Oct 3, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/history/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ export class History {
cb(err)
})
} else {
warn(false, 'uncaught error during route navigation:')
if (process.env.NODE_ENV !== 'production') {
warn(false, 'uncaught error during route navigation:')
}
console.error(err)
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export default class VueRouter {
afterHooks: Array<?AfterNavigationHook>

constructor (options: RouterOptions = {}) {
if (process.env.NODE_ENV !== 'production') {
warn(this instanceof VueRouter, `Router must be called with the new operator.`)
}
this.app = null
this.apps = []
this.options = options
Expand Down
2 changes: 1 addition & 1 deletion src/util/warn.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function assert (condition: any, message: string) {
}

export function warn (condition: any, message: string) {
if (process.env.NODE_ENV !== 'production' && !condition) {
if (!condition) {
typeof console !== 'undefined' && console.warn(`[vue-router] ${message}`)
}
}
Expand Down