Q76: What does the `noUncheckedIndexedAccess` compiler option do?

Difficulty:MediumTopic:Compiler Options

When noUncheckedIndexedAccess is enabled, accessing dynamic keys on an object or array via index signatures automatically appends | undefined to the returned type, forcing developers to perform protective safety checks.

noUncheckedIndexedAccess Safety Check
const dict: Record<string, string> = { key: "value" };

// With noUncheckedIndexedAccess enabled:
const val = dict["missingKey"]; // Type: string | undefined

// Forces developer check before usage!
if (val !== undefined) {
  console.log(val.toUpperCase());
}
💡 Appends | undefined to dynamic property access results to prevent runtime errors.
Key Takeaways
  • Appends | undefined to dynamic dictionary and array access lookups for safety.