An error occurred when using defineProps<>.
Version
3.2.22
Reproduction link
Steps to reproduce
Create one interface file with typescript type.
Import the file from the component(. vue) that definesProps.
Define props as follows.
import type { GroupTitleLargePageData, GroupTitleLargeProps } from "@/interfaces/components/groups/GroupTitleLargePageTypes";
const props = withDefaults(defineProps
------------------- error ----------------------------
[plugin:vite:vue] [@vue/compiler-sfc] type argument passed to defineProps() must be a literal type, or a reference to an interface or literal type.
D:/project/hamonica/workspace/hamonica-fe-type/src/components/groups/GroupTitleLarge.vu
14 | const props = withDefaults(defineProps
What is expected?
I want to call and use the props interface through import.
What is actually happening?
------------------- error ----------------------------
[plugin:vite:vue] [@vue/compiler-sfc] type argument passed to defineProps() must be a literal type, or a reference to an interface or literal type.
D:/project/hamonica/workspace/hamonica-fe-type/src/components/groups/GroupTitleLarge.vu
14 | const props = withDefaults(defineProps
i use vite + typescript
look: https://github.com/vuejs/vue-next/issues/4294#issuecomment-896082769 You can declare SampleProps in app.vue eg:
<script lang='ts'>
export interface SampleProps{
sample1?:string;
sample2?:string;
}
</script>
<script setup lang="ts">
import { ref } from 'vue'
import SampleProps from './SampleProps'
const props = withDefaults(defineProps<SampleProps>(),{
sample1:'sample'
});
</script>
<template>
<h1>{{ props }}</h1>
</template>
no. I know it's not supported yet.
-----Original Message----- From: @.> To: @.>; Cc: @.>; @.>; Sent: 2022-03-27 (일) 16:06:49 (GMT+09:00) Subject: Re: [vuejs/core] An error occurred when using defineProps<>. (Issue #4982)
duplicate of #4294
Has it been fixed? I meet the same problem @v3.2.13 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>