TypeScript/tests/cases/conformance/types/conditional/conditionalTypesExcessProperties.ts
Nathan Shively-Sanders 42a2d9e568
Excess property understands conditional types (#25584)
Previously it did not, causing misleading excess property errors. Note
that assignability errors with conditional types are still usually
confusing. This PR doesn't address that.

Also, make sure that exact matches in getSpellingSuggestion are skipped.
2018-07-11 11:24:40 -07:00

10 lines
308 B
TypeScript

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
}