TypeScript/tests/cases/compiler/nonObjectUnionNestedExcessPropertyCheck.ts
Wesley Wigham 169e485d90
Perform excess property checking on intersection and union members (#30853)
* Perform excess property checking on intersection and union members

* Allow partial union props to contain the undefined type

* Add test case from #30771

* Un-terse getPossiblePropertiesOfUnionType side-effecting code

* Fix bug exposed in RWC

* Cache results of getPossiblePropertiesOfUnionType

* Fix whitespace
2019-04-16 21:58:48 -07:00

20 lines
606 B
TypeScript

interface IProps {
iconProp?: string;
nestedProp?: {
testBool?: boolean;
}
}
interface INestedProps {
nestedProps?: IProps;
}
// These are the types of errors we want:
const propB1: IProps | number = { INVALID_PROP_NAME: 'share', iconProp: 'test' };
// Nested typing works here and we also get an expected error:
const propB2: IProps | number = { nestedProp: { asdfasdf: 'test' }, iconProp: 'test' };
// Want an error generated here but there isn't one.
const propA1: INestedProps | number = { nestedProps: { INVALID_PROP_NAME: 'share', iconProp: 'test' } };