Only emit comment once for export enum declaration
This commit is contained in:
parent
874846a534
commit
9d63c5a35e
5 changed files with 57 additions and 8 deletions
|
@ -802,17 +802,17 @@ namespace ts {
|
|||
* Adds a trailing VariableStatement for an enum or module declaration.
|
||||
*/
|
||||
function addVarForExportedEnumOrNamespaceDeclaration(statements: Statement[], node: EnumDeclaration | ModuleDeclaration) {
|
||||
statements.push(
|
||||
createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
[createVariableDeclaration(
|
||||
getDeclarationName(node),
|
||||
const transformedStatement = createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
[createVariableDeclaration(
|
||||
getDeclarationName(node),
|
||||
/*type*/ undefined,
|
||||
createPropertyAccess(createIdentifier("exports"), getDeclarationName(node))
|
||||
)],
|
||||
createPropertyAccess(createIdentifier("exports"), getDeclarationName(node))
|
||||
)],
|
||||
/*location*/ node
|
||||
)
|
||||
);
|
||||
setNodeEmitFlags(transformedStatement, NodeEmitFlags.NoComments);
|
||||
statements.push(transformedStatement);
|
||||
}
|
||||
|
||||
function getDeclarationName(node: DeclarationStatement) {
|
||||
|
|
19
tests/baselines/reference/commentOnExportEnumDeclaration.js
Normal file
19
tests/baselines/reference/commentOnExportEnumDeclaration.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
//// [commentOnExportEnumDeclaration.ts]
|
||||
/**
|
||||
* comment
|
||||
*/
|
||||
export enum Color {
|
||||
r, g, b
|
||||
}
|
||||
|
||||
//// [commentOnExportEnumDeclaration.js]
|
||||
"use strict";
|
||||
/**
|
||||
* comment
|
||||
*/
|
||||
(function (Color) {
|
||||
Color[Color["r"] = 0] = "r";
|
||||
Color[Color["g"] = 1] = "g";
|
||||
Color[Color["b"] = 2] = "b";
|
||||
})(exports.Color || (exports.Color = {}));
|
||||
var Color = exports.Color;
|
|
@ -0,0 +1,12 @@
|
|||
=== tests/cases/compiler/commentOnExportEnumDeclaration.ts ===
|
||||
/**
|
||||
* comment
|
||||
*/
|
||||
export enum Color {
|
||||
>Color : Symbol(Color, Decl(commentOnExportEnumDeclaration.ts, 0, 0))
|
||||
|
||||
r, g, b
|
||||
>r : Symbol(Color.r, Decl(commentOnExportEnumDeclaration.ts, 3, 19))
|
||||
>g : Symbol(Color.g, Decl(commentOnExportEnumDeclaration.ts, 4, 6))
|
||||
>b : Symbol(Color.b, Decl(commentOnExportEnumDeclaration.ts, 4, 9))
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
=== tests/cases/compiler/commentOnExportEnumDeclaration.ts ===
|
||||
/**
|
||||
* comment
|
||||
*/
|
||||
export enum Color {
|
||||
>Color : Color
|
||||
|
||||
r, g, b
|
||||
>r : Color
|
||||
>g : Color
|
||||
>b : Color
|
||||
}
|
6
tests/cases/compiler/commentOnExportEnumDeclaration.ts
Normal file
6
tests/cases/compiler/commentOnExportEnumDeclaration.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* comment
|
||||
*/
|
||||
export enum Color {
|
||||
r, g, b
|
||||
}
|
Loading…
Reference in a new issue