diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 67e4fa31cb249..ed3feb6005e09 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -966,6 +966,7 @@ namespace ts { const oldDiag = getSymbolAccessibilityDiagnostic; parameterProperties = compact(flatMap(ctor.parameters, param => { if (!hasModifier(param, ModifierFlags.ParameterPropertyModifier)) return; + if (shouldStripInternalParameterProperty(param)) return; getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(param); if (param.name.kind === SyntaxKind.Identifier) { return preserveJsDoc(createProperty( @@ -1150,6 +1151,12 @@ namespace ts { return false; } + // shouldStripInternal does not work with constructor parameters. This variant does. + function shouldStripInternalParameterProperty(param: ParameterDeclaration) { + return param.jsDoc && param.jsDoc.some(doc => + doc.tags.some(tag => getTextOfNode(tag) === "@internal")); + } + function ensureModifiers(node: Node, privateDeclaration?: boolean): ReadonlyArray { const currentFlags = getModifierFlags(node); const newFlags = ensureModifierFlags(node, privateDeclaration); diff --git a/tests/baselines/reference/stripInternalParameterProperty.js b/tests/baselines/reference/stripInternalParameterProperty.js new file mode 100644 index 0000000000000..8329e1acbd0f4 --- /dev/null +++ b/tests/baselines/reference/stripInternalParameterProperty.js @@ -0,0 +1,24 @@ +//// [stripInternalParameterProperty.ts] +export class C { + constructor(/** @internal */ public foo, public bar) {} +} + + +//// [stripInternalParameterProperty.js] +"use strict"; +exports.__esModule = true; +var C = /** @class */ (function () { + function C(/** @internal */ foo, bar) { + this.foo = foo; + this.bar = bar; + } + return C; +}()); +exports.C = C; + + +//// [stripInternalParameterProperty.d.ts] +export declare class C { + bar: any; + constructor(/** @internal */ foo: any, bar: any); +} diff --git a/tests/baselines/reference/stripInternalParameterProperty.symbols b/tests/baselines/reference/stripInternalParameterProperty.symbols new file mode 100644 index 0000000000000..8296c3ff97a06 --- /dev/null +++ b/tests/baselines/reference/stripInternalParameterProperty.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/stripInternalParameterProperty.ts === +export class C { +>C : Symbol(C, Decl(stripInternalParameterProperty.ts, 0, 0)) + + constructor(/** @internal */ public foo, public bar) {} +>foo : Symbol(C.foo, Decl(stripInternalParameterProperty.ts, 1, 16)) +>bar : Symbol(C.bar, Decl(stripInternalParameterProperty.ts, 1, 44)) +} + diff --git a/tests/baselines/reference/stripInternalParameterProperty.types b/tests/baselines/reference/stripInternalParameterProperty.types new file mode 100644 index 0000000000000..1d7c944510a25 --- /dev/null +++ b/tests/baselines/reference/stripInternalParameterProperty.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/stripInternalParameterProperty.ts === +export class C { +>C : C + + constructor(/** @internal */ public foo, public bar) {} +>foo : any +>bar : any +} + diff --git a/tests/cases/compiler/stripInternalParameterProperty.ts b/tests/cases/compiler/stripInternalParameterProperty.ts new file mode 100644 index 0000000000000..8f1bd279838ea --- /dev/null +++ b/tests/cases/compiler/stripInternalParameterProperty.ts @@ -0,0 +1,7 @@ + +// @declaration:true +// @stripInternal:true + +export class C { + constructor(/** @internal */ public foo, public bar) {} +}