noPropertyAccessFromIndexSignature: Stricter Object Access
What you'll learn: How to force bracket notation for dynamically-defined properties, making the distinction between known and index-signature properties explicit in your code.
The Core Idea
When you define an object type with an index signature, you're saying "this object can have any number of properties with keys of this type." TypeScript normally lets you access these properties using either dot notation (obj.prop) or bracket notation (obj["prop"]).
The noPropertyAccessFromIndexSignature flag changes this: properties defined only through an index signature must be accessed with brackets. Properties explicitly declared in the type can still use dot notation.
This distinction makes it crystal clear when you're accessing a known, guaranteed property versus a dynamic, maybe-exists property.
Plain English Explanation
Think of an object like a filing cabinet. Some drawers are labeled and permanently installed (explicit properties). Others are unlabeled slots where you can insert folders as needed (index signature properties).
With this flag enabled, TypeScript says: "If you want something from a labeled drawer, just open it normally. But if you're reaching into the unlabeled slots, you must explicitly check the label first" — that's what bracket notation represents.
When This Matters
Without this flag, user.middleName and user["middleName"] look identical to TypeScript, even if middleName only exists through an index signature. With the flag, the bracket notation serves as a visual reminder: "This property might not exist; I'm accessing something dynamic."
Key Takeaway: noPropertyAccessFromIndexSignature enforces bracket notation for index-signature-only properties, creating a syntactic distinction between guaranteed and dynamic property access for safer, more intentional code.