Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add a triple-slash directive for a type definition file.
Typescript
/// <reference path=[1] /> Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes instead of double quotes.
Referencing a .js or .ts file instead of a .d.ts file.
Omitting the quotes around the path.
✗ Incorrect
Triple-slash directives use a path to a type definition file, usually ending with .d.ts, enclosed in double quotes.
2fill in blank
mediumComplete the triple-slash directive to reference a types package.
Typescript
/// <reference types=[1] /> Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes instead of double quotes.
Referencing a package name that is not installed.
Omitting quotes around the package name.
✗ Incorrect
The triple-slash directive with 'types' references the name of a types package, usually in double quotes.
3fill in blank
hardFix the error in the triple-slash directive syntax.
Typescript
/// <reference [1]="./globals.d.ts" />
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'paths' instead of 'path'.
Confusing 'type' with 'types'.
Omitting the attribute name.
✗ Incorrect
The correct attribute for referencing a file path is 'path'. 'paths' is invalid, and 'type' or 'types' are used differently.
4fill in blank
hardFill both blanks to create a triple-slash directive referencing a types package with the correct syntax.
Typescript
/// <reference [1]=[2] />
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'path' instead of 'types' for packages.
Not using quotes around the package name.
Using single quotes instead of double quotes.
✗ Incorrect
The attribute 'types' is used to reference a types package, and the package name must be in double quotes.
5fill in blank
hardFill all three blanks to create a triple-slash directive referencing a path to a type definition file with correct syntax.
Typescript
/// <reference [1]=[2][3] />
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes instead of double quotes.
Omitting quotes around the path.
Using 'types' instead of 'path' for file references.
✗ Incorrect
The attribute is 'path', the path must be enclosed in double quotes, so the second blank is a double quote, and the third blank is the file path.