Skip to content

Broken emit with private field in class decoratorΒ #54465

Closed
@Jamesernator

Description

@Jamesernator

Bug Report

πŸ”Ž Search Terms

private field, decorators, broken emit

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about decorators

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

function makeDecorator(fn: (...args: any[]) => any) {
    return function decorateClass<C extends new (...args: any[]) => any>(
        klass: C, 
        ctx: ClassDecoratorContext,
    )  {
        // The implementation of this doesn't matter
    }
}

@makeDecorator(x => x.#foo)
class Foo {
    #foo: number = 3;
}

πŸ™ Actual behavior

The generated code is syntatically incorrect with the error:

Unexpected token ')' 

This happens on the line, basically nothing is emitted after the x.:

    let _classDecorators = [makeDecorator(x => x.)];

πŸ™‚ Expected behavior

Functioning code should be emitted.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions