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

doesn't work as intended when using export * from "./abc" statement #286

Open
demonhue opened this issue Jun 26, 2023 · 2 comments
Open

Comments

@demonhue
Copy link
Contributor

demonhue commented Jun 26, 2023

There are 3 files in one folder a.ts, b.ts and c.ts

a.ts

let a = 5, b = 10;
export {a,b};

b.ts

export * from "./a.ts"

c.ts

import {a} from "./b.ts"

then it shows that there is an unused export in b.ts named b even though there is no export named b in b.ts

@demonhue demonhue changed the title --ignoreLocallyUsed doesn't work with aliases doesn't work as intended when using export * from "./abc" statement Jun 26, 2023
@AivarasBartasevicius
Copy link

AivarasBartasevicius commented Jun 27, 2023

You are exporting both a and b from b.ts because of the "*",

1 option:
b.ts was
export * as aStuff from "./a.ts"
and c.ts was
import { aStuff } from "./b.ts"

2 option:
b.ts was
export a from "./a.ts"
and c.ts was
import { a } from "./b.ts"

both options should work.
of course in option 2 the error then would say that a.ts has unused b, and in option 1 I image it would work, but you would be hiding that b is unused act.

@jtbandes
Copy link

I have the same issue, and I also notice that the reported location (line number) is wrong. It corresponds to the line number of the original export, not the line number of the export *. This makes it hard/impossible to use a // ts-unused-exports:disable-next-line comment to work around the issue.

I reported the same issue in ts-prune nadeesha/ts-prune#141 and that was never resolved either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants