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>
3
Answers
I think it worked and you need to use
type
in import because usingtypescript
:This should be working well
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.TypeScript uses types and interfaces that are not recognized by pure JavaScript. So my friend, you need to remove type declarations, keep imports because modern JavaScript (ES6) supports imports.`
import { Content } from ‘@prismicio/client’;
const props = getSliceComponentProps(["slice"]);
`