Skip to content

Commit

Permalink
fix(types): add HTML attributes for JSX
Browse files Browse the repository at this point in the history
Close #435
  • Loading branch information
posva committed Aug 23, 2020
1 parent 62aa300 commit 06f3f8f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/RouterLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
reactive,
unref,
VNodeProps,
HTMLAttributes,
} from 'vue'
import { RouteLocationRaw, VueUseOptions, RouteLocation } from './types'
import { isSameRouteLocationParams, isSameRouteRecord } from './location'
Expand Down Expand Up @@ -186,7 +187,7 @@ export const RouterLinkImpl = defineComponent({
// also to avoid inline import() in generated d.ts files
export const RouterLink = (RouterLinkImpl as any) as {
new (): {
$props: VNodeProps & RouterLinkProps
$props: HTMLAttributes & VNodeProps & RouterLinkProps
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/RouterView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
VNodeProps,
getCurrentInstance,
computed,
HTMLAttributes,
} from 'vue'
import { RouteLocationNormalized, RouteLocationNormalizedLoaded } from './types'
import {
Expand Down Expand Up @@ -108,7 +109,7 @@ export const RouterViewImpl = defineComponent({
// also to avoid inline import() in generated d.ts files
export const RouterView = (RouterViewImpl as any) as {
new (): {
$props: VNodeProps & RouterViewProps
$props: HTMLAttributes & VNodeProps & RouterViewProps
}
}

Expand Down
3 changes: 2 additions & 1 deletion test-dts/components.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ 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 class="link" to="/foo" />)
expectType<JSX.Element>(<RouterLink to={{ path: '/foo' }} />)
expectType<JSX.Element>(<RouterLink to={{ path: '/foo' }} custom />)

// RouterView
expectType<JSX.Element>(<RouterView />)
expectType<JSX.Element>(<RouterView class="view" />)
expectType<JSX.Element>(<RouterView name="foo" />)
expectType<JSX.Element>(<RouterView route={router.currentRoute.value} />)

0 comments on commit 06f3f8f

Please sign in to comment.