-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Perform excess property checking on intersection and union members #30853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
weswigham
merged 8 commits into
microsoft:master
from
weswigham:fix-intersection-target-excess-props-checks
Apr 17, 2019
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b3f9bc0
Perform excess property checking on intersection and union members
weswigham 667329d
Allow partial union props to contain the undefined type
weswigham ac0af46
Add test case from #30771
weswigham f87ba3f
Un-terse getPossiblePropertiesOfUnionType side-effecting code
weswigham 8dd510b
Fix bug exposed in RWC
weswigham 7a4761c
Cache results of getPossiblePropertiesOfUnionType
weswigham b7f9326
Fix whitespace
weswigham f54e5ab
Merge branch 'master' into fix-intersection-target-excess-props-checks
weswigham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
48 changes: 48 additions & 0 deletions
48
tests/baselines/reference/deepExcessPropertyCheckingWhenTargetIsIntersection.errors.txt
This file contains hidden or 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,48 @@ | ||
tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts(21,33): error TS2322: Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'. | ||
Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'. | ||
tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts(27,34): error TS2326: Types of property 'icon' are incompatible. | ||
Type '{ props: { INVALID_PROP_NAME: string; ariaLabel: string; }; }' is not assignable to type 'NestedProp<ITestProps>'. | ||
Types of property 'props' are incompatible. | ||
Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'. | ||
Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'. | ||
|
||
|
||
==== tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts (2 errors) ==== | ||
interface StatelessComponent<P = {}> { | ||
(props: P & { children?: number }, context?: any): null; | ||
} | ||
|
||
const TestComponent: StatelessComponent<TestProps> = (props) => { | ||
return null; | ||
} | ||
|
||
interface ITestProps { | ||
ariaLabel?: string; | ||
} | ||
|
||
interface NestedProp<TProps> { | ||
props: TProps; | ||
} | ||
|
||
interface TestProps { | ||
icon: NestedProp<ITestProps>; | ||
} | ||
|
||
TestComponent({icon: { props: { INVALID_PROP_NAME: 'share', ariaLabel: 'test label' } }}); | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2322: Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'. | ||
!!! error TS2322: Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'. | ||
!!! related TS6500 tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts:14:3: The expected type comes from property 'props' which is declared here on type 'NestedProp<ITestProps>' | ||
|
||
const TestComponent2: StatelessComponent<TestProps | {props2: {x: number}}> = (props) => { | ||
return null; | ||
} | ||
|
||
TestComponent2({icon: { props: { INVALID_PROP_NAME: 'share', ariaLabel: 'test label' } }}); | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2326: Types of property 'icon' are incompatible. | ||
!!! error TS2326: Type '{ props: { INVALID_PROP_NAME: string; ariaLabel: string; }; }' is not assignable to type 'NestedProp<ITestProps>'. | ||
!!! error TS2326: Types of property 'props' are incompatible. | ||
!!! error TS2326: Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'. | ||
!!! error TS2326: Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.