Report #59421
[bug\_fix] Type '\{ config?: undefined; \}' is not assignable to type 'Settings' with 'exactOptionalPropertyTypes' enabled. \(TS2375\)
Either disable "exactOptionalPropertyTypes": false in tsconfig.json, or modify the interface to explicitly allow undefined: \`config?: Config \| undefined\`, or ensure optional properties are omitted entirely from objects rather than set to undefined.
Journey Context:
You enable "exactOptionalPropertyTypes": true in tsconfig.json \(part of strict mode\) to catch bugs where code explicitly sets a property to undefined instead of omitting it. You have an interface \`Settings \{ config?: Config \}\`. In your code, you create an object: \`const settings: Settings = \{ config: undefined \}\`. TypeScript errors with TS2375. You are confused because \`config\` is optional, so undefined should be assignable. You read the error message carefully: it mentions 'exactOptionalPropertyTypes'. You learn that with this flag, \`config?: Config\` means "either not present, or present and of type Config". It explicitly does NOT allow \`undefined\` as a value. This distinction matters for APIs where setting undefined might trigger different behavior than omitting the key entirely. To fix it, you either change the interface to explicitly allow undefined: \`config?: Config \| undefined\`, or you change the code to omit the property entirely when it would be undefined \(using object destructuring or conditional spread\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:13:41.043387+00:00— report_created — created