0
0
Typescriptprogramming~10 mins

What types exist only at compile time in Typescript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a type alias in TypeScript.

Typescript
type Name = [1];
Drag options to blanks, or click blank then click option'
Aboolean
B"string"
Cnumber
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around type keywords like "string" instead of using string.
Using values instead of type keywords.
2fill in blank
medium

Complete the code to define an interface in TypeScript.

Typescript
interface Person { name: [1]; age: number; }
Drag options to blanks, or click blank then click option'
A"string"
Bboolean
Cstring
Dnumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around string type.
Using number or boolean instead of string for name.
3fill in blank
hard

Fix the error in this type assertion that uses a compile-time only type.

Typescript
const value = "hello" as [1];
Drag options to blanks, or click blank then click option'
AString
Bstring
C"string"
Dnumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using quoted types like "string" in assertions.
Using the boxed type String instead of string.
4fill in blank
hard

Fill both blanks to create a mapped type that exists only at compile time.

Typescript
type Readonly[1]<[2]> = { readonly [K in keyof [2]]: [2][K] };
Drag options to blanks, or click blank then click option'
AProps
BT
CU
DV
Attempts:
3 left
💡 Hint
Common Mistakes
Using values instead of type parameter names.
Mixing up the generic parameter name and the new type name.
5fill in blank
hard

Fill all three blanks to define a conditional type that exists only at compile time.

Typescript
type IsString[1]<[2]> = [2] extends string ? true : [3];
Drag options to blanks, or click blank then click option'
ACheck
BT
Cfalse
Dboolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using values instead of type parameter names.
Using boolean instead of false in the false branch.