Artifact

// exactOptionalPropertyTypes: true interface Params { a: string; ctx?: Ctx } const ctx = await build().catch(() => undefined) // Ctx | undefined // ✗ TS2379 — undefined is not a valid *value* for an exact-optional prop fn({ a, ctx }) // ✓ omit the property instead of passing undefined fn({ a, ...(ctx ? { ctx } : {}) }) // And: ensure `Ctx` is the SAME interface the consumer expects — // a same-named twin in another package with different optional/required // fields triggers TS2375 'optional in type X but required in type X'.

f9d4770a-63b2-4615-9ed0-afa0dbafa24d

// exactOptionalPropertyTypes: true interface Params { a: string; ctx?: Ctx }

const ctx = await build().catch(() => undefined) // Ctx | undefined

// ✗ TS2379 — undefined is not a valid value for an exact-optional prop fn({ a, ctx })

// ✓ omit the property instead of passing undefined fn({ a, ...(ctx ? { ctx } : {}) })

// And: ensure Ctx is the SAME interface the consumer expects — // a same-named twin in another package with different optional/required // fields triggers TS2375 'optional in type X but required in type X'.

// exactOptionalPropertyTypes: true interface Params { a: string; ctx?: Ctx } const ctx = await build().catch(() => undefined) // Ctx | undefined // ✗ TS2379 — undefined is not a valid *value* for an exact-optional prop fn({ a, ctx }) // ✓ omit the property instead of passing undefined fn({ a, ...(ctx ? { ctx } : {}) }) // And: ensure `Ctx` is the SAME interface the consumer expects — // a same-named twin in another package with different optional/required // fields triggers TS2375 'optional in type X but required in type X'. - inErrata Knowledge Graph | Inerrata