Skip to content

Provide a quick-fix for non-exported types #37440

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
DanielRosenwasser opened this issue Mar 17, 2020 · 14 comments · Fixed by #51038
Closed

Provide a quick-fix for non-exported types #37440

DanielRosenwasser opened this issue Mar 17, 2020 · 14 comments · Fixed by #51038
Labels
Domain: Quick Fixes Editor-provided fixes, often called code actions. Experience Enhancement Noncontroversial enhancements Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript

Comments

@DanielRosenwasser
Copy link
Member

In #36187, @a-tarasyuk wrote up a handy error message for non-exported types. We should provide a quick fix to add the export modifier for declarations like this that aren't in node_modules and the like.

@DanielRosenwasser DanielRosenwasser added Domain: Quick Fixes Editor-provided fixes, often called code actions. Experience Enhancement Noncontroversial enhancements Good First Issue Well scoped, documented and has the green light Help Wanted You can do this labels Mar 17, 2020
@RyanCavanaugh RyanCavanaugh added the Suggestion An idea for TypeScript label Mar 17, 2020
@AGMETEOR
Copy link
Contributor

@DanielRosenwasser / @RyanCavanaugh I can get time and work on this. Quick question, which files generally have the code for Domain "Quick Fixes"?

@DanielRosenwasser
Copy link
Member Author

It's all in src/services/codefixes/. Make sure you update src/services/tsconfig.json to include the new file for the quick fix. One similar code action would be in fixImplicitThis.ts which adds a this. to foo in

class C {
  foo = 10;
  bar() {
    foo; // oops! needs to be prefixed with `this.`
  }
}

@DanielRosenwasser
Copy link
Member Author

Sorry, I meant fixForgottenThisPropertyAccess.ts!

@AGMETEOR
Copy link
Contributor

Thanks a lot :)

@james-fourth
Copy link

@AGMETEOR Are you still working on this issue? If not, I'm looking for an opportunity to begin contributing. :)

@AGMETEOR
Copy link
Contributor

AGMETEOR commented Apr 5, 2020

@JJPIV yes, I am working on it

@AGMETEOR
Copy link
Contributor

AGMETEOR commented Apr 8, 2020

@JJPIV please take this on if you still want to.

@davidstellini
Copy link

@JJPIV Did you take this? If not I'd like to take a shot :)

@Qiyu8
Copy link

Qiyu8 commented Apr 14, 2020

I'm working on this issue, currently stuck at getting SourceFile object for a.ts, can anybody help me?

// @filename a.ts

declare function foo(): any

declare function bar(): any;

export { bar };

// @filename b.ts

import { foo, bar } from "./a";

@AGMETEOR
Copy link
Contributor

@Qiyu8 I think that information is in the context that's passed to getCodeActions(context: CodeFixContext) in the arg object for registerCodeFix

@Qiyu8
Copy link

Qiyu8 commented Apr 16, 2020

@AGMETEOR Thanks for your advise, would you mind reviewing the code?

@AGMETEOR
Copy link
Contributor

AGMETEOR commented Apr 16, 2020

@Qiyu8 I think @DanielRosenwasser is the one that reviews. I am also still quite a new contributor :)

@BenjaVR
Copy link

BenjaVR commented May 15, 2021

I assume nobody is working on this at the moment? If so, I would like to take a shot @DanielRosenwasser

@DanielRosenwasser
Copy link
Member Author

Thank you @a-tarasyuk!

@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label Oct 13, 2022
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 4.9.2 milestone Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Quick Fixes Editor-provided fixes, often called code actions. Experience Enhancement Noncontroversial enhancements Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
7 participants