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

Commit efe7b65

Browse filesBrowse files
authored
Merge pull request microsoft#12610 from Microsoft/Port12590
Port microsoft#12590
2 parents 2cec8db + e5b5fe1 commit efe7b65
Copy full SHA for efe7b65

5 files changed

+144-1Lines changed: 144 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/transformers/ts.ts‎

Copy file name to clipboardExpand all lines: src/compiler/transformers/ts.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,7 @@ namespace ts {
19051905
: (<ComputedPropertyName>name).expression;
19061906
}
19071907
else if (isIdentifier(name)) {
1908-
return createLiteral(name.text);
1908+
return createLiteral(unescapeIdentifier(name.text));
19091909
}
19101910
else {
19111911
return getSynthesizedClone(name);
Collapse file
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//// [decoratorWithUnderscoreMethod.ts]
2+
3+
declare var console : { log(arg: string): void };
4+
function dec(): Function {
5+
return function (target: any, propKey: string, descr: PropertyDescriptor): void {
6+
console.log(target[propKey]);
7+
//logs undefined
8+
//propKey has three underscores as prefix, but the method has only two underscores
9+
};
10+
}
11+
12+
class A {
13+
@dec()
14+
private __foo(bar: string): void {
15+
// do something with bar
16+
}
17+
}
18+
19+
//// [decoratorWithUnderscoreMethod.js]
20+
function dec() {
21+
return function (target, propKey, descr) {
22+
console.log(target[propKey]);
23+
//logs undefined
24+
//propKey has three underscores as prefix, but the method has only two underscores
25+
};
26+
}
27+
var A = (function () {
28+
function A() {
29+
}
30+
A.prototype.__foo = function (bar) {
31+
// do something with bar
32+
};
33+
return A;
34+
}());
35+
__decorate([
36+
dec()
37+
], A.prototype, "__foo");
Collapse file
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
=== tests/cases/compiler/decoratorWithUnderscoreMethod.ts ===
2+
3+
declare var console : { log(arg: string): void };
4+
>console : Symbol(console, Decl(decoratorWithUnderscoreMethod.ts, 1, 11))
5+
>log : Symbol(log, Decl(decoratorWithUnderscoreMethod.ts, 1, 23))
6+
>arg : Symbol(arg, Decl(decoratorWithUnderscoreMethod.ts, 1, 28))
7+
8+
function dec(): Function {
9+
>dec : Symbol(dec, Decl(decoratorWithUnderscoreMethod.ts, 1, 49))
10+
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
11+
12+
return function (target: any, propKey: string, descr: PropertyDescriptor): void {
13+
>target : Symbol(target, Decl(decoratorWithUnderscoreMethod.ts, 3, 21))
14+
>propKey : Symbol(propKey, Decl(decoratorWithUnderscoreMethod.ts, 3, 33))
15+
>descr : Symbol(descr, Decl(decoratorWithUnderscoreMethod.ts, 3, 50))
16+
>PropertyDescriptor : Symbol(PropertyDescriptor, Decl(lib.d.ts, --, --))
17+
18+
console.log(target[propKey]);
19+
>console.log : Symbol(log, Decl(decoratorWithUnderscoreMethod.ts, 1, 23))
20+
>console : Symbol(console, Decl(decoratorWithUnderscoreMethod.ts, 1, 11))
21+
>log : Symbol(log, Decl(decoratorWithUnderscoreMethod.ts, 1, 23))
22+
>target : Symbol(target, Decl(decoratorWithUnderscoreMethod.ts, 3, 21))
23+
>propKey : Symbol(propKey, Decl(decoratorWithUnderscoreMethod.ts, 3, 33))
24+
25+
//logs undefined
26+
//propKey has three underscores as prefix, but the method has only two underscores
27+
};
28+
}
29+
30+
class A {
31+
>A : Symbol(A, Decl(decoratorWithUnderscoreMethod.ts, 8, 1))
32+
33+
@dec()
34+
>dec : Symbol(dec, Decl(decoratorWithUnderscoreMethod.ts, 1, 49))
35+
36+
private __foo(bar: string): void {
37+
>__foo : Symbol(A.__foo, Decl(decoratorWithUnderscoreMethod.ts, 10, 9))
38+
>bar : Symbol(bar, Decl(decoratorWithUnderscoreMethod.ts, 12, 18))
39+
40+
// do something with bar
41+
}
42+
}
Collapse file
+46Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
=== tests/cases/compiler/decoratorWithUnderscoreMethod.ts ===
2+
3+
declare var console : { log(arg: string): void };
4+
>console : { log(arg: string): void; }
5+
>log : (arg: string) => void
6+
>arg : string
7+
8+
function dec(): Function {
9+
>dec : () => Function
10+
>Function : Function
11+
12+
return function (target: any, propKey: string, descr: PropertyDescriptor): void {
13+
>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
14+
>target : any
15+
>propKey : string
16+
>descr : PropertyDescriptor
17+
>PropertyDescriptor : PropertyDescriptor
18+
19+
console.log(target[propKey]);
20+
>console.log(target[propKey]) : void
21+
>console.log : (arg: string) => void
22+
>console : { log(arg: string): void; }
23+
>log : (arg: string) => void
24+
>target[propKey] : any
25+
>target : any
26+
>propKey : string
27+
28+
//logs undefined
29+
//propKey has three underscores as prefix, but the method has only two underscores
30+
};
31+
}
32+
33+
class A {
34+
>A : A
35+
36+
@dec()
37+
>dec() : Function
38+
>dec : () => Function
39+
40+
private __foo(bar: string): void {
41+
>__foo : (bar: string) => void
42+
>bar : string
43+
44+
// do something with bar
45+
}
46+
}
Collapse file
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// @noemithelpers: true
2+
// @experimentaldecorators: true
3+
4+
declare var console : { log(arg: string): void };
5+
function dec(): Function {
6+
return function (target: any, propKey: string, descr: PropertyDescriptor): void {
7+
console.log(target[propKey]);
8+
//logs undefined
9+
//propKey has three underscores as prefix, but the method has only two underscores
10+
};
11+
}
12+
13+
class A {
14+
@dec()
15+
private __foo(bar: string): void {
16+
// do something with bar
17+
}
18+
}

0 commit comments

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