Skip to content
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

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

Closed
Jessidhia opened this issue Oct 12, 2017 · 3 comments
Closed
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@Jessidhia
Copy link

Jessidhia commented Oct 12, 2017

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.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 12, 2017

default should get you the references..

animation

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Oct 12, 2017
@Jessidhia
Copy link
Author

Jessidhia commented Oct 17, 2017

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.

@mhegazy mhegazy added Bug A bug in TypeScript and removed Needs More Info The issue still hasn't been fully clarified labels Oct 17, 2017
@mhegazy mhegazy assigned ghost Oct 17, 2017
@mhegazy mhegazy added this to the TypeScript 2.7 milestone Oct 17, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Oct 17, 2017

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

export default 1;

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Oct 18, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
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

No branches or pull requests

2 participants