Skip to content

Not possible to find-all-references for export default of anonymous type #19122

Closed

Description

TypeScript Version: 2.5.3

Code

export default function () {}

Expected behavior:

It is possible, somehow, to Find all references of the exported anonymous function declaration.

Actual behavior:

It is not possible to Find all references through any means other than temporarily giving the function declaration a name; or to import it from somewhere else and try to Find all references of the imported value.

This also affects anonymous classes and anonymous expression results.


In this case, the best case behavior would be that asking to Find all references of the default token in export default would find the references to the default export.

Activity

  1. mhegazy commented on Oct 12, 2017

    @mhegazy
    Contributor

    default should get you the references..

    animation

  2. Jessidhia commented on Oct 17, 2017

    @Jessidhia
    Author

    I happened to reproduce it now in my project but not with an anonymous function, but an anonymous expression.

    Not possible to find all references:

    export default connect(mapStateToProps, mapDispatchToProps)(Component)

    Possible to find all references by searching for references to default:

    const x = connect(mapStateToProps, mapDispatchToProps)(Component)
    export { x as default }

    Note that searching for references to the x variable does not report things that import it, even though it is an aliased live-binding export. Only looking for references to default return users of the component.

    In either case, it's not possible to find them with the export default connect(...)(...) expression. Searching for references to Component does happen to find things importing it, but the use is indirect and incidental (only its type is used, as part of the return type of connect()()).

    This was tested with 2.5.3 as I have not been able to update to 2.6.0 yet.

    My project is strict, isolatedModules, with allowSyntheticDefaultExports and module: esnext.

  3. added
    BugA bug in TypeScript
    and removed
    Needs More InfoThe issue still hasn't been fully clarified
    on Oct 17, 2017
  4. mhegazy commented on Oct 17, 2017

    @mhegazy
    Contributor

    I see. thanks for the repro. here is a simpler repro:

    export default 1;
  5. locked and limited conversation to collaborators on Jun 14, 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

      No branches or pull requests

      Issue actions