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