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

JS: Add support for TypeScript 4.5 #7216

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

@erik-krogh
Copy link
Contributor

@erik-krogh erik-krogh commented Nov 23, 2021

Evaluation looks fine.


I didn't add new syntax nodes for the new import assertions.
And I didn't add support for import assertions in the JS parser.
E.g. import obj from "./something.json" assert { type: "json" };.
It's currently a stage 3 proposal.


TypeScript added support for the #name in obj syntax, which we didn't support in the JS parser.
So I implemented the ECMAScript proposal first. (It's a stage 4 proposal).

The #name in obj syntax is weird.
For context: name in obj tests whether the string-value contained in the variable name is present as a field in obj.
However, #name in obj tests whether the private field #name (from the current class) is present in obj.
That also means that two #name in obj expressions in two different classes will refer to two different #name fields.

It appears to be the only situation across JavaScript where an identifier does not refer to a value, but instead refers to the existence of a field.
So the implementation is somewhat hacky, but that comes from it being a special case in the language itself.

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

Successfully merging this pull request may close these issues.

None yet

1 participant