1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
=== tests/cases/compiler/nonObjectUnionNestedExcessPropertyCheck.ts ===
interface IProps {
iconProp?: string;
>iconProp : string
nestedProp?: {
>nestedProp : { testBool?: boolean; }
testBool?: boolean;
>testBool : boolean
}
}
interface INestedProps {
nestedProps?: IProps;
>nestedProps : IProps
}
// These are the types of errors we want:
const propB1: IProps | number = { INVALID_PROP_NAME: 'share', iconProp: 'test' };
>propB1 : number | IProps
>{ INVALID_PROP_NAME: 'share', iconProp: 'test' } : { INVALID_PROP_NAME: string; iconProp: string; }
>INVALID_PROP_NAME : string
>'share' : "share"
>iconProp : string
>'test' : "test"
// Nested typing works here and we also get an expected error:
const propB2: IProps | number = { nestedProp: { asdfasdf: 'test' }, iconProp: 'test' };
>propB2 : number | IProps
>{ nestedProp: { asdfasdf: 'test' }, iconProp: 'test' } : { nestedProp: { asdfasdf: string; }; iconProp: string; }
>nestedProp : { asdfasdf: string; }
>{ asdfasdf: 'test' } : { asdfasdf: string; }
>asdfasdf : string
>'test' : "test"
>iconProp : string
>'test' : "test"
// Want an error generated here but there isn't one.
const propA1: INestedProps | number = { nestedProps: { INVALID_PROP_NAME: 'share', iconProp: 'test' } };
>propA1 : number | INestedProps
>{ nestedProps: { INVALID_PROP_NAME: 'share', iconProp: 'test' } } : { nestedProps: { INVALID_PROP_NAME: string; iconProp: string; }; }
>nestedProps : { INVALID_PROP_NAME: string; iconProp: string; }
>{ INVALID_PROP_NAME: 'share', iconProp: 'test' } : { INVALID_PROP_NAME: string; iconProp: string; }
>INVALID_PROP_NAME : string
>'share' : "share"
>iconProp : string
>'test' : "test"
|