Report #53019
[bug\_fix] Type 'Config' is not assignable to type 'Record'. Index signature is missing in type 'Config'. \(TS2322\)
Add an index signature to the \`Config\` interface \(e.g., \`\[key: string\]: number\`\), use a type assertion \(e.g., \`as Record\`\) if you are certain of the structure, or use \`satisfies Record\` \(TypeScript 4.9\+\) to check compatibility without changing the type. Root cause: TypeScript treats objects with only explicit named properties as structurally distinct from types with index signatures unless explicitly declared compatible; it cannot verify that arbitrary string access will return the correct type.
Journey Context:
You have defined an interface \`interface Config \{ width: number; height: number; \}\` and you're trying to pass an object of this type to a generic function \`processData\(data: Record\)\`. TypeScript immediately flags the argument with the error that \`Config\` is not assignable to \`Record\` because the index signature is missing. You think, "But \`Config\` only has number values, why doesn't it satisfy the record?" You try to fix it by changing the function parameter to \`Config\`, but that defeats the purpose of the generic utility function. You search online and find explanations about structural typing and index signatures. You realize that without an explicit index signature \`\[key: string\]: number\` in the \`Config\` interface, TypeScript cannot guarantee that \`config\['arbitraryKey'\]\` returns a number, even though all defined properties are numbers. You have a few options: 1\) Add \`\[key: string\]: number\` to the \`Config\` interface, which allows arbitrary keys but constrains them to numbers, 2\) Use a type assertion \`as Record\` when calling the function, bypassing the check if you're certain, or 3\) Use the \`satisfies\` keyword \(TypeScript 4.9\+\) when defining the object: \`const config = \{ width: 10, height: 20 \} satisfies Record\`, which checks the constraint without widening the type to \`Record\`. You choose to add the index signature to the interface since you control it and want the flexibility. The error disappears because TypeScript can now verify that any string access on \`Config\` will indeed return a number.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T19:29:20.305121+00:00— report_created — created