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

initial support for accessors (tc39 stage 3 proposal) #14451

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

snoglobe
Copy link
Contributor

What does this PR do?

this PR brings initial support for accessors defined by the tc39 stage 3 proposal for decorators. https://github.com/tc39/proposal-decorators

TODO:

  • make the renamer work with the newly generated class fields
  • write tests
  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

src/renamer.zig Outdated
@@ -725,7 +729,10 @@ pub const NumberRenamer = struct {

/// Caller must use an arena allocator
pub fn findUnusedName(this: *NumberScope, allocator: std.mem.Allocator, temp_allocator: std.mem.Allocator, input_name: []const u8) UnusedName {
var name = bun.MutableString.ensureValidIdentifier(input_name, temp_allocator) catch unreachable;
var name = if (input_name[0] == '#')
allocator.dupe(u8, input_name) catch unreachable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if there's a non-ascii character in a private name?


if (is_private_prop) {
old_property_name = property.key.?.data.e_string.string(p.allocator) catch bun.outOfMemory();
new_property_name = std.fmt.allocPrint(p.allocator, "#{s}", .{old_property_name}) catch bun.outOfMemory();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why isn't this a private property ref?

@@ -21808,14 +21808,14 @@ fn NewParser_(
continue;
}
if (@as(Expr.Tag, property.key.?.data) != .e_string and @as(Expr.Tag, property.key.?.data) != .e_private_identifier) {
p.log.addError(p.source, property.key.?.loc, "'accessor' property key must be a string or private identifier") catch unreachable;
out_properties.push(p.allocator, property.*) catch unreachable;
p.log.addError(p.source, property.key.?.loc, "'accessor' property key must be a string or private identifier") catch bun.outOfMemory();
Copy link
Collaborator

@Jarred-Sumner Jarred-Sumner Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these can all be try right?

@snoglobe
Copy link
Contributor Author

fixed

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

Successfully merging this pull request may close these issues.

3 participants