Report #11997
[bug\_fix] Type 'MyInterface' is not assignable to type 'Record'. Index signature is missing in type 'MyInterface'.ts\(2322\)
Add an explicit index signature to the interface that matches the required constraint, e.g., \[key: string\]: string. Alternatively, use a type assertion \(as Record\) if you are certain the object conforms. If the target type is under your control, consider using a mapped type or making the index signature optional. The root cause is structural typing: an interface without an explicit index signature is not considered assignable to a type that requires one, even if all declared properties match.
Journey Context:
You're refactoring a function to accept a Record for a dictionary of headers. You pass an object that implements an interface with specific properties: interface Headers \{ authorization: string; contentType: string; \}. You get 'Index signature is missing in type 'Headers''. You check the interface—it's just a list of properties. You realize TypeScript treats explicit properties and index signatures separately. Even though Headers has string values, TypeScript won't let you assign it to Record because it doesn't explicitly guarantee that any string key will return a string \(even though it looks like it should\). You have two choices: add \[key: string\]: string to the Headers interface \(but this loosens the type\), or use a type assertion \(headers as Record\) at the call site. You choose the latter for now, understanding that TypeScript is protecting you from potential missing keys.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T14:49:17.209246+00:00— report_created — created