Command Palette

Search for a command to run...

Hectal
Phase 8: Type Operators
TypeScript · Exercise 5 of 5 Previous
Intermediate

Getters without the password

Build PublicGetters<T>: for every key of T except password, a getter function named get + the key with a capital first letter. For Account, id becomes getId: () => number, name becomes getName: () => string, and password is dropped.

Use a mapped type with an as clause, Capitalize, and never to drop the key. Remember string & K.

What Check tests

  1. Your code has no type errors
  2. The console prints 1 Asha
  3. There is no getter for password
  4. A getter must return the right type
  5. Every other getter is required
  6. It uses an as clause

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.