<template>
<div class="app">
Greetings, {{ name }}
<button @click="updateName('Jane')">Modify Name</button>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
name: 'App',
components: {
},
data(){
return {
name:'John'
}
},
methods: {
updateName(name: string){
this.name = name
}
}
});
</script>
<style>
</style>
I am currently delving into TypeScript and one of its key features is enforcing "types". I have a method called 'updateName(name: string)' with a parameter 'name' that should be a string. However, when I pass a number or boolean as the argument in the template to the updateName function, it accepts them without throwing any errors.