-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
tests/baselines/reference/nonObjectUnionNestedExcessPropertyCheck.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
tests/cases/compiler/nonObjectUnionNestedExcessPropertyCheck.ts(13,35): error TS2322: Type '{ INVALID_PROP_NAME: string; iconProp: string; }' is not assignable to type 'number | IProps'. | ||
Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'IProps'. | ||
tests/cases/compiler/nonObjectUnionNestedExcessPropertyCheck.ts(16,7): error TS2322: Type '{ nestedProp: { asdfasdf: string; }; iconProp: string; }' is not assignable to type 'number | IProps'. | ||
Type '{ nestedProp: { asdfasdf: string; }; iconProp: string; }' is not assignable to type 'IProps'. | ||
Types of property 'nestedProp' are incompatible. | ||
Type '{ asdfasdf: string; }' has no properties in common with type '{ testBool?: boolean; }'. | ||
tests/cases/compiler/nonObjectUnionNestedExcessPropertyCheck.ts(19,56): error TS2326: Types of property 'nestedProps' are incompatible. | ||
Type '{ INVALID_PROP_NAME: string; iconProp: string; }' is not assignable to type 'IProps'. | ||
Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'IProps'. | ||
|
||
|
||
==== tests/cases/compiler/nonObjectUnionNestedExcessPropertyCheck.ts (3 errors) ==== | ||
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' }; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2322: Type '{ INVALID_PROP_NAME: string; iconProp: string; }' is not assignable to type 'number | IProps'. | ||
!!! error TS2322: Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'IProps'. | ||
|
||
// Nested typing works here and we also get an expected error: | ||
const propB2: IProps | number = { nestedProp: { asdfasdf: 'test' }, iconProp: 'test' }; | ||
~~~~~~ | ||
!!! error TS2322: Type '{ nestedProp: { asdfasdf: string; }; iconProp: string; }' is not assignable to type 'number | IProps'. | ||
!!! error TS2322: Type '{ nestedProp: { asdfasdf: string; }; iconProp: string; }' is not assignable to type 'IProps'. | ||
!!! error TS2322: Types of property 'nestedProp' are incompatible. | ||
!!! error TS2322: Type '{ asdfasdf: string; }' has no properties in common with type '{ testBool?: boolean; }'. | ||
|
||
// Want an error generated here but there isn't one. | ||
const propA1: INestedProps | number = { nestedProps: { INVALID_PROP_NAME: 'share', iconProp: 'test' } }; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2326: Types of property 'nestedProps' are incompatible. | ||
!!! error TS2326: Type '{ INVALID_PROP_NAME: string; iconProp: string; }' is not assignable to type 'IProps'. | ||
!!! error TS2326: Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'IProps'. | ||
|
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/nonObjectUnionNestedExcessPropertyCheck.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//// [nonObjectUnionNestedExcessPropertyCheck.ts] | ||
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' } }; | ||
|
||
|
||
//// [nonObjectUnionNestedExcessPropertyCheck.js] | ||
// These are the types of errors we want: | ||
var propB1 = { INVALID_PROP_NAME: 'share', iconProp: 'test' }; | ||
// Nested typing works here and we also get an expected error: | ||
var propB2 = { nestedProp: { asdfasdf: 'test' }, iconProp: 'test' }; | ||
// Want an error generated here but there isn't one. | ||
var propA1 = { nestedProps: { INVALID_PROP_NAME: 'share', iconProp: 'test' } }; |
46 changes: 46 additions & 0 deletions
46
tests/baselines/reference/nonObjectUnionNestedExcessPropertyCheck.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
=== tests/cases/compiler/nonObjectUnionNestedExcessPropertyCheck.ts === | ||
interface IProps { | ||
>IProps : Symbol(IProps, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 0, 0)) | ||
|
||
iconProp?: string; | ||
>iconProp : Symbol(IProps.iconProp, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 0, 18)) | ||
|
||
nestedProp?: { | ||
>nestedProp : Symbol(IProps.nestedProp, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 1, 22)) | ||
|
||
testBool?: boolean; | ||
>testBool : Symbol(testBool, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 2, 18)) | ||
} | ||
} | ||
|
||
interface INestedProps { | ||
>INestedProps : Symbol(INestedProps, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 5, 1)) | ||
|
||
nestedProps?: IProps; | ||
>nestedProps : Symbol(INestedProps.nestedProps, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 7, 24)) | ||
>IProps : Symbol(IProps, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 0, 0)) | ||
} | ||
|
||
// These are the types of errors we want: | ||
const propB1: IProps | number = { INVALID_PROP_NAME: 'share', iconProp: 'test' }; | ||
>propB1 : Symbol(propB1, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 12, 5)) | ||
>IProps : Symbol(IProps, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 0, 0)) | ||
>INVALID_PROP_NAME : Symbol(INVALID_PROP_NAME, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 12, 33)) | ||
>iconProp : Symbol(iconProp, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 12, 61)) | ||
|
||
// Nested typing works here and we also get an expected error: | ||
const propB2: IProps | number = { nestedProp: { asdfasdf: 'test' }, iconProp: 'test' }; | ||
>propB2 : Symbol(propB2, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 15, 5)) | ||
>IProps : Symbol(IProps, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 0, 0)) | ||
>nestedProp : Symbol(nestedProp, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 15, 33)) | ||
>asdfasdf : Symbol(asdfasdf, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 15, 47)) | ||
>iconProp : Symbol(iconProp, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 15, 67)) | ||
|
||
// Want an error generated here but there isn't one. | ||
const propA1: INestedProps | number = { nestedProps: { INVALID_PROP_NAME: 'share', iconProp: 'test' } }; | ||
>propA1 : Symbol(propA1, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 18, 5)) | ||
>INestedProps : Symbol(INestedProps, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 5, 1)) | ||
>nestedProps : Symbol(nestedProps, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 18, 39)) | ||
>INVALID_PROP_NAME : Symbol(INVALID_PROP_NAME, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 18, 54)) | ||
>iconProp : Symbol(iconProp, Decl(nonObjectUnionNestedExcessPropertyCheck.ts, 18, 82)) | ||
|
49 changes: 49 additions & 0 deletions
49
tests/baselines/reference/nonObjectUnionNestedExcessPropertyCheck.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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" | ||
|
19 changes: 19 additions & 0 deletions
19
tests/cases/compiler/nonObjectUnionNestedExcessPropertyCheck.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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' } }; |