Recall & Review
beginner
What is a triple-slash directive in TypeScript?
A triple-slash directive is a single-line comment starting with
/// that provides compiler instructions, like referencing other files or types.Click to reveal answer
beginner
How do you reference another file using a triple-slash directive?
You use
/// <reference path="filename.ts" /> at the top of your TypeScript file to tell the compiler to include that file.Click to reveal answer
intermediate
What is the purpose of
/// <reference types="..." /> directive?It tells the compiler to include type declarations from a package, usually from
node_modules/@types, so you get type info for libraries.Click to reveal answer
beginner
Where should triple-slash directives be placed in a TypeScript file?
They must be placed at the very top of the file, before any other code or import statements.Click to reveal answer
intermediate
Can triple-slash directives affect module resolution in TypeScript?
Yes, they can guide the compiler to find files or types that are not automatically discovered, helping with module resolution.
Click to reveal answer
What does the triple-slash directive
/// <reference path="utils.ts" /> do?✗ Incorrect
The directive tells the compiler to include the referenced file utils.ts during compilation.
Where must triple-slash directives appear in a TypeScript file?
✗ Incorrect
Triple-slash directives must be at the top of the file before any other code or imports.
Which triple-slash directive is used to include type declarations from a package?
✗ Incorrect
The
/// <reference types="..." /> directive includes type declarations from packages.What symbol starts a triple-slash directive in TypeScript?
✗ Incorrect
Triple-slash directives start with three slashes:
///.Can triple-slash directives be used to affect module resolution?
✗ Incorrect
Triple-slash directives guide the compiler to find files or types, affecting module resolution.
Explain what triple-slash directives are and how they are used in TypeScript.
Think about how TypeScript knows about other files or type info.
You got /4 concepts.
Describe the difference between
/// <reference path="..." /> and /// <reference types="..." /> directives.One is for files, the other is for type packages.
You got /4 concepts.