0
0
Vueframework~5 mins

Setting up TypeScript in Vue project - Quick Revision & Summary

Choose your learning style9 modes available
Recall & Review
beginner
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?
Anpm create vite@latest my-app -- --template vue-ts
Bvue create my-app --typescript
Cnpm init vue@latest my-app
Dvue add typescript
In a Vue single-file component, how do you specify the script uses TypeScript?
A<script type="ts">
B<script type="typescript">
C<script lang="typescript">
D<script lang="ts">
What file tells TypeScript how to handle .vue files?
Ashims-vue.d.ts
Bvue.config.js
Ctsconfig.json
Dpackage.json
Which package is essential to install for TypeScript support in Vue 3?
Avue-router
Bvuex
Ctypescript
Deslint
What is a benefit of enabling strict mode in tsconfig.json?
AIt disables type checking.
BIt helps catch errors early by enforcing stricter type checks.
CIt makes the app run faster.
DIt automatically converts JavaScript to TypeScript.
Explain the steps to set up TypeScript in a new Vue 3 project using Vite.
Think about project creation, file setup, and TypeScript declarations.
You got /4 concepts.
    Describe why the shims-vue.d.ts file is important in a Vue TypeScript project.
    Consider how TypeScript treats unknown file types.
    You got /3 concepts.