-
Notifications
You must be signed in to change notification settings - Fork 13k
Enhance type argument completions #62170
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
+402
−13
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e81dac9
Make `getTypeArgumentConstraint` work for type arguments of expressions
mkantor a3de49b
Suggest completions of property values in type arguments
mkantor e253963
Suggest completions within string literals in type arguments
mkantor 27890ac
Suggest completions within tuple type arguments
mkantor 79f53bd
Use `hasTypeArguments` in `getTypeArgumentConstraint`
mkantor d3e5ece
Rename `getSignaturesFromCallLike` to `getUninstantiatedSignatures`
mkantor 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
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
38 changes: 38 additions & 0 deletions
38
tests/cases/fourslash/completionListInTypeLiteralInTypeParameter10.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,38 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
////interface Foo { | ||
//// one: string; | ||
//// two: number; | ||
////} | ||
////interface Bar { | ||
//// three: boolean; | ||
//// four: { | ||
//// five: unknown; | ||
//// }; | ||
////} | ||
//// | ||
////function a<T extends Foo>() {} | ||
////a<{/*0*/}>(); | ||
//// | ||
////var b = () => <T extends Foo>() => {}; | ||
////b()<{/*1*/}>(); | ||
//// | ||
////declare function c<T extends Foo>(): void | ||
////declare function c<T extends Bar>(): void | ||
////c<{/*2*/}>(); | ||
//// | ||
////function d<T extends Foo, U extends Bar>() {} | ||
////d<{/*3*/}, {/*4*/}>(); | ||
////d<Foo, { four: {/*5*/} }>(); | ||
//// | ||
////(<T extends Foo>() => {})<{/*6*/}>(); | ||
|
||
verify.completions( | ||
{ marker: "0", unsorted: ["one", "two"], isNewIdentifierLocation: true }, | ||
{ marker: "1", unsorted: ["one", "two"], isNewIdentifierLocation: true }, | ||
{ marker: "2", unsorted: ["one", "two", "three", "four"], isNewIdentifierLocation: true }, | ||
{ marker: "3", unsorted: ["one", "two"], isNewIdentifierLocation: true }, | ||
{ marker: "4", unsorted: ["three", "four"], isNewIdentifierLocation: true }, | ||
{ marker: "5", unsorted: ["five"], isNewIdentifierLocation: true }, | ||
{ marker: "6", unsorted: ["one", "two"], isNewIdentifierLocation: true }, | ||
); |
32 changes: 32 additions & 0 deletions
32
tests/cases/fourslash/completionListInTypeLiteralInTypeParameter11.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,32 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
////interface Foo { | ||
//// one: string; | ||
//// two: number; | ||
////} | ||
////interface Bar { | ||
//// three: boolean; | ||
//// four: symbol; | ||
////} | ||
//// | ||
////class A<T extends Foo> {} | ||
////new A<{/*0*/}>(); | ||
//// | ||
////class B<T extends Foo, U extends Bar> {} | ||
////new B<{/*1*/}, {/*2*/}>(); | ||
//// | ||
////declare const C: { | ||
//// new <T extends Foo>(): unknown | ||
//// new <T extends Bar>(): unknown | ||
////} | ||
////new C<{/*3*/}>() | ||
//// | ||
////new (class <T extends Foo> {})<{/*4*/}>(); | ||
|
||
verify.completions( | ||
{ marker: "0", unsorted: ["one", "two"], isNewIdentifierLocation: true }, | ||
{ marker: "1", unsorted: ["one", "two"], isNewIdentifierLocation: true }, | ||
{ marker: "2", unsorted: ["three", "four"], isNewIdentifierLocation: true }, | ||
{ marker: "3", unsorted: ["one", "two", "three", "four"], isNewIdentifierLocation: true }, | ||
{ marker: "4", unsorted: ["one", "two"], isNewIdentifierLocation: true }, | ||
); |
25 changes: 25 additions & 0 deletions
25
tests/cases/fourslash/completionListInTypeLiteralInTypeParameter12.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,25 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
////interface Foo { | ||
//// kind: 'foo'; | ||
//// one: string; | ||
////} | ||
////interface Bar { | ||
//// kind: 'bar'; | ||
//// two: number; | ||
////} | ||
//// | ||
////declare function a<T extends Foo>(): void | ||
////declare function a<T extends Bar>(): void | ||
////a<{ kind: 'bar', /*0*/ }>(); | ||
//// | ||
////declare function b<T extends Foo>(kind: 'foo'): void | ||
////declare function b<T extends Bar>(kind: 'bar'): void | ||
////b<{/*1*/}>('bar'); | ||
|
||
// The completion lists are unfortunately not narrowed here (ideally only | ||
// properties of `Bar` would be suggested). | ||
verify.completions( | ||
{ marker: "0", unsorted: ["one", "two"], isNewIdentifierLocation: true }, | ||
{ marker: "1", unsorted: ["kind", "one", "two"], isNewIdentifierLocation: true }, | ||
); |
18 changes: 18 additions & 0 deletions
18
tests/cases/fourslash/completionListInTypeLiteralInTypeParameter13.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,18 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @jsx: preserve | ||
// @filename: a.tsx | ||
////interface Foo { | ||
//// one: string; | ||
//// two: number; | ||
////} | ||
//// | ||
////const Component = <T extends Foo>() => <></>; | ||
//// | ||
////<Component<{/*0*/}>></Component>; | ||
////<Component<{/*1*/}>/>; | ||
|
||
verify.completions( | ||
{ marker: "0", unsorted: ["one", "two"], isNewIdentifierLocation: true }, | ||
{ marker: "1", unsorted: ["one", "two"], isNewIdentifierLocation: true }, | ||
); |
10 changes: 10 additions & 0 deletions
10
tests/cases/fourslash/completionListInTypeLiteralInTypeParameter14.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,10 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
////interface Foo { | ||
//// one: string; | ||
//// two: number; | ||
////} | ||
////declare function f<T extends Foo>(x: TemplateStringsArray): void; | ||
////f<{/*0*/}>``; | ||
|
||
verify.completions({ marker: "0", unsorted: ["one", "two"], isNewIdentifierLocation: true }); |
15 changes: 15 additions & 0 deletions
15
tests/cases/fourslash/completionListInTypeLiteralInTypeParameter15.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,15 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
////interface Foo { | ||
//// one: string; | ||
//// two: number; | ||
////} | ||
//// | ||
////declare function decorator<T extends Foo>(originalMethod: unknown, _context: unknown): never | ||
//// | ||
////class { | ||
//// @decorator<{/*0*/}> | ||
//// method() {} | ||
////} | ||
|
||
verify.completions({ marker: "0", unsorted: ["one", "two"], isNewIdentifierLocation: true }); |
Oops, something went wrong.
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.