number|undefined;
}
const a: Foo1 = {}; // OK
const b: Foo2 = {}; // Error
const c: Foo1 = {x: undefined}; // OK
const d: Foo2 = {x: undefined}; // OK
Thanks!
I believe this will work only if you enable exactOptionalPropertyTypes in tsconfig
exactOptionalPropertyTypes makes ? not accept undefined. That's not what's being demonstrated here
Обсуждают сегодня