Skip to content

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

Closed
@sandersn

Description

@sandersn
// @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.

Activity

added this to the TypeScript 2.9 milestone on May 3, 2018
ghost

ghost commented on May 3, 2018

@ghost

@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

sandersn commented on May 3, 2018

@sandersn
MemberAuthor
  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 added
FixedA PR has been merged for this issue
on May 4, 2018
ghost closed this as completedin #23881on May 4, 2018
locked and limited conversation to collaborators on Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @sandersn@mhegazy

      Issue actions

        In JS, typedef rename and find-all-refs doesn't work across files · Issue #23863 · microsoft/TypeScript