refactor(js_semantic): ambient computed name can ref a variable imported as a type #3002
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fix #2975
A constant can be imported as a type and used in a computed member name of a member signature.
Here is an example:
Previously, Biome was unable to bind the value imported as a type to the computed member name.
We now correctly handle this case.
To do that, I used the same strategy as
typeof x
:NAME
is still identified as a type.NAME
is emitted as aReference::AmbientRead
(this ref kind was previously namedReference::Typeof
).Typeof
reference to a value and fallback to an imported type otherwise.There may be a way to better handle
typeof x
and more generally values that are imported as types and used in a type context.Also, I took the opportunity of removing
Reference::ExportType
. This reference kind was added with the wrong assumption thatexport type
can only reference a type. Actually a such declaration can also reference a value.I unified
Reference::Typeof
andReference::Qualified
into a single variant namedReference::AmbientRead
.Test Plan
I added non-regression tests.