Skip to content

Commit

Permalink
vue: Fix component props typing when re-exporting
Browse files Browse the repository at this point in the history
We encountered a bug with vue/ts in our configuration:
If we re-export a vue component, it will be typed to any
if used inside Vue's <template>.
Disabling this typescript rule restores the expected typing.

Github issue link:
vuejs/core#11732

This also uncovered that radix didn't adhere to our typing rules,
we silenced those errors.

CMK-18584

Change-Id: Ieeef6f3d7cadcbfbc0366ee67972e8b7dd9e16c9
  • Loading branch information
cellador committed Sep 3, 2024
1 parent 923a367 commit 86b2de8
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const props = withDefaults(defineProps<Props>(), {
</script>

<template>
<!-- @vue-expect-error Radix-vue props doesn't follow our exactOptionalPropertyTypes rule -->
<Primitive :as="as" :as-child="asChild" :class="props.class">
<slot />
</Primitive>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const props = defineProps<CollapsibleContentProps>()
</script>

<template>
<!-- @vue-expect-error Radix-vue props doesn't follow our exactOptionalPropertyTypes rule -->
<CollapsibleContent v-bind="props" class="ui-collapsible-content">
<slot />
</CollapsibleContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const props = defineProps<CollapsibleTriggerProps>()
</script>

<template>
<!-- @vue-expect-error Radix-vue props doesn't follow our exactOptionalPropertyTypes rule -->
<CollapsibleTrigger v-bind="props">
<slot />
</CollapsibleTrigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const forwarded = useForwardPropsEmits(props, emits)
</script>

<template>
<!-- @vue-expect-error Radix-vue props doesn't follow our exactOptionalPropertyTypes rule -->
<CollapsibleRoot v-slot="{ open: openSlot }" v-bind="forwarded" class="ui-collapsible">
<slot :open="openSlot" />
</CollapsibleRoot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const delegatedProps = computed(() => {
</script>

<template>
<!-- @vue-expect-error Radix-vue props doesn't follow our exactOptionalPropertyTypes rule -->
<Label v-bind="delegatedProps" :class="labelVariants({ variant })">
<slot />
</Label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)

<template>
<TooltipPortal>
<!-- @vue-expect-error Radix-vue props doesn't follow our exactOptionalPropertyTypes rule -->
<TooltipContent
v-bind="{ ...forwarded, ...$attrs }"
:class="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const props = defineProps<TooltipProviderProps>()
</script>

<template>
<!-- @vue-expect-error Radix-vue props doesn't follow our exactOptionalPropertyTypes rule -->
<TooltipProvider v-bind="props">
<slot />
</TooltipProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const props = defineProps<TooltipTriggerProps>()
</script>

<template>
<!-- @vue-expect-error Radix-vue props doesn't follow our exactOptionalPropertyTypes rule -->
<TooltipTrigger v-bind="props">
<slot />
</TooltipTrigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const forwarded = useForwardPropsEmits(props, emits)
</script>

<template>
<!-- @vue-expect-error Radix-vue props doesn't follow our exactOptionalPropertyTypes rule -->
<TooltipRoot v-bind="forwarded">
<slot />
</TooltipRoot>
Expand Down
5 changes: 4 additions & 1 deletion packages/cmk-frontend-vue/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
// Enabling this option doesn't play nice with vue:
// Properties of components exported via index.ts will be typed as Any
// Issue link: https://github.com/vuejs/core/issues/11732
"noPropertyAccessFromIndexSignature": false,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true
Expand Down

0 comments on commit 86b2de8

Please sign in to comment.