You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the namespace only contains comments, or ends with comments, an error is thrown when namespaces#unwrap is called.
The error thrown is
/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:2253
throw new ManipulationError(sourceFile.getFilePath(), oldFileText, newFileText, message);
^
ManipulationError: Manipulation error: Cannot get the next when at the end of the iterator.
-- Details --
Path: /mnt/c/Workspaces/Experimental/ts-morph-error/test.ts
Text: "class Whatever {}"
Stack: Error: Cannot get the next when at the end of the iterator.
at AdvancedIterator.next (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:39:19)
at UnwrapParentHandler.handleNode (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:1761:97)
at ParentFinderReplacementNodeHandler.handleNode (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:1541:36)
at NodeHandlerHelper.handleForValues (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:1352:21)
at ParentFinderReplacementNodeHandler.handleChildren (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:1414:25)
at ParentFinderReplacementNodeHandler.handleNode (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:1404:18)
at ParentFinderReplacementNodeHandler.handleNode (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:1544:19)
at doManipulation (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:2237:21)
at unwrapNode (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:2644:5)
at NamespaceDeclaration.unwrap (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:9964:13)
at throwError (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:2253:19)
at doManipulation (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:2251:9)
at unwrapNode (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:2644:5)
at NamespaceDeclaration.unwrap (/mnt/c/Workspaces/Experimental/ts-morph-error/node_modules/ts-morph/dist/ts-morph.js:9964:13)
at /mnt/c/Workspaces/Experimental/ts-morph-error/index.js:10:45
at Array.forEach (<anonymous>)
at Object.<anonymous> (/mnt/c/Workspaces/Experimental/ts-morph-error/index.js:10:28)
at Module._compile (internal/modules/cjs/loader.js:1144:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)
at Module.load (internal/modules/cjs/loader.js:993:32) {
filePath: '/mnt/c/Workspaces/Experimental/ts-morph-error/test.ts',
oldText: 'namespace Some {\n' +
' class Whatever {}\n' +
' // Some comment.\n' +
' /* This one too. */\n' +
' }',
newText: 'class Whatever {}'
}
Version: 7.0.2
To Reproduce
import{Project,ts}from"ts-morph";constproject=newProject();constsourceFile=project.createSourceFile("test.ts",`namespace Some { class Whatever {} // Some comment. /* This one too. */ }`);sourceFile.getNamespaces().forEach(ns=>ns.unwrap());
Expected behavior
No error thrown.
The text was updated successfully, but these errors were encountered:
When the namespace only contains comments, or ends with comments, an error is thrown when namespaces#unwrap is called.
The error thrown is
Version: 7.0.2
To Reproduce
Expected behavior
No error thrown.
The text was updated successfully, but these errors were encountered: