-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Support 'find references' on most declaration-related keywords #36490
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
Conversation
I've moved the logic out of checker and into services in a |
@sheetalkamat do you have any further feedback? |
This seems needlessly inconsistent. I don’t like this as it means if I delete X from the second import, the behavior of Find References suddenly changes. Either both cases should find refs for |
@fatcerberus that's an interesting point. @DanielRosenwasser do you have any preference here? |
I think it's often nice to have something just do the only possible successful action. We can change this later if people do find it confusing. |
I'll create a PR for this change shortly. |
I've put up a PR with the following changes:
|
This change lets "find references" requests to the server find references to a declaration when the cursor is on certain keywords:
public
,private
,protected
,static
,readonly
,abstract
,declare
,export
, andconst
(enums)) will find references to the declaration they modify.class
,interface
,type
(type aliases),enum
,module
,namespace
,function
,get
(get accessors), andset
(set accessors)) will find references to the declaration they declare.extends
,implements
) in aclass
/interface
declaration will find references to the type in the heritage clause, as long as that clause has only one type (as more than one type would be ambiguous).const
,let
,var
) will find references to the variable declared if declaration list contains a single declaration.import
import "module"
will find references tomodule
import X from "module"
will find references toX
(if there are no named bindings)import * as X from "module"
will find references toX
import { X } from "module"
will find references toX
(if there is no default binding and only one named binding)import { X, Y } from "module"
will find references tomodule
(since it would be ambiguous betweenX
andY
).import X = Y
will find references toX
import X = require("module")
will find references toX
export
export * from "module"
will find references tomodule
export * as X from "module"
will find references toX
export { X } from "module"
will find references toX
(if there is only one named binding)export { X }
will find references toX
(if there is only one named binding)export = X
will find references toX
export default X
will find references toX
as
import * as X from "module"
will find references toX
import { Y as X } from "module"
will find references toX
export * as X from "module"
will find references toX
export { Y as X } from "module"
will find references toX
export { Y as X }
will find references toX
from
import ... from "module"
will find references tomodule
export ... from "module"
will find references tomodule
require
(in animport=
declaration)import X = require("module")
will find references tomodule
type
(in animport
/export
declaration) has the same behavior asimport
orexport
(above), where applicable.new
,void
,typeof
,delete
,yield
,await
) will find references to the declaration referenced in the operand (as long as the operand is an identifier or property access).in
,instanceof
,as
) will find references to the declaration on the right.extends
in<T extends U>
(type parameter list) will find references toU
extends
inT extends U ? A : B
(conditional type) will find references toU
infer
inT extends infer U ? A : B
(conditional type) will find references toU
in
in{ [P in K]: T }
(mapped type) will find references toP
keyof
inkeyof T
will find references toT
readonly
inreadonly T[]
will find references toT
(not supported on tuple types)I've also updated
runCode
in our fourslash tests so that errors are reported at the source location in the test file (using source maps), and so that you can step through the ts file when debugging.Fixes #13309
Fixes #28268