Skip to content
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

tsickle: emit comment after missing semicolon only once #1487

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions src/jsdoc_transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,10 +846,9 @@ export function jsdocTransformer(
continue;
}
}
const newDecl =
// TODO: go/ts50upgrade - Remove after upgrade.
// tslint:disable-next-line:no-unnecessary-type-assertion
ts.visitNode(decl, visitor, ts.isVariableDeclaration)!;
const newDecl = ts.setEmitFlags(
ts.visitNode(decl, visitor, ts.isVariableDeclaration)!,
ts.EmitFlags.NoComments);
const newStmt = ts.factory.createVariableStatement(
varStmt.modifiers,
ts.factory.createVariableDeclarationList([newDecl], flags));
Expand Down
1 change: 1 addition & 0 deletions src/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class FileSummary {
modName: string|undefined;
autochunk = false;
enhanceable = false;
legacyNamespace = false;
moduleType = ModuleType.UNKNOWN;

private stringify(symbol: Symbol): string {
Expand Down
3 changes: 3 additions & 0 deletions src/ts_migration_exports_shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ class Generator {
fileSummary.addStrongRequire({type: Type.CLOSURE, name: 'goog'});
fileSummary.addStrongRequire(
{type: Type.CLOSURE, name: this.srcIds.googModuleId});
if (maybeDeclareLegacyNameCall) {
fileSummary.legacyNamespace = true;
}

fileSummary.autochunk = isAutoChunk;
fileSummary.moduleType = ModuleType.GOOG_MODULE;
Expand Down
22 changes: 22 additions & 0 deletions test_files/comments/trailing_no_semicolon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
*
* @fileoverview Tests that the JSDoc comment of `other` is only emitted once.
* Without the trailing semicolon after `noExplicitSemicolon` TypeScript seems
* to duplicate the trailing comment as soon as a custom transformer modifies
* the variable statement.
*
* Generated from: test_files/comments/trailing_no_semicolon.ts
*/
goog.module('test_files.comments.trailing_no_semicolon');
var module = module || { id: 'test_files/comments/trailing_no_semicolon.ts' };
goog.require('tslib');
/** @type {number} */
const noExplicitSemicolon = 0;
/**
* This is a comment with a JSDoc tag
* JSCompiler doesn't recognize
*
* \@foobar
* @type {number}
*/
exports.other = 1;
17 changes: 17 additions & 0 deletions test_files/comments/trailing_no_semicolon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @fileoverview Tests that the JSDoc comment of `other` is only emitted once.
* Without the trailing semicolon after `noExplicitSemicolon` TypeScript seems
* to duplicate the trailing comment as soon as a custom transformer modifies
* the variable statement.
*/


const noExplicitSemicolon = 0

/**
* This is a comment with a JSDoc tag
* JSCompiler doesn't recognize
*
* @foobar
*/
export const other = 1;
Loading