Skip to content

Import hints not working when using export default after class definition #19115

Closed

Description

@mjbvz

From Lucjan Suski (@methyl) on October 10, 2017 7:25

  • VSCode Version: 1.17.0
  • OS Version: Arch Linux

Steps to Reproduce:

  1. Open a JS project with jsconfig.json having checkJs: true in compilerOptions
  2. Create a test.js with following content:
class Test {}
export default Test
  1. Create a test2.js with following content:
class Test2 extends Test {}

Actual behavior:

  • No lightbulb with hint to import Test from './test appear.

Correct behavior

  • Lightbulb with hint to import Test from './test appear, just like when test.js have export default inlined:
export default class Test {}

Copied from original issue: microsoft/vscode#35966

Activity

  1. removed their assignment
    on Oct 11, 2017
  2. mjbvz commented on Oct 11, 2017

    @mjbvz
    ContributorAuthor

    Confirmed this happens with TypeScript 2.5.3 and 2.6.0-20171011

  3. added
    Domain: LS: Quick Fixes
    on Oct 11, 2017
  4. amcasey commented on Jan 3, 2018

    @amcasey
    Member

    isExportDefaultSymbol is returning false because the declaration has no default modifier.

  5. amcasey commented on Jan 4, 2018

    @amcasey
    Member

    Related case: export { Test as default };

  6. amcasey commented on Jan 4, 2018

    @amcasey
    Member

    Andy (Andrewkraft) (@Andy-MS), I'm told you've been working in this area and might have some thoughts on what these default export helpers should do (i.e. how to divide the fix between the compiler and the services).

  7. amcasey commented on Jan 4, 2018

    @amcasey
    Member

    Here's a hackish solution to the cases we've identified so far. https://github.com/amcasey/TypeScript/tree/Scratch19115

  8. amcasey commented on Jan 4, 2018

    @amcasey
    Member

    I see four other callers to getLocalSymbolForExportDefault and they basically all just want the local name of the default export. Possibly a helper returning that value is in order.

  9. amcasey commented on Jan 4, 2018

    @amcasey
    Member

    Andy (Andrewkraft) (@Andy-MS) so don't update the other callers?

  10. amcasey commented on Jan 4, 2018

    @amcasey
    Member

    The change in findAllReferences.ts broke some tests. I'm still investigating. The failures looked like regressions, which makes me think that we might want to go the other way and pull out the default-export handling that's already there (because it's not clear why that one form would be special).

  11. amcasey commented on Jan 4, 2018

    @amcasey
    Member

    As far as I can tell, the occurrence in services/utilities.ts doesn't matter - it's only used by rename and you can't rename default.

  12. amcasey commented on Jan 4, 2018

    @amcasey
    Member

    For findAllReferences, I tested all three implementations (current, special case all default exports, special case no default exports) against all three types of default exports and the current implementation had the best behavior. Presumably, this means that the other two types of default exports (i.e. not handled by getLocalSymbolForExportDefault) are handled downstream.

  13. added a commit that references this issue on Jan 4, 2018
    ff58f1f
  14. added
    Fixed
    on Jan 8, 2018
  15. methyl commented on Jan 9, 2018

    @methyl

    Thanks a lot Andrew Casey (@amcasey), excellent work!

  16. locked and limited conversation to collaborators on Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugDomain: LS: Quick FixesFixed

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions