mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Address code review
This commit is contained in:
@@ -4511,50 +4511,26 @@ module ts {
|
||||
return emitPinnedOrTripleSlashComments(member);
|
||||
}
|
||||
|
||||
}
|
||||
if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature || member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) {
|
||||
writeLine();
|
||||
emitLeadingComments(member);
|
||||
emitStart(member);
|
||||
if (member.flags & NodeFlags.Static) {
|
||||
write("static ");
|
||||
}
|
||||
|
||||
if (member.kind === SyntaxKind.GetAccessor) {
|
||||
write("get ");
|
||||
}
|
||||
else if (member.kind === SyntaxKind.SetAccessor) {
|
||||
write("set ");
|
||||
}
|
||||
emit((<MethodDeclaration>member).name);
|
||||
emitSignatureAndBody(<MethodDeclaration>member);
|
||||
emitEnd(member);
|
||||
emitTrailingComments(member);
|
||||
}
|
||||
else if (member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) {
|
||||
var accessors = getAllAccessorDeclarations(node.members, <AccessorDeclaration>member);
|
||||
if (member === accessors.firstAccessor) {
|
||||
writeLine();
|
||||
if (accessors.getAccessor) {
|
||||
writeLine();
|
||||
emitLeadingComments(accessors.getAccessor);
|
||||
emitStart(accessors.getAccessor);
|
||||
if (member.flags & NodeFlags.Static) {
|
||||
write("static ");
|
||||
}
|
||||
write("get ");
|
||||
emit((<MethodDeclaration>member).name);
|
||||
emitSignatureAndBody(accessors.getAccessor);
|
||||
emitEnd(accessors.getAccessor);
|
||||
emitTrailingComments(accessors.getAccessor);
|
||||
}
|
||||
if (accessors.setAccessor) {
|
||||
// We will only write new line if we just emit getAccessor
|
||||
writeLine();
|
||||
emitLeadingComments(accessors.setAccessor);
|
||||
emitStart(accessors.setAccessor);
|
||||
if (member.flags & NodeFlags.Static) {
|
||||
write("static ");
|
||||
}
|
||||
write("set ");
|
||||
emit((<MethodDeclaration>member).name);
|
||||
emitSignatureAndBody(accessors.setAccessor);
|
||||
emitEnd(accessors.setAccessor);
|
||||
emitTrailingComments(accessors.setAccessor);;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,17 @@ class C {
|
||||
static get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
|
||||
set ["computedname"](x: any) {
|
||||
}
|
||||
set ["computedname"](y: string) {
|
||||
}
|
||||
|
||||
set foo(a: string) { }
|
||||
static set bar(b: number) { }
|
||||
@@ -27,6 +38,16 @@ class C {
|
||||
static get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
set ["computedname"](x) {
|
||||
}
|
||||
set ["computedname"](y) {
|
||||
}
|
||||
set foo(a) {
|
||||
}
|
||||
static set bar(b) {
|
||||
|
||||
@@ -21,6 +21,19 @@ class C {
|
||||
static get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
|
||||
set ["computedname"](x: any) {
|
||||
>x : any
|
||||
}
|
||||
set ["computedname"](y: string) {
|
||||
>y : string
|
||||
}
|
||||
|
||||
set foo(a: string) { }
|
||||
>foo : string
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//// [emitClassDeclarationWithLiteralPropertyNameInES6.ts]
|
||||
class B {
|
||||
"hello" = 10;
|
||||
0b110 = "world";
|
||||
0o23534 = "WORLD";
|
||||
20 = "twenty";
|
||||
"foo"() { }
|
||||
0b1110() {}
|
||||
11() { }
|
||||
interface() { }
|
||||
static "hi" = 10000;
|
||||
static 22 = "twenty-two";
|
||||
static 0b101 = "binary";
|
||||
static 0o3235 = "octal";
|
||||
}
|
||||
|
||||
//// [emitClassDeclarationWithLiteralPropertyNameInES6.js]
|
||||
class B {
|
||||
constructor() {
|
||||
this["hello"] = 10;
|
||||
this[0b110] = "world";
|
||||
this[0o23534] = "WORLD";
|
||||
this[20] = "twenty";
|
||||
}
|
||||
"foo"() {
|
||||
}
|
||||
0b1110() {
|
||||
}
|
||||
11() {
|
||||
}
|
||||
interface() {
|
||||
}
|
||||
}
|
||||
B["hi"] = 10000;
|
||||
B[22] = "twenty-two";
|
||||
B[0b101] = "binary";
|
||||
B[0o3235] = "octal";
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithLiteralPropertyNameInES6.ts ===
|
||||
class B {
|
||||
>B : B
|
||||
|
||||
"hello" = 10;
|
||||
0b110 = "world";
|
||||
0o23534 = "WORLD";
|
||||
20 = "twenty";
|
||||
"foo"() { }
|
||||
0b1110() {}
|
||||
11() { }
|
||||
interface() { }
|
||||
>interface : () => void
|
||||
|
||||
static "hi" = 10000;
|
||||
static 22 = "twenty-two";
|
||||
static 0b101 = "binary";
|
||||
static 0o3235 = "octal";
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
//// [emitClassDeclarationWithThisKeyword.ts]
|
||||
//// [emitClassDeclarationWithThisKeywordInES6.ts]
|
||||
class B {
|
||||
x = 10;
|
||||
constructor() {
|
||||
@@ -18,7 +18,7 @@ class B {
|
||||
}
|
||||
}
|
||||
|
||||
//// [emitClassDeclarationWithThisKeyword.js]
|
||||
//// [emitClassDeclarationWithThisKeywordInES6.js]
|
||||
class B {
|
||||
constructor() {
|
||||
this.x = 10;
|
||||
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithThisKeyword.ts ===
|
||||
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithThisKeywordInES6.ts ===
|
||||
class B {
|
||||
>B : B
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//// [emitClassDeclarationWithTypeArgumentAndOverload.ts]
|
||||
//// [emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts]
|
||||
class B<T> {
|
||||
x: T;
|
||||
B: T;
|
||||
@@ -22,7 +22,7 @@ class B<T> {
|
||||
}
|
||||
}
|
||||
|
||||
//// [emitClassDeclarationWithTypeArgumentAndOverload.js]
|
||||
//// [emitClassDeclarationWithTypeArgumentAndOverloadInES6.js]
|
||||
class B {
|
||||
constructor(a) {
|
||||
this.B = a;
|
||||
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentAndOverload.ts ===
|
||||
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts ===
|
||||
class B<T> {
|
||||
>B : B<T>
|
||||
>T : T
|
||||
@@ -13,4 +13,7 @@ class C {
|
||||
get [Symbol.hasInstance]() {
|
||||
return "";
|
||||
}
|
||||
get [Symbol.hasInstance]() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,17 @@ class C {
|
||||
static get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
|
||||
set ["computedname"](x: any) {
|
||||
}
|
||||
set ["computedname"](y: string) {
|
||||
}
|
||||
|
||||
set foo(a: string) { }
|
||||
static set bar(b: number) { }
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// @target: es6
|
||||
class B {
|
||||
"hello" = 10;
|
||||
0b110 = "world";
|
||||
0o23534 = "WORLD";
|
||||
20 = "twenty";
|
||||
"foo"() { }
|
||||
0b1110() {}
|
||||
11() { }
|
||||
interface() { }
|
||||
static "hi" = 10000;
|
||||
static 22 = "twenty-two";
|
||||
static 0b101 = "binary";
|
||||
static 0o3235 = "octal";
|
||||
}
|
||||
Reference in New Issue
Block a user