We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
organizeImports
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
When calling sourceFile.organizeImports(), all imports are removed, even those that might be necessary.
sourceFile.organizeImports()
import { Project, SourceFile } from 'ts-morph'; console.clear(); const project = new Project({ useInMemoryFileSystem: true, compilerOptions: { strict: true, target: 3, // ES2015 }, skipFileDependencyResolution: true, }); const sourceText = ` import { Unused } from 'unused-module'; class MyComponent { property: string = "hello"; method() { console.log(property); } } `; const sourceFile = project.createSourceFile('MyComponent.ts', sourceText); sourceFile.organizeImports(); console.log(sourceFile.getFullText());
Only unused imports should be removed, while necessary imports should be retained.
All imports are removed, even if they might be needed.
[StackBlitz Example](https://stackblitz.com/edit/vitejs-vite-nqlj93qx?file=src%2Fmain.ts)
This issue might be related to skipFileDependencyResolution: true, but even with it set to false, the problem persists.
skipFileDependencyResolution: true
false
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description
When calling
sourceFile.organizeImports()
, all imports are removed, even those that might be necessary.Reproduction
Expected Behavior
Only unused imports should be removed, while necessary imports should be retained.
Actual Behavior
All imports are removed, even if they might be needed.
StackBlitz Reproduction
[StackBlitz Example](https://stackblitz.com/edit/vitejs-vite-nqlj93qx?file=src%2Fmain.ts)
Environment
Additional Context
This issue might be related to
skipFileDependencyResolution: true
, but even with it set tofalse
, the problem persists.The text was updated successfully, but these errors were encountered: