Skip to content

In JS, typedef rename and find-all-refs doesn't work across files #23863

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

Closed
sandersn opened this issue May 3, 2018 · 2 comments · Fixed by #23881
Closed

In JS, typedef rename and find-all-refs doesn't work across files #23863

sandersn opened this issue May 3, 2018 · 2 comments · Fixed by #23881
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@sandersn
Copy link
Member

sandersn commented May 3, 2018

// @Filename: mod1.js
module.exports = { e: 1, m: 1 }
/** @typedef {number} Foo */

// @Filename: use.js
/** @type {import('./mod1').Foo} */
var foo = 12

Expected behavior:
Renaming Foo in use.js should rename it. Find-all-refs on Foo in use.js should list all references

Actual behavior:
Neither work. However, goto-def does work.

@mhegazy mhegazy added the Bug A bug in TypeScript label May 3, 2018
@mhegazy mhegazy assigned ghost May 3, 2018
@mhegazy mhegazy added this to the TypeScript 2.9 milestone May 3, 2018
@ghost
Copy link

ghost commented May 3, 2018

@sandersn That example doesn't type-check (and goto-def doesn't work for me): module.exports = { e: number, m: number }; fails because number is not a value, and /** @type {Foo} */ fails because Foo was never imported. Also, I thought a comment that doesn't precede anything was ignored?

@sandersn
Copy link
Member Author

sandersn commented May 3, 2018

  1. Sorry, I typed up the repro based on code in a test buffer. I fixed the type errors.
  2. I observed the problem with import('./mod1').Foo; I don't know if renaming Foo should work for `const mod1 = require('./mod1'); /** @type {mod1.Foo} */. Probably yes?
  3. We have special-case code in the binder for typedef that is supposed to grab every typedef, even at the end of a file. I think they attach to the end of file node or something.

@ghost ghost added the Fixed A PR has been merged for this issue label May 4, 2018
@ghost ghost closed this as completed in #23881 May 4, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants