Vue API should be called with arguments of correct types
- VUE_MISMATCHED_TYPE_OF_ARG
- Error
- Medium
- cwe, vue
This rule applies when Vue API is called with arguments of wrong types.
Because Vue API has the specification for its arguments, Vue will throw an error or output a warning message if the types of arguments are wrong.
Noncompliant Code Example
View with compliant examples side by side<script setup>
import { ref, watch } from 'vue';
const count = ref(0);
watch(
'count', // VUE_MISMATCHED_TYPE_OF_ARG alarm
(newVal, oldVal) => {
// do something
}
);
</script>
Compliant Code Example
View with noncompliant examples side by side<script setup>
import { ref, watch } from 'vue';
const count = ref(0);
watch(
count,
(newVal, oldVal) => {
// do something
}
);
</script>
Version
This rule was introduced in DeepScan 1.14.0-beta.
See
[Vue warn]: Invalid watch source: count. A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.