Reputation: 313
I am using Vue version 3.2 and TypeScript.
When I want to define my props like this:
<!-- AppButton.vue -->
<script lang="ts">
interface Iprops {
buttonType?: string;
size?: string;
disabled?: boolean;
loading?: boolean;
}
</script>
<script lang="ts" setup>
const props = defineProps<Iprops>();
</script>
When running the code, I get this error:
I searched a lot but did not find any results
Upvotes: 1
Views: 891
Reputation: 1
The interface
should be declared inside the script setup
, since the other script is usually used to declare inheritAttrs
or name
:
<script lang="ts" setup>
interface Iprops {
buttonType?: string;
size?: string;
disabled?: boolean;
loading?: boolean;
}
const props = defineProps<Iprops>();
</script>
Also imported types and complex ones are not supported for argument declaration type.
As of now, the type declaration argument must be one of the following to ensure correct static analysis:
Upvotes: 2