-
Notifications
You must be signed in to change notification settings - Fork 12.8k
JSDoc type reference understands require with entity name #34804
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
JSDoc type reference understands require with entity name #34804
Conversation
For example, `require("x").c`. This is the value equivalent of `import("x").a.b.c`, but the syntax tree is not as nicely designed for this purpose. Fixes #34802
note: this needs to be in 3.7 too |
if (isVariableDeclaration(decl) && decl.initializer) { | ||
let expr = decl.initializer; | ||
// skip past entity names, eg `require("x").a.b.c` | ||
while (isPropertyAccessExpression(expr)) { |
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.
What about optional chains?
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.
Those work -- I added a test. I guess they use the same AST as normal property access expressions?
@typescript-bot cherry-pick this to release-3.7 (Not sure this is going to work, this has been a hot spot of bug fixes.) |
Hey @sandersn, I couldn't open a PR with the cherry-pick. (You can check the log here). You may need to squash and pick this PR into release-3.7 manually. |
* resolve require with entity name postfix For example, `require("x").c`. This is the value equivalent of `import("x").a.b.c`, but the syntax tree is not as nicely designed for this purpose. Fixes #34802 * Add bug number to test * Add optional chain test
Thanks for trying, typescript-bot. I cherry-picked the squashed commit manually. |
For example,
require("x").c
. This is the value equivalent ofimport("x").a.b.c
, but the syntax tree is not as nicely designed for this purpose.Fixes #34802