-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Lanugage Service support for union types #861
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
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b8923b3
Support symbol kind for union properties
mhegazy 5669f63
add test for quick info
mhegazy c439ae4
Add support for union properties in goto def
mhegazy 779db6e
Support find all refs on union properties
mhegazy 2eb51ab
Use getRootSymbols for all union property needs
mhegazy dc43e83
Merge branch 'unionTypes' into unionTypesLS
mhegazy 927f04f
Fix contextually typed object literal proeprties that are not propert…
mhegazy 9f43ac0
respond to code review remarks
mhegazy f5a9fee
ensure unionProperty symbols have declarations set at creation time
mhegazy 2ce627c
Handle union properties completions on apparant types
mhegazy 4442b45
Add a temporary fix to quick info
mhegazy 04e5309
Merge branch 'unionTypes' into unionTypesLS
mhegazy 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
Support find all refs on union properties
- Loading branch information
commit 779db6e76a8b117e2b12a8b6b0df72fb73411b12
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
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
40 changes: 40 additions & 0 deletions
40
tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts
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,40 @@ | ||
/// <reference path='fourslash.ts'/> | ||
|
||
////interface A { | ||
//// a: number; | ||
//// common: string; | ||
////} | ||
//// | ||
////interface B { | ||
//// b: number; | ||
//// common: number; | ||
////} | ||
//// | ||
////// Assignment | ||
////var v1: A | B = { a: 0, /*1*/common: "" }; | ||
////var v2: A | B = { b: 0, /*2*/common: 3 }; | ||
//// | ||
////// Function call | ||
////function consumer(f: A | B) { } | ||
////consumer({ a: 0, b: 0, /*3*/common: 1 }); | ||
//// | ||
////// Type cast | ||
////var c = <A | B> { /*4*/common: 0, b: 0 }; | ||
//// | ||
////// Array literal | ||
////var ar: Array<A|B> = [{ a: 0, /*5*/common: "" }, { b: 0, /*6*/common: 0 }]; | ||
//// | ||
////// Nested object literal | ||
////var ob: { aorb: A|B } = { aorb: { b: 0, /*7*/common: 0 } }; | ||
//// | ||
////// Widened type | ||
////var w: A|B = { a:0, /*8*/common: undefined }; | ||
//// | ||
////// Untped -- should not be included | ||
////var u1 = { a: 0, b: 0, common: "" }; | ||
////var u2 = { b: 0, common: 0 }; | ||
|
||
test.markers().forEach((m) => { | ||
goTo.position(m.position, m.fileName); | ||
verify.referencesCountIs(10); // 8 contextually typed common, and 2 in definition (A.common, B.common) | ||
}); |
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
Or 86F9 iginal file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/// <reference path='fourslash.ts'/> | ||
|
||
////interface One { | ||
//// common: { /*1*/a: number; }; | ||
////} | ||
//// | ||
////interface Base { | ||
//// /*2*/a: string; | ||
//// b: string; | ||
////} | ||
//// | ||
////interface HasAOrB extends Base { | ||
//// /*3*/a: string; | ||
//// b: string; | ||
////} | ||
//// | ||
////interface Two { | ||
//// common: HasAOrB; | ||
////} | ||
//// | ||
////var x : One | Two; | ||
//// | ||
////x.common./*4*/a; | ||
|
||
goTo.marker("1"); | ||
verify.referencesCountIs(2); // One.common.a, x.common.a | ||
|
||
goTo.marker("2"); | ||
verify.referencesCountIs(3); // Base.a, HasAOrB.a, x.common.a | ||
|
||
goTo.marker("3"); | ||
verify.referencesCountIs(3); // Base.a, HasAOrB.a, x.common.a | ||
|
||
goTo.marker("4"); | ||
verify.referencesCountIs(4); // One.common.a, Base.a, HasAOrB.a, x.common.a |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done