mitjans / nuxt-posthog

Posthog module for Nuxt
https://nuxt-posthog.cmitjans.dev
MIT License
25 stars 3 forks source link

fix: vue compiler warning using `withDefaults` & reactive prop destruture #49

Closed ryanweston closed 1 week ago

ryanweston commented 1 week ago

Fixes @vue/compiler-sfc warning in PostHogFeatureFlagwhere reactive destructuring is disabled when withDefaults is used.

Warning: 
[@vue/compiler-sfc] withDefaults() is unnecessary when using destructure with defineProps().
Reactive destructure will be disabled when using withDefaults().
Prefer using destructure default values, e.g. const { foo = 1 } = defineProps(...).

PATH/node_modules/.pnpm/nuxt-posthog@1.5.3_magicast@0.3.5_rollup@4.18.0_webpack-sources@3.2.3/node_modules/nuxt-posthog/dist/runtime/components/PostHogFeatureFlag.vue
3  |  import usePostHogFeatureFlag from '../composables/usePostHogFeatureFlag';
4  |
5  |  const { name } = withDefaults(
   |                   ^^^^^^^^^^^^
6  |    defineProps<{
7  |      name: string;

Forced to used runtime types as destructure syntax to set defaults does not work with boolean casting. For example the below will still default to false:

interface Props {
  name: string;
  match?: string | boolean;
}

const { name, match = true } = defineProps<Props>();
vercel[bot] commented 1 week ago

@ryanweston is attempting to deploy a commit to the cmitjans' projects Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] commented 1 week ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuxt-posthog-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 27, 2024 5:29pm