Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/transformers/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1905,7 +1905,7 @@ namespace ts {
: (<ComputedPropertyName>name).expression;
}
else if (isIdentifier(name)) {
return createLiteral(name.text);
return createLiteral(unescapeIdentifier(name.text));
}
else {
return getSynthesizedClone(name);
Expand Down
37 changes: 37 additions & 0 deletions tests/baselines/reference/decoratorWithUnderscoreMethod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//// [decoratorWithUnderscoreMethod.ts]

declare var console : { log(arg: string): void };
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
}
}

//// [decoratorWithUnderscoreMethod.js]
function dec() {
return function (target, propKey, descr) {
console.log(target[propKey]);
//logs undefined
//propKey has three underscores as prefix, but the method has only two underscores
};
}
var A = (function () {
function A() {
}
A.prototype.__foo = function (bar) {
// do something with bar
};
return A;
}());
__decorate([
dec()
], A.prototype, "__foo");
42 changes: 42 additions & 0 deletions tests/baselines/reference/decoratorWithUnderscoreMethod.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
=== tests/cases/compiler/decoratorWithUnderscoreMethod.ts ===

declare var console : { log(arg: string): void };
>console : Symbol(console, Decl(decoratorWithUnderscoreMethod.ts, 1, 11))
>log : Symbol(log, Decl(decoratorWithUnderscoreMethod.ts, 1, 23))
>arg : Symbol(arg, Decl(decoratorWithUnderscoreMethod.ts, 1, 28))

function dec(): Function {
>dec : Symbol(dec, Decl(decoratorWithUnderscoreMethod.ts, 1, 49))
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))

return function (target: any, propKey: string, descr: PropertyDescriptor): void {
>target : Symbol(target, Decl(decoratorWithUnderscoreMethod.ts, 3, 21))
>propKey : Symbol(propKey, Decl(decoratorWithUnderscoreMethod.ts, 3, 33))
>descr : Symbol(descr, Decl(decoratorWithUnderscoreMethod.ts, 3, 50))
>PropertyDescriptor : Symbol(PropertyDescriptor, Decl(lib.d.ts, --, --))

console.log(target[propKey]);
>console.log : Symbol(log, Decl(decoratorWithUnderscoreMethod.ts, 1, 23))
>console : Symbol(console, Decl(decoratorWithUnderscoreMethod.ts, 1, 11))
>log : Symbol(log, Decl(decoratorWithUnderscoreMethod.ts, 1, 23))
>target : Symbol(target, Decl(decoratorWithUnderscoreMethod.ts, 3, 21))
>propKey : Symbol(propKey, Decl(decoratorWithUnderscoreMethod.ts, 3, 33))

//logs undefined
//propKey has three underscores as prefix, but the method has only two underscores
};
}

class A {
>A : Symbol(A, Decl(decoratorWithUnderscoreMethod.ts, 8, 1))

@dec()
>dec : Symbol(dec, Decl(decoratorWithUnderscoreMethod.ts, 1, 49))

private __foo(bar: string): void {
>__foo : Symbol(A.__foo, Decl(decoratorWithUnderscoreMethod.ts, 10, 9))
>bar : Symbol(bar, Decl(decoratorWithUnderscoreMethod.ts, 12, 18))

// do something with bar
}
}
46 changes: 46 additions & 0 deletions tests/baselines/reference/decoratorWithUnderscoreMethod.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
=== tests/cases/compiler/decoratorWithUnderscoreMethod.ts ===

declare var console : { log(arg: string): void };
>console : { log(arg: string): void; }
>log : (arg: string) => void
>arg : string

function dec(): Function {
>dec : () => Function
>Function : Function

return function (target: any, propKey: string, descr: PropertyDescriptor): void {
>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 } : (target: any, propKey: string, descr: PropertyDescriptor) => void
>target : any
>propKey : string
>descr : PropertyDescriptor
>PropertyDescriptor : PropertyDescriptor

console.log(target[propKey]);
>console.log(target[propKey]) : void
>console.log : (arg: string) => void
>console : { log(arg: string): void; }
>log : (arg: string) => void
>target[propKey] : any
>target : any
>propKey : string

//logs undefined
//propKey has three underscores as prefix, but the method has only two underscores
};
}

class A {
>A : A

@dec()
>dec() : Function
>dec : () => Function

private __foo(bar: string): void {
>__foo : (bar: string) => void
>bar : string

// do something with bar
}
}
18 changes: 18 additions & 0 deletions tests/cases/compiler/decoratorWithUnderscoreMethod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// @noemithelpers: true
// @experimentaldecorators: true

declare var console : { log(arg: string): void };
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
}
}