-
Notifications
You must be signed in to change notification settings - Fork 12.9k
go-to-type-definition, and find-all-refs should work for import.meta #44364
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 all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e8d59b1
go-to-type-definition, and find-all-refs should work for import.meta
Zzzen 1e99298
search `meta` instead of `import.meta`
Zzzen 89101bb
Merge remote-tracking branch 'origin/main' into meta-prop-misc
Zzzen a7b9dd6
remove `definition`
Zzzen 6fa2684
fix compilation error
Zzzen ef09426
update baseline
Zzzen c0ef5d9
revert definition
Zzzen 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
61 changes: 61 additions & 0 deletions
61
tests/baselines/reference/findAllRefsImportMeta.baseline.jsonc
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,61 @@ | ||
// === /tests/cases/fourslash/foo.ts === | ||
// /// <reference no-default-lib="true"/> | ||
// /// <reference path='./bar.d.ts' /> | ||
// import./*FIND ALL REFS*/[|meta|]; | ||
// import.[|meta|]; | ||
|
||
// === /tests/cases/fourslash/baz.ts === | ||
// /// <reference no-default-lib="true"/> | ||
// /// <reference path='./bar.d.ts' /> | ||
// let x = import | ||
// . // hai :) | ||
// [|meta|]; | ||
|
||
[ | ||
{ | ||
"definition": { | ||
"containerKind": "", | ||
"containerName": "", | ||
"fileName": "/tests/cases/fourslash/foo.ts", | ||
"kind": "keyword", | ||
"textSpan": { | ||
"start": 82, | ||
"length": 4 | ||
}, | ||
"displayParts": [ | ||
{ | ||
"kind": "keyword" | ||
} | ||
] | ||
}, | ||
"references": [ | ||
{ | ||
"textSpan": { | ||
"start": 82, | ||
"length": 4 | ||
}, | ||
"fileName": "/tests/cases/fourslash/foo.ts", | ||
"isWriteAccess": false, | ||
"isDefinition": false | ||
}, | ||
{ | ||
"textSpan": { | ||
"start": 95, | ||
"length": 4 | ||
}, | ||
"fileName": "/tests/cases/fourslash/foo.ts", | ||
"isWriteAccess": false, | ||
"isDefinition": false | ||
}, | ||
{ | ||
"textSpan": { | ||
"start": 109, | ||
"length": 4 | ||
}, | ||
"fileName": "/tests/cases/fourslash/baz.ts", | ||
"isWriteAccess": false, | ||
"isDefinition": false | ||
} | ||
] | ||
} | ||
] |
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,41 @@ | ||
[ | ||
{ | ||
"marker": { | ||
"fileName": "/tests/cases/fourslash/foo.ts", | ||
"position": 77, | ||
"name": "1" | ||
}, | ||
"quickInfo": { | ||
"kind": "", | ||
"kindModifiers": "", | ||
"textSpan": { | ||
"start": 75, | ||
"length": 6 | ||
}, | ||
"displayParts": [], | ||
"documentation": [] | ||
} | ||
}, | ||
{ | ||
"marker": { | ||
"fileName": "/tests/cases/fourslash/foo.ts", | ||
"position": 84, | ||
"name": "2" | ||
}, | ||
"quickInfo": { | ||
"kind": "interface", | ||
"kindModifiers": "declare", | ||
"textSpan": { | ||
"start": 75, | ||
"length": 11 | ||
}, | ||
"displayParts": [], | ||
"documentation": [ | ||
{ | ||
"text": "The type of `import.meta`.\n\nIf you need to declare that a given property exists on `import.meta`,\nthis type may be augmented via interface merging.", | ||
"kind": "text" | ||
} | ||
] | ||
} | ||
} | ||
] |
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,26 @@ | ||
// @noLib: true | ||
|
||
/// <reference path='fourslash.ts'/> | ||
|
||
// @module: esnext | ||
// @Filename: foo.ts | ||
/////// <reference no-default-lib="true"/> | ||
/////// <reference path='./bar.d.ts' /> | ||
////import./**/meta; | ||
////import.[|meta|]; | ||
|
||
//@Filename: bar.d.ts | ||
////interface ImportMeta { | ||
////} | ||
|
||
// @Filename: baz.ts | ||
/////// <reference no-default-lib="true"/> | ||
/////// <reference path='./bar.d.ts' /> | ||
////let x = import | ||
//// . // hai :) | ||
//// meta; | ||
|
||
verify.baselineFindAllReferences(""); | ||
|
||
goTo.rangeStart(test.ranges()[0]); | ||
verify.renameInfoFailed(); |
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,13 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
// @module: esnext | ||
// @Filename: foo.ts | ||
/////// <reference no-default-lib="true"/> | ||
/////// <reference path='./bar.d.ts' /> | ||
////import.me/*reference*/ta; | ||
|
||
//@Filename: bar.d.ts | ||
////interface ImportMeta { | ||
////} | ||
|
||
verify.goToDefinition("reference", []); |
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,13 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
// @module: esnext | ||
// @Filename: foo.ts | ||
/////// <reference no-default-lib="true"/> | ||
/////// <reference path='./bar.d.ts' /> | ||
////import.me/*reference*/ta; | ||
|
||
//@Filename: bar.d.ts | ||
////interface /*definition*/ImportMeta { | ||
////} | ||
|
||
verify.goToType("reference", "definition"); |
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,19 @@ | ||
///<reference path="fourslash.ts" /> | ||
|
||
// @module: esnext | ||
// @Filename: foo.ts | ||
/////// <reference no-default-lib="true"/> | ||
/////// <reference path='./bar.d.ts' /> | ||
////im/*1*/port.me/*2*/ta; | ||
|
||
//@Filename: bar.d.ts | ||
/////** | ||
//// * The type of `import.meta`. | ||
//// * | ||
//// * If you need to declare that a given property exists on `import.meta`, | ||
//// * this type may be augmented via interface merging. | ||
//// */ | ||
//// interface ImportMeta { | ||
////} | ||
|
||
verify.baselineQuickInfo() |
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.
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.
I don't exactly know if you should be considering anything a "definition" location apart from the global
ImportMeta
interface.Even that one is a little weird, because that's what you'd want if you requested "go-to-type", not necessarily "go-to-definition".
Do all responses require a
definition
? @jessetrinity and @andrewbranch might have more knowledge here.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.
The types imply that a definition isn’t required. My intuition is that this shouldn’t be one.
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.
It's copied from
getAllReferencesForKeyword
, which searches primitive types likestring/number/any
. They should have no definition either?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.
I’m not 100% sure what the implications are for removing it—we should check with @mjbvz ad @uniqueiniquity.
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.
Let’s get rid of the
definition
Uh oh!
There was an error while loading. Please reload this page.
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.
findReferencedSymbols
won't work ifdefinition
is absent.TypeScript/src/services/findAllReferences.ts
Lines 207 to 219 in 29c7ae2
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.
🤦 I swear all this stuff was just made up on the spot