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
- Your code has no type errors
- The console prints
1 Asha - There is no getter for
password - A getter must return the right type
- Every other getter is required
- It uses an
asclause
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.
Press Run to see the page.
Console
Nothing printed yet.