Skip to content

Commit a91cb09

Browse files
committed
fix: Fix type-safety of the Link component
1 parent f7d4992 commit a91cb09

File tree

2 files changed

+35
-21
lines changed

2 files changed

+35
-21
lines changed

src/runtime/components/elements/Button.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,24 @@ import buildAppConfig from "#build/app.config";
1616

1717
type ParentLinkProps = InstanceType<typeof UiLink>["$props"];
1818
type ButtonUiConfig = Partial<UiButtonConfig>;
19+
type Props = ParentLinkProps & {
20+
label?: string;
21+
leadingIcon?: string;
22+
trailingIcon?: string;
23+
type?: HTMLButtonElement["type"];
24+
loading?: boolean;
25+
disabled?: boolean;
26+
truncate?: boolean;
27+
block?: boolean;
28+
padded?: boolean;
29+
size?: UiButtonSizes;
30+
color?: UiButtonColors;
31+
variant?: UiButtonVariants;
32+
loadingIcon?: string;
33+
ui?: ButtonUiConfig;
34+
};
1935

20-
export default defineComponent<
21-
ParentLinkProps & {
22-
label?: string;
23-
leadingIcon?: string;
24-
trailingIcon?: string;
25-
type?: HTMLButtonElement["type"];
26-
loading?: boolean;
27-
disabled?: boolean;
28-
truncate?: boolean;
29-
block?: boolean;
30-
padded?: boolean;
31-
size?: UiButtonSizes;
32-
color?: UiButtonColors;
33-
variant?: UiButtonVariants;
34-
loadingIcon?: string;
35-
ui?: ButtonUiConfig;
36-
}
37-
>({
36+
export default defineComponent<Props>({
3837
components: { UiLink, UiIcon },
3938

4039
props: {

src/runtime/components/elements/Link.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
import { NuxtLink } from "#components";
22
import { useRoute } from "#imports";
33
import { defineComponent, h, type PropType } from "vue";
4-
import type { RouteLocationNormalized } from "vue-router";
4+
import type { RouteLocationNormalized, RouteLocationRaw } from "vue-router";
55
import { classNames, isDeepEqual } from "../../utils";
66

7-
type NuxtLinkProps = InstanceType<typeof NuxtLink>["$props"];
8-
type Props = NuxtLinkProps & {
7+
type Props = {
8+
// NuxtLink props
9+
to?: RouteLocationRaw;
10+
href?: RouteLocationRaw;
11+
external?: boolean;
12+
replace?: boolean;
13+
custom?: boolean;
14+
target?: "_blank" | "_parent" | "_self" | "_top" | (string & {}) | null;
15+
rel?: string | null;
16+
noRel?: boolean;
17+
prefetch?: boolean;
18+
noPrefetch?: boolean;
19+
activeClass?: string;
20+
exactActiveClass?: string;
21+
ariaCurrentValue?: string;
22+
23+
// UiLink props
924
type?: HTMLButtonElement["type"];
1025
disabled?: boolean;
1126
exact?: boolean;

0 commit comments

Comments
 (0)