dsherret / dsherret/ts-morph

fixMissingImports breaks when adding to empty named imports

Open
#613 12 comments 3 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
6.2k
Forks
238
Avg merge
2m
Merged PRs (30d)
1

Description

I'm not sure exactly what happened here, but I had:

```ts
import { } from "../jsx";
```

And that caused this:

```
Error: Cannot get the next when at the end of the iterator.
-- Details --
Path: V:/ts-morph/src/structures/utils/forEachStructureChild.ts
Text: "...dDeclarationStructure, ParameteredNodeStructure, TypeElementMemberedNodeStructure } from \"../base\";\r\nimport { JsxElementStructure, JsxSelfClosingElementStructure, JsxAttributedNodeStructure }{ } from \"../jsx\";\r\nimport { VariableStatementStructure } from \"../statement\";\r\n\r\n// todo: Code generate this...\r\n\r\nexp..."
Stack: Error: Cannot get the next when at the end of the iterator.
at AdvancedIterator.next (V:\ts-morph\node_modules\ts-morph\dist\utils\AdvancedIterator.js:33:19)
at RangeHandler.handleNode (V:\ts-morph\node_modules\ts-morph\dist\manipulation\nodeHandlers\RangeHandler.js:38:78)
at NodeHandlerHelper.handleForValues (V:\ts-morph\node_modules\ts-morph\dist\manipulation\nodeHandlers\NodeHandlerHelper.js:12:21)
at RangeHandler.rangeHandlerReplace (V:\ts-morph\node_modules\ts-morph\dist\manipulation\nodeHandlers\RangeHandler.js:48:21)
at RangeHandler.handleNode (V:\ts-morph\node_modules\ts-morph\dist\manipulation\nodeHandlers\RangeHandler.js:31:18)
at NodeHandlerHelper.handleForValues (V:\ts-morph\node_modules\ts-morph\dist\manipulation\nodeHandlers\NodeHandlerHelper.js:12:21)
at RangeHandler.rangeHandlerReplace (V:\ts-morph\node_modules\ts-morph\dist\manipulation\nodeHandlers\RangeHandler.js:48:21)
at RangeHandler.handleNode (V:\ts-morph\node_modules\ts-morph\dist\manipulation\nodeHandlers\RangeHandler.js:31:18)
at Object.doManipulation (V:\ts-morph\node_modules\ts-morph\dist\manipulation\manipulations\doManipulation.js:9:21)
at Object.insertIntoTextRange (V:\ts-morph\node_modules\ts-morph\dist\manipulation\manipulations\insertion.js:34:22)
at Object.doManipulation (V:\ts-morph\node_modules\ts-morph\dist\manipulation\manipulations\doManipulation.js:12:15)
at Object.insertIntoTextRange (V:\ts-morph\node_modules\ts-morph\dist\manipulation\manipulations\insertion.js:34:22)
at applyTextChanges (V:\ts-morph\node_modules\ts-morph\dist\compiler\ast\module\SourceFile.js:656:32)
at SourceFile.fixMissingImports (V:\ts-morph\node_modules\ts-morph\dist\compiler\ast\module\SourceFile.js:636:13)
at Object.createForEachStructureChild (V:\ts-morph\scripts\generation\createForEachStructureChild.ts:29:31)
at Object. (V:\ts-morph\scripts\generation\main.ts:46:9)
at Generator.next ()
at V:\ts-morph\scripts\generation\main.ts:7:71
at new Promise ()
at __awaiter (V:\ts-morph\scripts\generation\main.ts:3:12)
```

Kind of looks like that might be a bug in the compiler though.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.