1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
//// [conditionalTypesExcessProperties.ts]
type Something<T> = { test: string } & (T extends object ? {
arg: T
} : {
arg?: undefined
});
function testFunc2<A extends object>(a: A, sa: Something<A>) {
sa = { test: 'hi', arg: a }; // not excess (but currently still not assignable)
sa = { test: 'bye', arg: a, arr: a } // excess
}
//// [conditionalTypesExcessProperties.js]
function testFunc2(a, sa) {
sa = { test: 'hi', arg: a }; // not excess (but currently still not assignable)
sa = { test: 'bye', arg: a, arr: a }; // excess
}
|