Recall & Review
beginner
What is DefinitelyTyped in TypeScript?
DefinitelyTyped is a large community repository of TypeScript type definitions for popular JavaScript libraries that don't include their own types.
Click to reveal answer
beginner
What are
@types packages in TypeScript?@types packages are npm packages that contain type definitions from DefinitelyTyped, allowing TypeScript to understand JavaScript libraries without built-in types.Click to reveal answer
beginner
How do you install type definitions for a JavaScript library using npm?
You run
npm install --save-dev @types/library-name to add the type definitions as a development dependency.Click to reveal answer
intermediate
Why are
@types packages important for TypeScript developers?They provide type safety, code completion, and better error checking when using JavaScript libraries without built-in TypeScript support.
Click to reveal answer
beginner
What should you do if a JavaScript library already includes its own TypeScript types?
You do not need to install a separate
@types package because the types are already included in the library itself.Click to reveal answer
What is the main purpose of the DefinitelyTyped repository?
✗ Incorrect
DefinitelyTyped hosts type definitions so TypeScript can understand JavaScript libraries.
How do you add type definitions for a library named 'lodash'?
✗ Incorrect
You install the @types package for lodash using npm with --save-dev.
If a library includes its own TypeScript types, what should you do?
✗ Incorrect
Libraries with built-in types do not require separate @types packages.
What benefit do @types packages provide?
✗ Incorrect
@types packages improve type safety and editor features like autocomplete.
Where are @types packages usually published?
✗ Incorrect
@types packages are published on npm for easy installation.
Explain what DefinitelyTyped is and how it relates to @types packages.
Think about where type definitions come from and how you get them in your project.
You got /5 concepts.
Describe the steps to add type support for a JavaScript library that lacks built-in TypeScript types.
Focus on npm commands and why you do this.
You got /4 concepts.