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

removeDefaultImport fails on type only import #1533

Open
forivall opened this issue Apr 26, 2024 · 0 comments
Open

removeDefaultImport fails on type only import #1533

forivall opened this issue Apr 26, 2024 · 0 comments

Comments

@forivall
Copy link

Describe the bug

Version: 20.0.0 (removeDefaultImport is unchanged since this version, so it's still applicable i think)

To Reproduce

import { Project } from "ts-morph";

const project = new Project();
const sourceFile = project.createSourceFile("test.ts", ``);

sourceFile.addImportDeclaration({ moduleSpecifier: 'foo', defaultImport: 'bar', isTypeOnly: true });
const importDeclaration = sourceFile.getImportDeclarations()[0].removeDefaultImport()

// reproduce the problem here
importDeclaration.removeDefaultImport();
> 1 | import type bar from "foo";
    at Object.throwIfNullOrUndefined (node_modules/@ts-morph/common/dist/ts-morph-common.js:438:19)
    at Identifier.getNextSiblingIfKindOrThrow (node_modules/ts-morph/dist/ts-morph.js:3841:30)
    at ImportDeclaration.removeDefaultImport (node_modules/ts-morph/dist/ts-morph.js:12499:57)

Expected behavior

The default import should be removed.

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

No branches or pull requests

1 participant