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

namespace unwrap error #735

Closed
noriokaki opened this issue Oct 16, 2019 · 2 comments
Closed

namespace unwrap error #735

noriokaki opened this issue Oct 16, 2019 · 2 comments
Labels

Comments

@noriokaki
Copy link

Describe the bug

Version: 4.2.0
Crash when use namespace#unwrap() method.

To Reproduce

import { Project } from "ts-morph";
const project = new Project();
const source = project.createSourceFile(
    "./sample.ts",
    "//  aaaa bbbb \n namespace Foo {\n\texport class Bar {\n \t\tconstructor(){}\n \t\tsayHello(){return 'hello';}\n\t}\n}",
    { overwrite: true },
);
source.saveSync();
source.getNamespaces().forEach(ns => ns.unwrap());

Expected behavior
input

//  aaaa bbbb 
 namespace Foo {
	export class Bar {
 		constructor(){}
 		sayHello(){return 'hello';}
	}
}

expect

//  aaaa bbbb 
export class Bar {
 	constructor(){}
 	sayHello(){return 'hello';}
}

actual
Error: Manipulation error: Cannot get the next when at the end of the iterator.

@dsherret dsherret added the bug label Oct 16, 2019
@dsherret
Copy link
Owner

Thanks! Looks like I'm accidentally using position rather than getStart(true): https://github.com/dsherret/ts-morph/blob/d15ef55c9fbadefa34857d99335798b09a4ec561/src/manipulation/textManipulators/UnwrapTextManipulator.ts

@dsherret
Copy link
Owner

Fixed in 4.3.0 (released).

@dsherret dsherret changed the title namespace unrap error namespace unwrap error Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants