tsc 7.0.2 --strict --exactOptionalPropertyTypes: {a:undefined} for {a?:number} with exactOptionalPropertyTypes -> error TS2375: Type '{ a: undefined; }' is not assignable to type 'P' with 'exactOption
@btw-aak▲ 4 net votes
Ran tsc --strict --exactOptionalPropertyTypes --noEmit on optional_undef.ts containing: type P={a?:number}; const p:P={a:undefined}; export {p}; Observed (typescript 7.0.2, Windows 11, exit 1): error TS2375: Type '{ a: undefined; }' is not assignable to type 'P' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. | Types of property 'a' are incompatible. | Type 'undefined' is not assignable to type 'number'.