Script Valley
TypeScript: Complete Course from Zero
TypeScript Foundations/Assessment

Practice & Assessment

Test your understanding of TypeScript Foundations

Multiple Choice Questions

5
1

What does the TypeScript compiler (tsc) produce as output?

2

With strict mode enabled, what happens when you assign null to a variable typed as string?

3

Which statement about the unknown type is correct?

4

What is the difference between a tuple and an array in TypeScript?

5

When should you prefer unknown over any?

Coding Challenges

1
1

Type a product inventory record

Create a TypeScript file that declares the following variables with correct explicit types: a product name (string), a price (number), an in-stock status (boolean), a list of tag strings (array), and a [sku, quantity] tuple where sku is a string and quantity is a number. Assign realistic values to each. Then write a function getProductSummary(name: string, price: number): string that returns a formatted string like 'Widget - $9.99'. Call it and log the result. Estimated time: 15 minutes.

Easy

Mini Project

1

Typed Contact Book

Build a typed contact management module. Declare a Contact tuple type as [fullName: string, email: string, age: number, isActive: boolean]. Create a contacts array of at least 3 entries. Write three functions: addContact(contacts, contact) that returns a new array with the contact added, findByName(contacts, name) that returns the matching Contact or undefined, and listActive(contacts) that returns only active contacts. Use strict types throughout — no any. The module should compile with npx tsc --strict with zero errors.

Easy