TypeScript adds type checking which helps find mistakes before running the app. This improves code quality and developer confidence.
<script setup lang="ts"> import { defineProps } from 'vue' const props = defineProps<{ age: number }>() </script> <template> <p>Age: {{ props.age }}</p> </template>
TypeScript checks types during development and will warn if a string is passed where a number is expected. However, at runtime Vue does not enforce types strictly, so the app runs but with a potential type mismatch.
Option A correctly uses a type parameter with reactive() to type the state object. Option A is invalid syntax. Option A has wrong count type. Option A misuses reactive typing.
Computed properties in Vue are readonly by default. Trying to assign to double.value causes a TypeScript error because 'value' is readonly.
Option A uses the generic type parameter with inject and the non-null assertion operator (!) to tell TypeScript the injected value exists. Option A uses a type assertion but does not guarantee non-null. Option A lacks non-null assertion and may cause undefined errors. Option A provides a default but changes injection behavior.