Skip to content

Type only import not deleted from result file #9

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

Closed
anion155 opened this issue May 17, 2019 · 4 comments
Closed

Type only import not deleted from result file #9

anion155 opened this issue May 17, 2019 · 4 comments

Comments

@anion155
Copy link
Contributor

anion155 commented May 17, 2019

Import of types error (cyclic import is imported, cause it does breaks functionality):

// a.js
import { B } from '@/b';
import { NotRuntime } from '@/c';

export class A {
    constructor(public name: NotRuntime) {}
}

export const b = new B();
b.print(new A('This is a random name'));

// b.ts
import { A } from '@/a';

export class B {
    print(a: A) {
        console.log(a.name);
    }
}

// c.ts
export type NotRuntime = string;
throw new Error('Should never happen, until `import "@/c"`');

Produces invalid code with circular dependencies. When without paths and this plugin, resulting b.js does not content require('./a.js'), which resolves circular dependency error.

@anion155
Copy link
Contributor Author

@anion155
Copy link
Contributor Author

@danielpza What if node.moduleSpecifier.text = file; instead update? This is fixing issue for import clause at least.

@anion155 anion155 changed the title Type only circular dependencies not deleted Type only import not deleted from result file May 17, 2019
@danielpza
Copy link
Member

If that fixes the problem is fine by me. I'll check the test to make sure everything is fine and deploy a new release.

@anion155
Copy link
Contributor Author

@danielpza It does looks like ts bug, or maybe we have to update some modules cache. I have created thread on ts, will see what ts guru say about this. Meanwhile I'll be looking to this further.

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

2 participants