Command Palette

Search for a command to run...

Hectal
Phase 15: TypeScript in Real Projects
TypeScript · Exercise 6 of 6 Previous
Intermediate

Migrate a file from JavaScript

This file was renamed from .js to .ts and now has implicit-any errors under the default strict options. Add real types to every parameter and return value, without using any.

totalPrice multiplies each item's price by its qty and adds them. findItem returns the item with that name, or undefined if there is none. The program must print total: 55 and missing: true.

What Check tests

  1. Your code has no type errors
  2. The program prints total: 55 and missing: true
  3. No any
  4. A price given as text is rejected
  5. findItem may return undefined

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Console

Nothing printed yet.