components: { RouterLink },
name: 'AppLink',
- // @ts-ignore
+ // @ts-expect-error
props: {
...((RouterLink as any).props as RouterLinkProps),
inactiveClass: String as PropType<string>,
computed: {
isExternalLink(): boolean {
- // @ts-ignore
+ // @ts-expect-error
return typeof this.to === 'string' && this.to.startsWith('http')
},
},
const NoGuard: RouteRecordRaw = { path: '/', component: components.Home }
const InvalidRoute: RouteRecordRaw = {
path: '/',
- // @ts-ignore: intended error
+ // @ts-expect-error
component: null,
}
const WrongLazyRoute: RouteRecordRaw = {
path: '/',
- // @ts-ignore: intended error
component: Promise.resolve(components.Home),
}
const SingleGuard: RouteRecordRaw = {
})
it('throws if component is null', async () => {
- // @ts-ignore
+ // @ts-expect-error
await expect(checkGuards([InvalidRoute], 2)).rejects.toHaveProperty(
'message',
expect.stringMatching('Invalid route component')
import { mockWarn } from 'jest-mock-warn'
const currentLocation = { path: '/' } as MatcherLocation
-// @ts-ignore
+// @ts-expect-error
const component: RouteComponent = null
describe('Matcher: adding and removing records', () => {
{
score: a,
re: /a/,
- // @ts-ignore
+ // @ts-expect-error
stringify: v => v,
- // @ts-ignore
+ // @ts-expect-error
parse: v => v,
keys: [],
},
{
score: b,
re: /a/,
- // @ts-ignore
stringify: v => v,
- // @ts-ignore
parse: v => v,
keys: [],
}
import { MatcherLocationNormalizedLoose } from '../utils'
import { mockWarn } from 'jest-mock-warn'
-// @ts-ignore
+// @ts-expect-error
const component: RouteComponent = null
// for normalized records
throw new Error('not handled')
} else {
// use one single record
- if (!resolved.matched)
- // @ts-ignore
- resolved.matched = record.map(normalizeRouteRecord)
+ if (!resolved.matched) resolved.matched = record.map(normalizeRouteRecord)
// allow passing an expect.any(Array)
else if (Array.isArray(resolved.matched))
resolved.matched = resolved.matched.map(m => ({
}
for (let key in initialValue) {
- // @ts-ignore
+ // @ts-expect-error
route[key] =
// new line to still get errors here
computed(() => routeRef.value[key as keyof RouteLocationNormalizedLoose])
})
it('fails if history option is missing', () => {
- // @ts-ignore
+ // @ts-expect-error
expect(() => createRouter({ routes })).toThrowError(
'Provide the "history" option'
)
beforeEach(() => {
// mock all encoding functions
for (const key in encoding) {
- // @ts-ignore
+ // @ts-expect-error
const value = encoding[key]
- // @ts-ignore
+ // @ts-expect-error
if (typeof value === 'function') encoding[key] = jest.fn((v: string) => v)
- // @ts-ignore
+ // @ts-expect-error
else if (key === 'PLUS_RE') encoding[key] = /\+/g
}
})
})
it('decodes values in params', async () => {
- // @ts-ignore: override to make the difference
+ // @ts-expect-error: override to make the difference
encoding.decode = () => 'd'
- // @ts-ignore
+ // @ts-expect-error
encoding.encodeParam = () => 'e'
const router = createRouter()
await router.push({ name: 'optional', params: { a: 'a%' } })
})
it('keeps decoded values in query', async () => {
- // @ts-ignore: override to make the difference
+ // @ts-expect-error: override to make the difference
encoding.decode = () => 'd'
- // @ts-ignore
+ // @ts-expect-error
encoding.encodeQueryValue = () => 'ev'
- // @ts-ignore
+ // @ts-expect-error
encoding.encodeQueryKey = () => 'ek'
const router = createRouter()
await router.push({ name: 'home', query: { p: '%' } })
})
it('keeps decoded values in hash', async () => {
- // @ts-ignore: override to make the difference
+ // @ts-expect-error: override to make the difference
encoding.decode = () => 'd'
- // @ts-ignore
+ // @ts-expect-error
encoding.encodeHash = () => '#e'
const router = createRouter()
await router.push({ name: 'home', hash: '#%' })
})
})
it('decodes hash', async () => {
- // @ts-ignore: override to make the difference
+ // @ts-expect-error: override to make the difference
encoding.decode = () => '#d'
- // @ts-ignore
+ // @ts-expect-error
encoding.encodeHash = () => '#e'
const router = createRouter()
await router.push('#%20')
aliasOf: RouteRecordViewLoose | undefined
}
-// @ts-ignore we are intentionally overriding the type
+// @ts-expect-error we are intentionally overriding the type
export interface RouteLocationNormalizedLoose extends RouteLocationNormalized {
name: RouteRecordName | null | undefined
path: string
}
)
- // @ts-ignore: needed for jsdom
+ // @ts-expect-error: needed for jsdom
global.window = dom.window
global.location = dom.window.location
global.history = dom.window.history
state.enter++
logs.value.push(`${key}: enter ${from.path} - ${to.path}`)
next(vm => {
- // @ts-ignore
+ // @ts-expect-error
vm.enterCallback++
})
},
app.use(router)
-// @ts-ignore
window.r = router
app.mount('#app')
app.use(router)
window.vm = app.mount('#app')
-// @ts-ignore
+// @ts-expect-error
window.router = router
beforeRouteEnter(to, from, next) {
next(vm => {
- // @ts-ignore
+ // @ts-expect-error
console.log('enter from ', vm.id)
- // @ts-ignore
})
},
beforeRouteUpdate(to, from, next) {
console.log('update of', i)
- // @ts-ignore
+ // @ts-expect-error
this.count++
next()
},
app.use(router)
-// @ts-ignore
window.r = router
app.mount('#app')
})
}
-// @ts-ignore
+// @ts-expect-error
window._go = go
router.beforeEach((to, from, next) => {
// don't redirect on right click
if (e.button !== undefined && e.button !== 0) return
// don't redirect if `target="_blank"`
- // @ts-ignore getAttribute does exist
+ // @ts-expect-error getAttribute does exist
if (e.currentTarget && e.currentTarget.getAttribute) {
- // @ts-ignore getAttribute exists
+ // @ts-expect-error getAttribute exists
const target = e.currentTarget.getAttribute('target')
if (/\b_blank\b/i.test(target)) return
}
for (let key in obj) {
if (!keys.includes(key as any)) {
- // @ts-ignore
+ // @ts-expect-error
ret[key] = obj[key]
}
}
})
if (__TEST__) {
- // @ts-ignore: only for tests
+ // @ts-expect-error: only for tests
routerHistory.changeURL = function (url: string) {
const from = this.location
queue.splice(position++ + 1, queue.length, url)
}:\n${guard.toString()}\n. If you are returning a value instead of calling "next", make sure to remove the "next" parameter from your function.`
if (typeof guardReturn === 'object' && 'then' in guardReturn) {
guardCall = guardCall.then(resolvedValue => {
- // @ts-ignore: _called is added at canOnlyBeCalledOnce
+ // @ts-expect-error: _called is added at canOnlyBeCalledOnce
if (!next._called) {
warn(message)
return Promise.reject(new Error('Invalid navigation guard'))
})
// TODO: test me!
} else if (guardReturn !== undefined) {
- // @ts-ignore: _called is added at canOnlyBeCalledOnce
+ // @ts-expect-error: _called is added at canOnlyBeCalledOnce
if (!next._called) {
warn(message)
reject(new Error('Invalid navigation guard'))
warn(
`The "next" callback was called more than once in one navigation guard when going from "${from.fullPath}" to "${to.fullPath}". It should be called exactly one time in each navigation guard. This will fail in production.`
)
- // @ts-ignore: we put it in the original one because it's easier to check
+ // @ts-expect-error: we put it in the original one because it's easier to check
next._called = true
if (called === 1) next.apply(null, arguments as any)
}
) &&
// and we have done it a couple of times
redirectedFrom &&
- // @ts-ignore
+ // @ts-expect-error
(redirectedFrom._count = redirectedFrom._count
- ? // @ts-ignore
+ ? // @ts-expect-error
redirectedFrom._count + 1
: 1) > 10
) {
>
}
for (let key in START_LOCATION_NORMALIZED) {
- // @ts-ignore: the key matches
+ // @ts-expect-error: the key matches
reactiveRoute[key] = computed(() => currentRoute.value[key])
}
},
{
path: '/foo',
- // @ts-ignore
+ // @ts-expect-error
component,
// @ts-expect-error
meta: {},