-
Notifications
You must be signed in to change notification settings - Fork 663
Feat(rome_js_parser): typeof private property name #2524
Feat(rome_js_parser): typeof private property name #2524
Conversation
!bench_parser |
Parser Benchmark Results
|
@MichaReiser could you help with reviewing my pull request about the new typescript 4.7 syntax? |
@@ -2129,7 +2129,7 @@ TsAnyName = | |||
TsQualifiedName = | |||
left: TsAnyName | |||
'.' | |||
right: JsName | |||
right: JsAnyName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having concerns about adding JsAnyName
to the right-hand side. This will not only allow private names in typeof
expressions but anywhere else where TsQualifiedName
is used (and none of these allow private names).
Can you go through all types that have a field with the type TsQualifiedName
and check if TS now allows the usage of private names for these use cases? For example, TsImportTypeQualifier
, TsNameWithTypeArguments
, TsReferenceType
, TsAnyModuleReference
Does TS support typeof this.#a.b
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p
Ts support typeof this.#a.b
, https://www.typescriptlang.org/play?#code/FAYwNghgzlAEAqsDexZtgYgrAvMiAXLAOTEC+q6ALgKZRUAUAlMpetQJ4AONA9gGawqACwCWUAHRYJEANxtYFMkA, but I don't have enough knowledge about Ts specification, so I can't write code snippet include the ast node you mentioned above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to understand the exact change of typescript to model the AST correctly.
Are you able to find the related PR in the TypeScript repository?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
microsoft/TypeScript#47696, this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading the code of this PR should help you understand which rules allow private names and which do not (allowPrivateIdentifiers
parameter).
The next step is then to go to TypeScript's playground and try to come up with examples for the cases where private names are/aren't allowed.
We're reverting the linked change in TS, so you probably shouldn't merge this (we may not even allow this syntax). |
Thanks @jakebailey for letting us know! |
Summary
part of #2400
typeof on private fields: Announcement
Test Plan
I copy the test case from official pull request https://github.com/microsoft/TypeScript/pull/47696/files#diff-c7d8064feb0c4b5ba2cb75b7987eefc92a880fded5f86a9564f5d30ffef48bff, and pass it.