Skip to content

Commit a53f9e8

Browse files
authored
Call ensureModifiers on private property modifiers (#23026)
1 parent 9dd3ef4 commit a53f9e8

File tree

5 files changed

+92
-1
lines changed

5 files changed

+92
-1
lines changed

src/compiler/transformers/declarations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ namespace ts {
614614
if (isMethodDeclaration(input) || isMethodSignature(input)) {
615615
if (hasModifier(input, ModifierFlags.Private)) {
616616
if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload
617-
return cleanup(createProperty(/*decorators*/undefined, input.modifiers, input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined));
617+
return cleanup(createProperty(/*decorators*/undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined));
618618
}
619619
}
620620

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//// [declarationEmitPrivateAsync.ts]
2+
export class Foo {
3+
private async baz() {
4+
return;
5+
}
6+
}
7+
8+
//// [declarationEmitPrivateAsync.js]
9+
"use strict";
10+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
11+
return new (P || (P = Promise))(function (resolve, reject) {
12+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
15+
step((generator = generator.apply(thisArg, _arguments || [])).next());
16+
});
17+
};
18+
var __generator = (this && this.__generator) || function (thisArg, body) {
19+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
20+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
21+
function verb(n) { return function (v) { return step([n, v]); }; }
22+
function step(op) {
23+
if (f) throw new TypeError("Generator is already executing.");
24+
while (_) try {
25+
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
26+
if (y = 0, t) op = [0, t.value];
27+
switch (op[0]) {
28+
case 0: case 1: t = op; break;
29+
case 4: _.label++; return { value: op[1], done: false };
30+
case 5: _.label++; y = op[1]; op = [0]; continue;
31+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
32+
default:
33+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
34+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
35+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
36+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
37+
if (t[2]) _.ops.pop();
38+
_.trys.pop(); continue;
39+
}
40+
op = body.call(thisArg, _);
41+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
42+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
43+
}
44+
};
45+
exports.__esModule = true;
46+
var Foo = /** @class */ (function () {
47+
function Foo() {
48+
}
49+
Foo.prototype.baz = function () {
50+
return __awaiter(this, void 0, void 0, function () {
51+
return __generator(this, function (_a) {
52+
return [2 /*return*/];
53+
});
54+
});
55+
};
56+
return Foo;
57+
}());
58+
exports.Foo = Foo;
59+
60+
61+
//// [declarationEmitPrivateAsync.d.ts]
62+
export declare class Foo {
63+
private baz;
64+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/declarationEmitPrivateAsync.ts ===
2+
export class Foo {
3+
>Foo : Symbol(Foo, Decl(declarationEmitPrivateAsync.ts, 0, 0))
4+
5+
private async baz() {
6+
>baz : Symbol(Foo.baz, Decl(declarationEmitPrivateAsync.ts, 0, 18))
7+
8+
return;
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/declarationEmitPrivateAsync.ts ===
2+
export class Foo {
3+
>Foo : Foo
4+
5+
private async baz() {
6+
>baz : () => Promise<void>
7+
8+
return;
9+
}
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// @lib: es6
2+
// @declaration: true
3+
export class Foo {
4+
private async baz() {
5+
return;
6+
}
7+
}

0 commit comments

Comments
 (0)