Search code examples
javascripttypescriptvue.jsvuejs3nuxtjs3

How to convert nuxt props from typescript in to js


I was wondering how can I convert this little snippet from typescript into JS.

<script setup lang="ts">
  import { type Content } from '@prismicio/client';

  defineProps(
    getSliceComponentProps<Content.HeroSlice>([
      "slice",
    ]),
  );
</script>

Solution

  • This should be working well

    <script setup>
    import * as prismic from '@prismicio/client'
    
    defineProps(getSliceComponentProps(["slice"]))
    </script>
    

    More info can be found in the docs.

    Since you're not typing it, you don't even need the Content in the TS generic.
    Use prismic.[your method] to do your usual Prismic stuff.