Skip to content

Commit

Permalink
stash
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingwl committed Apr 25, 2018
1 parent 92b9361 commit 8aadbd1
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 22 deletions.
17 changes: 10 additions & 7 deletions src/compiler/transformers/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ namespace ts {
if (ctor) {
const oldDiag = getSymbolAccessibilityDiagnostic;
parameterProperties = compact(flatMap(ctor.parameters, param => {
if (!hasModifier(param, ModifierFlags.ParameterPropertyModifier) || shouldStripInternal(param, /* isInline */ true)) return;
if (!hasModifier(param, ModifierFlags.ParameterPropertyModifier) || shouldStripInternal(param)) return;
getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(param);
if (param.name.kind === SyntaxKind.Identifier) {
return preserveJsDoc(createProperty(
Expand Down Expand Up @@ -1140,13 +1140,16 @@ namespace ts {
return stringContains(comment, "@internal");
}

function shouldStripInternal(node: Node, isInline?: boolean) {
function shouldStripInternal(node: Node) {
if (stripInternal && node) {
const commentRanges = isInline
? getTrailingCommentRangesOfNode(getParseTreeNode(node), currentSourceFile)
: getLeadingCommentRangesOfNode(getParseTreeNode(node), currentSourceFile);
if (forEach(commentRanges, hasInternalAnnotation)) {
return true;
node = getParseTreeNode(node);
const leadingCommentRanges = getLeadingCommentRangesOfNode(node, currentSourceFile);
if (leadingCommentRanges && leadingCommentRanges.length) {
return hasInternalAnnotation(last(leadingCommentRanges));
}
const trailingCommentRanges = getTrailingCommentRangesOfNode(node, currentSourceFile);
if (trailingCommentRanges && trailingCommentRanges.length) {
return hasInternalAnnotation(last(trailingCommentRanges));
}
}
return false;
Expand Down
53 changes: 48 additions & 5 deletions tests/baselines/reference/declarationEmitWorkWithInlineComments.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,52 @@
//// [declarationEmitWorkWithInlineComments.ts]
export class Foo {
constructor(/** @internal */ public bar: string) { }
/** @internal */ zoo: string;
constructor(
/** @internal */
public isInternal1: string,
/** @internal */ public isInternal2: string, /** @internal */
public isInternal3: string,
// @internal
public isInternal4: string,
// @internal
/** @internal */
public isInternal5: string,
/* @internal */ public isInternal6: string, /** @internal */
// next line
public notInternal1: string,
// @internal
/* next line */
public notInternal2: string
) { }
}


//// [declarationEmitWorkWithInlineComments.js]
"use strict";
exports.__esModule = true;
var Foo = /** @class */ (function () {
function Foo(/** @internal */ bar) {
this.bar = bar;
function Foo(
/** @internal */
isInternal1,
/** @internal */ isInternal2, /** @internal */ isInternal3,
// @internal
isInternal4,
// @internal
/** @internal */
isInternal5,
/* @internal */ isInternal6, /** @internal */
// next line
notInternal1,
// @internal
/* next line */
notInternal2) {
this.isInternal1 = isInternal1;
this.isInternal2 = isInternal2;
this.isInternal3 = isInternal3;
this.isInternal4 = isInternal4;
this.isInternal5 = isInternal5;
this.isInternal6 = isInternal6;
this.notInternal1 = notInternal1;
this.notInternal2 = notInternal2;
}
return Foo;
}());
Expand All @@ -19,5 +55,12 @@ exports.Foo = Foo;

//// [declarationEmitWorkWithInlineComments.d.ts]
export declare class Foo {
constructor(/** @internal */ bar: string);
notInternal1: string;
notInternal2: string;
constructor(
/** @internal */
isInternal1: string,
/** @internal */ isInternal2: string, /** @internal */ isInternal3: string, isInternal4: string,
/** @internal */
isInternal5: string, isInternal6: string, /** @internal */ notInternal1: string, notInternal2: string);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,38 @@
export class Foo {
>Foo : Symbol(Foo, Decl(declarationEmitWorkWithInlineComments.ts, 0, 0))

constructor(/** @internal */ public bar: string) { }
>bar : Symbol(Foo.bar, Decl(declarationEmitWorkWithInlineComments.ts, 1, 14))
constructor(
/** @internal */
public isInternal1: string,
>isInternal1 : Symbol(Foo.isInternal1, Decl(declarationEmitWorkWithInlineComments.ts, 1, 14))

/** @internal */ zoo: string;
>zoo : Symbol(Foo.zoo, Decl(declarationEmitWorkWithInlineComments.ts, 1, 54))
/** @internal */ public isInternal2: string, /** @internal */
>isInternal2 : Symbol(Foo.isInternal2, Decl(declarationEmitWorkWithInlineComments.ts, 3, 31))

public isInternal3: string,
>isInternal3 : Symbol(Foo.isInternal3, Decl(declarationEmitWorkWithInlineComments.ts, 4, 48))

// @internal
public isInternal4: string,
>isInternal4 : Symbol(Foo.isInternal4, Decl(declarationEmitWorkWithInlineComments.ts, 5, 31))

// @internal
/** @internal */
public isInternal5: string,
>isInternal5 : Symbol(Foo.isInternal5, Decl(declarationEmitWorkWithInlineComments.ts, 7, 31))

/* @internal */ public isInternal6: string, /** @internal */
>isInternal6 : Symbol(Foo.isInternal6, Decl(declarationEmitWorkWithInlineComments.ts, 10, 31))

// next line
public notInternal1: string,
>notInternal1 : Symbol(Foo.notInternal1, Decl(declarationEmitWorkWithInlineComments.ts, 11, 47))

// @internal
/* next line */
public notInternal2: string
>notInternal2 : Symbol(Foo.notInternal2, Decl(declarationEmitWorkWithInlineComments.ts, 13, 32))

) { }
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,38 @@
export class Foo {
>Foo : Foo

constructor(/** @internal */ public bar: string) { }
>bar : string
constructor(
/** @internal */
public isInternal1: string,
>isInternal1 : string

/** @internal */ zoo: string;
>zoo : string
/** @internal */ public isInternal2: string, /** @internal */
>isInternal2 : string

public isInternal3: string,
>isInternal3 : string

// @internal
public isInternal4: string,
>isInternal4 : string

// @internal
/** @internal */
public isInternal5: string,
>isInternal5 : string

/* @internal */ public isInternal6: string, /** @internal */
>isInternal6 : string

// next line
public notInternal1: string,
>notInternal1 : string

// @internal
/* next line */
public notInternal2: string
>notInternal2 : string

) { }
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
// @declaration: true
// @stripInternal:true

export class Foo {
constructor(/** @internal */ public bar: string) { }
/** @internal */ zoo: string;
constructor(
/** @internal */
public isInternal1: string,
/** @internal */ public isInternal2: string, /** @internal */
public isInternal3: string,
// @internal
public isInternal4: string,
// @internal
/** @internal */
public isInternal5: string,
/* @internal */ public isInternal6: string, /** @internal */
// next line
public notInternal1: string,
// @internal
/* next line */
public notInternal2: string
) { }
}

0 comments on commit 8aadbd1

Please sign in to comment.