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

feature request : add a " add all missing import " method in LanguageService #518

Closed
WanderWang opened this issue Dec 24, 2018 · 5 comments

Comments

@WanderWang
Copy link

Is your feature request related to a problem? Please describe.

I want to convert a big size typescript library from " global-variable-based " to ES6 modules

Here is a example :

from:

//a.ts
class A {
    public b:B;
}

//b.ts
class B {
}

to :

// a.ts
import { B } from ".b";
class A {
    public b:B;
}

//b.ts

export class B {
}

First step , I have added a export keyword with all classes , It works now .

Second step , I need to " add all missing import " ( such as manual in vscode ) programmicly , but failed .

Describe the solution you'd like

Please add a " add all missing import " method on LanguageService ,such as languageService.orginazeImports

Thanks you

@dsherret
Copy link
Owner

dsherret commented Jan 6, 2019

This will be in version 21. Hopefully will release later today (Edit: Nevermind. Want to get #522 in)

@dsherret dsherret closed this as completed Jan 6, 2019
@dsherret
Copy link
Owner

dsherret commented Jan 6, 2019

By the way, this is done using #getCombinedCodeFix() on the language service, but is available as a simple method call on the source file like so: sourceFile.fixMissingImports() (similar to sourceFile.organizeImports())

@dsherret dsherret added this to the Version 21 milestone Jan 7, 2019
@WanderWang
Copy link
Author

WanderWang commented Jan 7, 2019

great jobs ! could you publish a tag ( such as ts-simple-ast@next ) in npm before you release version21 ?

I have forked the repo and build a local library for my hot fix now .

@dsherret
Copy link
Owner

dsherret commented Jan 8, 2019

@WanderWang cool! By the way, I just updated the declaration file in the dev branch... I forgot to do that earlier.

Yeah, that's the way to go. In the future I'll probably have a @next version, but not at the moment.

@WanderWang
Copy link
Author

WanderWang commented Jan 8, 2019

Thanks for your hard working in ts-simple-ast again ! . This feature saved me tens of hours 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants