Skip to content

Use auto-imports for isolatedDeclarations fixes#4422

Open
DanielRosenwasser wants to merge 2 commits into
mainfrom
isolatedDeclarationsFixesWithNewImports
Open

Use auto-imports for isolatedDeclarations fixes#4422
DanielRosenwasser wants to merge 2 commits into
mainfrom
isolatedDeclarationsFixesWithNewImports

Conversation

@DanielRosenwasser

Copy link
Copy Markdown
Member

Fixes #4411.

Copilot AI review requested due to automatic review settings June 23, 2026 21:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the isolatedDeclarations “missing type annotation on exports” code fix to use the auto-import system so that the fix can add required imports (including import type) when the inferred annotation references types from files that aren’t currently imported (Fixes #4411).

Changes:

  • Wire autoimport.ImportAdder into the isolated-declarations type annotation fixer and include its edits in produced code actions (single-fix and fix-all).
  • Propagate createImportAdder/auto-import preparation errors through the code action pipeline.
  • Add a new fourslash regression test covering annotation + auto-import when the type originates in an unimported file.
Show a summary per file
File Description
internal/ls/codeactions_fixmissingtypeannotation.go Use ImportAdder to add imports for synthesized types during isolatedDeclarations annotation fixes.
internal/fourslash/tests/codeFixMissingTypeAnnotationOnExportsUsingTypeFromUnimportedFile_test.go Regression test ensuring the fix adds a type annotation and a new import type when needed.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment on lines 1217 to +1221
referenceTypeNode, importableSymbols := autoimport.TryGetAutoImportableReferenceFromTypeNode(typeNode, idToSymbol)
if referenceTypeNode != nil {
typeNode = referenceTypeNode
f.symbolsToImport = append(f.symbolsToImport, importableSymbols...)
if f.importAdder != nil {
for _, symbol := range importableSymbols {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

isolatedDeclarations quick-fix cannot consistently use auto-imports

2 participants