What is the first step to add TypeScript support in a new Vue 3 project?
Use the Vue CLI or Vite to create a new project and select TypeScript support during setup. For example, with Vite: run npm create vite@latest my-vue-app -- --template vue-ts.
Click to reveal answer
intermediate
How do you enable TypeScript in an existing Vue 3 project?
Install TypeScript and Vue's TypeScript support packages, then rename .js files to .ts or .vue files with <script lang="ts">. Also, add a tsconfig.json file to configure TypeScript.
Click to reveal answer
beginner
What is the purpose of lang="ts" in Vue single-file components?
It tells Vue and the build tools that the script section uses TypeScript syntax, so it should be compiled accordingly.
Click to reveal answer
intermediate
Why do you need a shims-vue.d.ts file when using TypeScript in Vue?
Because TypeScript doesn't understand .vue files by default, this file declares modules for Vue files so TypeScript can process them without errors.
Click to reveal answer
advanced
What is a common TypeScript configuration option to improve Vue development experience?
Setting strict: true in tsconfig.json helps catch errors early. Also, enabling jsx: preserve if using JSX, and including src/**/*.vue in include.
Click to reveal answer
Which command creates a new Vue 3 project with TypeScript using Vite?
Step 1: Identify TypeScript and Composition API usage
Using lang="ts" setup enables TypeScript and Composition API syntax in Vue 3.
Step 2: Check other options
The version with lang="js" setup uses JavaScript not TypeScript, the plain <script> lacks the lang="ts" attribute, and the one using export default with data() is Options API, not Composition API.
Final Answer:
<script lang="ts" setup> with ref import and usage -> Option C
Quick Check:
Use lang="ts" setup for Composition API with TypeScript [OK]
Hint: Use
Common Mistakes:
Omitting lang="ts" for TypeScript
Using lang="js" instead of lang="ts"
Mixing Options API with Composition API syntax
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.