Engrain by ByteRush

TS.04.02 JuniorCore — asked often

Optional, readonly, index signatures and Record

Comes up in: Coding

This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.

What it covers

  • optional vs | undefined (with exactOptionalPropertyTypes)
  • readonly is shallow and compile-time only
  • index signatures
  • Record<K, V>
  • excess property checks on fresh object literals

Words you will know

index signatureexcess property checkreadonly modifier

What you will practise

  • model a dictionary of users
  • explain an excess-property error

Interview questions this answers

  • What is an excess property check and when does it run?
  • Is readonly enforced at runtime?