mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
Merge pull request #1855 from stanthomas/master
issue #1833 : const enum: supress value comment in emitted javascript
This commit is contained in:
commit
6807bf86a5
@ -2461,8 +2461,11 @@ module ts {
|
||||
function tryEmitConstantValue(node: PropertyAccessExpression | ElementAccessExpression): boolean {
|
||||
var constantValue = resolver.getConstantValue(node);
|
||||
if (constantValue !== undefined) {
|
||||
var propertyName = node.kind === SyntaxKind.PropertyAccessExpression ? declarationNameToString((<PropertyAccessExpression>node).name) : getTextOfNode((<ElementAccessExpression>node).argumentExpression);
|
||||
write(constantValue.toString() + " /* " + propertyName + " */");
|
||||
write(constantValue.toString());
|
||||
if (!compilerOptions.removeComments) {
|
||||
var propertyName: string = node.kind === SyntaxKind.PropertyAccessExpression ? declarationNameToString((<PropertyAccessExpression>node).name) : getTextOfNode((<ElementAccessExpression>node).argumentExpression);
|
||||
write(" /* " + propertyName + " */");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -86,6 +86,11 @@ module m1 {
|
||||
|
||||
/// this is x
|
||||
declare var x;
|
||||
|
||||
|
||||
/** const enum member value comment (generated by TS) */
|
||||
const enum color { red, green, blue }
|
||||
var shade: color = color.green;
|
||||
|
||||
|
||||
//// [commentsdoNotEmitComments.js]
|
||||
@ -129,6 +134,7 @@ var m1;
|
||||
})();
|
||||
m1.b = b;
|
||||
})(m1 || (m1 = {}));
|
||||
var shade = 1;
|
||||
|
||||
|
||||
//// [commentsdoNotEmitComments.d.ts]
|
||||
@ -161,3 +167,9 @@ declare module m1 {
|
||||
}
|
||||
}
|
||||
declare var x: any;
|
||||
declare const enum color {
|
||||
red = 0,
|
||||
green = 1,
|
||||
blue = 2,
|
||||
}
|
||||
declare var shade: color;
|
||||
|
||||
@ -151,3 +151,18 @@ module m1 {
|
||||
declare var x;
|
||||
>x : any
|
||||
|
||||
|
||||
/** const enum member value comment (generated by TS) */
|
||||
const enum color { red, green, blue }
|
||||
>color : color
|
||||
>red : color
|
||||
>green : color
|
||||
>blue : color
|
||||
|
||||
var shade: color = color.green;
|
||||
>shade : color
|
||||
>color : color
|
||||
>color.green : color
|
||||
>color : typeof color
|
||||
>green : color
|
||||
|
||||
|
||||
@ -88,3 +88,8 @@ module m1 {
|
||||
|
||||
/// this is x
|
||||
declare var x;
|
||||
|
||||
|
||||
/** const enum member value comment (generated by TS) */
|
||||
const enum color { red, green, blue }
|
||||
var shade: color = color.green;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user