#Error from `exactOptionalPropertyTypes` incorrectly silenced by ternary
7 messages · Page 1 of 1 (latest)
Preview:```ts
import {Types} from "mongoose"
type ReceivedCtx = {
requestBody: {
parentId?: Types.ObjectId
}
}
type ExpectedParameters = {
parent?: Types.ObjectId
}
function update(args: ExpectedParameters) {
// something
}
declare const ctx: ReceivedCtx
...```
Here's a more minimal reproduction:
Preview:```ts
type Foo = {x?: number}
declare const a: number | undefined
declare const source: Foo
const b = source.x
let target: Foo
target = true ? {x: a} : {}
target = true ? {x: b} : {}
target = true ? {x: source.x} : {}
target = {...{x: a}}
target = {...{x: b}}
...```
Seems like a very specific bug, it requires all 3 of spread + ternary + accessing an optional value from object, and doesn't happen if any of that is missing as seen in the repro.