Allowance of any attributes for components creates problems for me.
For example taking this:
<script setup lang="ts">
import { ref } from 'vue';
import Checkbox from './Checkbox.vue';
const value = ref(false);
</script>
<template>
<div>{{ value }}</div>
<Checkbox :value @change="value = !value" fake-attr="some" />
</template>
Checkbox.vue
<script setup lang="ts">
defineProps<{
value: boolean
}>();
const $emit = defineEmits<{
check: [boolean]
}>();
</script>
<template>
<div>
<input type="checkbox" @change="e => $emit('check')">
</div>
</template>
As you see I can mistakenly put any attributes for Checkbox. Moreover I made a typo and put , as an attribute getting not so clear an error message at runtime which I had to debug with a conditional breakpoint:
Failed to execute 'setAttribute' on 'Element': ',' is not a valid attribute name.
A big problem is also to refactor, for example if I want to rename a property for more semantics I don't get any errors after the renaming since the old property would be become a valid extra attribute.
Any way to restrict component attributes to allowed ones (properties)?
defineOptions({ inheritAttrs: false})serve you in some way?