mirror of
https://github.com/jehna/humanify.git
synced 2026-04-27 09:35:58 +03:00
[GH-ISSUE #183] Support for private class fields #56
Labels
No labels
bug
enhancement
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/humanify#56
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @brianjenkins94 on GitHub (Oct 26, 2024).
Original GitHub issue: https://github.com/jehna/humanify/issues/183
It doesn't look like private class fields are renamed, can support be added for them?
@Versirity commented on GitHub (Nov 26, 2024):
Class static methods cannot be renamed either. I think these features are important
@0xdevalias commented on GitHub (Feb 18, 2025):
Using https://astexplorer.net/ with
@babel/parserWith this sample (Ref):
Gives this AST:
AST
From that, we can see that:
#privateField:ClassPrivateProperty->PrivateName->Identifier#privateFieldWithInitializer:ClassPrivateProperty->PrivateName->Identifier#privateMethod:ClassPrivateMethod->PrivateName->Identifier#privateStaticField:ClassPrivateProperty->PrivateName->Identifier#privateStaticFieldWithInitializer:ClassPrivateProperty->PrivateName->Identifier#privateStaticMethod:ClassPrivateMethod->PrivateName->IdentifierGiven each of these end up as
Identifier, I wonder if this change was relevant:I don't know for sure if this worked before that change, but from a relatively naive understanding of the code, I suspect it probably wouldn't work after it since
Identifierwas changed toBindingIdentifier; unless there is some other area of the code that handles this case more specifically.I find the current implementation of
visitAllIdentifiersa little confusing to reason about (see https://github.com/jehna/humanify/issues/330), so not sure exactly what the best way of implementing a fix here would be.@j4k0xb commented on GitHub (Feb 18, 2025):
A bit relevant but going directly back to replacing identifiers would lead to the same problems as before.
And
@babel/traversehas no built-in way to track the scope and references of private class fields/methods.Would probably have to do it similarly to this plugin/function:
github.com/babel/babel@ce0e87b12c/packages/babel-helper-create-class-features-plugin/src/fields.ts (L203)@0xdevalias commented on GitHub (Feb 21, 2025):
@j4k0xb Yeah, I definitely wasn't suggestion a naive switch from
BindingIdentifiertoIdentifier; more just wanted to highlight when/where it may have been introduced.Oh? True.. that's annoying.
@0xdevalias commented on GitHub (Jun 2, 2025):
Copying the following here as the more relevant place for it: