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

Use language service "rename" functionality to avoid name collisions #130

Closed
cspotcode opened this issue Aug 5, 2020 · 3 comments · Fixed by #270
Closed

Use language service "rename" functionality to avoid name collisions #130

cspotcode opened this issue Aug 5, 2020 · 3 comments · Fixed by #270
Assignees
Milestone

Comments

@cspotcode
Copy link
Contributor

This is an idea to fix the known limitation about duplicate names:

All your types should have different names inside a bundle. If you have 2 interface Options {} they will be merged by TypeScript and you will get wrong definitions.

The language service can be queried for a list of all locations to replace in order to rename an identifier. Can this functionality be used to rename symbols, avoiding naming collisions?

For each top-level declaration, we can decide if it needs a new name. If it does, we ask the language service for a list of all locations where that name appears. Then as we're emitting the bundled declaration, we perform replacement of all those text spans, which means the symbol gets its new name in the output.

I'm sure there are problems with this approach, and I'm interested to hear what you think.

@timocov
Copy link
Owner

timocov commented Aug 15, 2020

@cspotcode sorry for late reply.

It's an interesting idea, but I'm not sure whether it's possible or will be simple, because to rename property we need to detect all collision names, detect in what types we have that nodes and rename there (but what if we'll have 2 different collisions but used in the same type?). If you any rough impl of that, it'd be interesting to see how it works.

@timocov
Copy link
Owner

timocov commented Apr 10, 2021

Related to #116

@timocov
Copy link
Owner

timocov commented Nov 27, 2023

The fix has been released in v9.0.0.

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

Successfully merging a pull request may close this issue.

2 participants