Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Decorating underscore prefixed methods fails #12562

Copy link
Copy link
@martin31821

Description

@martin31821
Issue body actions

TypeScript Version: 2.1.1

Code

function dec(): Function
{
  return function (target: any, propKey: string, descr: PropertyDescriptor): void
  {
    console.log(target[propKey]);
    //logs undefined
    //propKey has three underscores as prefix, but the method has only two underscores
  };
}

class A
{
  @dec()
  private __foo(bar: string): void
  {
    // do something with bar
  }
}

Expected behavior:
target[propKey] should point to the decorated method

Actual behavior:
target[propKey] is undefined

My workaround is checking the property key in the decorator and deleting the first one underscore at the moment.

As far as I can tell the problem exists since typescript 2.1

Edit: updated code to reproduce problem when compiling

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.