The TypeScript team has shipped a new compiler flag in the 6.0 release – --noPropertyAccessFromIndexSignature. When enabled, the compiler refuses dot-notation access to properties that come from an index signature, forcing developers to use bracket notation and surfacing potential undefined values at compile time instead of in production.
Why the flag matters
In JavaScript, objects often serve as dictionaries, and TypeScript lets you type such structures with an index signature, e.g. Record<string, T>. The language treats obj.key and obj["key"] as interchangeable, so the compiler assumes the property exists even when the key is only known at runtime. That silent assumption is the source of many crashes: code that accesses obj.missingProp compiles fine, runs, and then throws because the value is undefined.
Dot notation carries an implicit guarantee – it tells readers and the type checker that the property is definitely present. Bracket notation, by contrast, signals uncertainty – the key might be missing, and the result could be undefined. --noPropertyAccessFromIndexSignature enforces that visual and semantic distinction, turning a class of runtime errors into compile-time diagnostics.
How the flag works
When the flag is turned on, any expression that accesses a property through an index signature with dot notation is flagged as an error. The code must be rewritten to use brackets:
// Before
const name = userData.name; // OK even if "name" is not in the index
// After enabling the flag
const name = userData["name"]; // Error unless brackets are used
The compiler then applies the same undefined-handling rules it already uses for bracket access. If --noUncheckedIndexedAccess is also enabled, the type of userData["name"] becomes T | undefined, forcing the developer to check for the missing case.
Practical migration steps
Enable the flag in
tsconfig.json:{ "compilerOptions": { "noPropertyAccessFromIndexSignature": true } }Run the type checker. All dot-notation accesses to index-signature keys will appear as errors.
Replace dots with brackets. The change is mechanical; it does not affect runtime performance.
Address the resulting
undefinedtypes. Add nullish coalescing, optional chaining, or explicit checks where needed.Consider pairing with
--noUncheckedIndexedAccessfor the strongest safety net. Together they ensure that any dictionary-style access is treated as potentially absent.
When to keep explicit properties
If a field is part of a stable API contract, declare it as an explicit property rather than relying on an index signature. Explicit properties continue to allow dot notation, preserving the guarantee that the field will always be present (as far as the type system can verify). Reserve index signatures for truly dynamic data where keys are not known ahead of time.
Counter-point: added verbosity
Some teams may find the extra brackets noisy, especially in codebases that heavily use flexible objects. The flag forces a stricter discipline that can require a sizeable refactor for legacy projects. For those cases, the flag can be introduced incrementally, perhaps limited to new modules, while the broader codebase adopts the pattern over time.
What to watch next
The flag is part of a broader push in TypeScript 6.0 toward stricter type safety. Future releases may introduce additional checks around object spread, optional chaining, or inferred any usage. Keeping an eye on the TypeScript roadmap will help teams decide when to adopt the next set of safety features without disrupting delivery schedules.
Takeaway: Enabling --noPropertyAccessFromIndexSignature makes the distinction between “this property is guaranteed” and “this property might be missing” explicit in the code, catching a whole class of bugs before they reach production. Turning a silent runtime failure into a compile-time error is a small change with a disproportionate impact on reliability.
