Skip to content

Fix field comments #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 24, 2019
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
4 changes: 2 additions & 2 deletions src/compiler/transformers/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,8 @@ namespace ts {
member.type,
/*initializer*/ undefined
);
setCommentRange(updated, node);
setSourceMapRange(updated, node);
setCommentRange(updated, member);
setSourceMapRange(updated, member);
return updated;
}
return member;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//// [classConstructorParametersCommentPlacement.ts]
// some comment
class A {
#a = "private hello";
#b = "another private name";
a = "public property";
constructor(private b = "something") { }
}


//// [classConstructorParametersCommentPlacement.js]
var _classPrivateFieldSet = function (receiver, privateMap, value) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to set private field on non-instance"); } privateMap.set(receiver, value); return value; };
var _a, _b;
// some comment
var A = /** @class */ (function () {
function A(b) {
if (b === void 0) { b = "something"; }
_a.set(this, void 0);
_b.set(this, void 0);
this.b = b;
_classPrivateFieldSet(this, _a, "private hello");
_classPrivateFieldSet(this, _b, "another private name");
this.a = "public property";
}
return A;
}());
_a = new WeakMap(), _b = new WeakMap();
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
=== tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersCommentPlacement.ts ===
// some comment
class A {
>A : Symbol(A, Decl(classConstructorParametersCommentPlacement.ts, 0, 0))

#a = "private hello";
>#a : Symbol(A.#a, Decl(classConstructorParametersCommentPlacement.ts, 1, 9))

#b = "another private name";
>#b : Symbol(A.#b, Decl(classConstructorParametersCommentPlacement.ts, 2, 25))

a = "public property";
>a : Symbol(A.a, Decl(classConstructorParametersCommentPlacement.ts, 3, 32))

constructor(private b = "something") { }
>b : Symbol(A.b, Decl(classConstructorParametersCommentPlacement.ts, 5, 16))
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
=== tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersCommentPlacement.ts ===
// some comment
class A {
>A : A

#a = "private hello";
>#a : string
>"private hello" : "private hello"

#b = "another private name";
>#b : string
>"another private name" : "another private name"

a = "public property";
>a : string
>"public property" : "public property"

constructor(private b = "something") { }
>b : string
>"something" : "something"
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

// some comment
class A {
#a = "private hello";
#b = "another private name";
a = "public property";
constructor(private b = "something") { }
}