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
8 changes: 6 additions & 2 deletions tsc/internal/transformers/declarations/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -2118,9 +2118,13 @@ caseBlock:
}
}

var mods *ast.ModifierList
modifierFlags := tx.ensureModifierFlags(node)
if isStatic {
mods = tx.Factory().NewModifierList([]*ast.Node{tx.Factory().NewModifier(ast.KindStaticKeyword)})
modifierFlags |= ast.ModifierFlagsStatic
}
var mods *ast.ModifierList
if modifierFlags != ast.ModifierFlagsNone {
mods = tx.Factory().NewModifierList(ast.CreateModifiersFromModifierFlags(modifierFlags, tx.Factory().NewModifier))
}
if ast.HasDynamicName(node) {
if !transformers.IsSimpleInlineableExpression(name) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//// [tests/cases/compiler/jsDeclarationEmitThisPropertyJSDocModifiers.ts] ////

//// [a.js]
export class A {
constructor() {
/** @private @type {boolean} */
this.privateProperty = false;
/** @protected @type {string} */
this.protectedProperty = "";
/** @readonly @type {number} */
this.readonlyProperty = 0;
/** @public @type {bigint} */
this.publicProperty = 0n;
}

static initialize() {
/** @private @type {symbol} */
this.privateStaticProperty = Symbol();
}
}




//// [a.d.ts]
export declare class A {
/** @private @type {boolean} */
private privateProperty;
/** @protected @type {string} */
protected protectedProperty: string;
/** @readonly @type {number} */
readonly readonlyProperty: number;
/** @public @type {bigint} */
publicProperty: bigint;
/** @private @type {symbol} */
private static privateStaticProperty;
constructor();
static initialize(): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class C {
//// [jsdocAccessibilityTagDeclarations.d.ts]
declare class Protected {
/** @protected */
c: any;
protected c: any;
/** @protected */
protected constructor(c: any);
/** @protected */
Expand All @@ -94,7 +94,7 @@ declare class Protected {
}
declare class Private {
/** @private */
c;
private c;
/** @private */
private constructor();
/** @private */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ declare class C {
* @readonly
* @type {number}
*/
y: number;
readonly y: number;
/** @readonly */
readonly x = 6;
/** @readonly */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// @target: esnext
// @allowJs: true
// @checkJs: true
// @declaration: true
// @emitDeclarationOnly: true
// @noTypesAndSymbols: true
// @filename: /a.js

export class A {
constructor() {
/** @private @type {boolean} */
this.privateProperty = false;
/** @protected @type {string} */
this.protectedProperty = "";
/** @readonly @type {number} */
this.readonlyProperty = 0;
/** @public @type {bigint} */
this.publicProperty = 0n;
}

static initialize() {
/** @private @type {symbol} */
this.privateStaticProperty = Symbol();
}
}
Loading