TypeScript/tests/cases/compiler/discriminateObjectTypesOnly.ts
Wesley Wigham 74c6bc1f85
Filter primitives from union when checking for mismatched excess props if nonprimitive type is present (#31708)
* Filter primitives from union when checking for mismatched excess props if nonprimitive type is present

* Use maybeTypeOfKind
2019-06-12 17:31:57 -07:00

11 lines
413 B
TypeScript

// @strict: true
type Thing = number | object;
const k: Thing = { toFixed: null }; // OK, satisfies object
type Thing2 = number | { toFixed: null } | object;
const q: Thing2 = { toFixed: null };
const h: Thing2 = { toString: null }; // OK, satisfies object
type Thing3 = number | { toFixed: null, toString: undefined } | object;
const l: Thing3 = { toString: undefined }; // error, toFixed isn't null