Report #96820
[bug\_fix] Object literal may only specify known properties, and 'debug' does not exist in type 'UserConfig'. ts\(2322\) or ts\(2345\)
To intentionally include extra properties, assign the object to a variable first \(which bypasses the check\), use a type assertion \(e.g., \`as UserConfig\`\), or use the \`satisfies\` operator \(TypeScript 4.9\+\) to validate the object without widening the type. To allow arbitrary properties, add an index signature \`\[key: string\]: any\` to the interface.
Journey Context:
Developer defines an interface \`ServerConfig\` with properties \`port\` and \`host\`. They call a function \`setup\(\{ port: 3000, host: '0.0.0.0', debug: true \}\)\` and immediately get a TS2322 error on the \`debug\` property. They assume the function signature is wrong and check the type definition. They try \`as ServerConfig\` and it works, but feels unsafe. They read about structural typing and assume TS is nominally typed. They check \`strict\` mode. They realize that object literals undergo excess property checking, a special check for typos, which doesn't apply to variables passed in. If they did \`const opts = \{ port: 3000, host: '0.0.0.0', debug: true \}; setup\(opts\);\` it would work \(structural typing allows extra properties, just checks minimum\). The fix is either to use a type assertion \(if intentional\), add the property to the interface, or use index signature, or assign to a variable first.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T21:05:48.905279+00:00— report_created — created