Skip to content

Commit

Permalink
fix(router-link): add missing prop custom in jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jul 3, 2020
1 parent 4efe1b8 commit c6274ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/RouterLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ import { routerKey, routeLocationKey } from './injectionSymbols'
import { RouteRecord } from './matcher/types'
import { assign } from './utils'

export interface RouterLinkProps {
export interface RouterLinkOptions {
to: RouteLocationRaw
// TODO: refactor using extra options allowed in router.push. Needs RFC
replace?: boolean
}

type UseLinkOptions = VueUseOptions<RouterLinkProps>
export interface RouterLinkProps extends RouterLinkOptions {
custom?: boolean
}

type UseLinkOptions = VueUseOptions<RouterLinkOptions>

// TODO: we could allow currentRoute as a prop to expose `isActive` and
// `isExactActive` behavior should go through an RFC
Expand Down
2 changes: 1 addition & 1 deletion src/history/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export interface RouterHistory {
/**
* Generates the corresponding href to be used in an anchor tag.
*
* @param location
* @param location - history location that should create an href
*/
createHref(location: HistoryLocationNormalized): string

Expand Down
3 changes: 3 additions & 0 deletions test-dts/components.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ let router = createRouter({

// RouterLink
expectError(<RouterLink />)
expectError(<RouterLink to="/" custom="text" />)
expectError(<RouterLink to="/" replace="text" />)
expectType<JSX.Element>(<RouterLink to="/foo" replace />)
expectType<JSX.Element>(<RouterLink to="/foo" />)
expectType<JSX.Element>(<RouterLink to={{ path: '/foo' }} />)
expectType<JSX.Element>(<RouterLink to={{ path: '/foo' }} custom />)

// RouterView
expectType<JSX.Element>(<RouterView />)
Expand Down

0 comments on commit c6274ae

Please sign in to comment.