mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Emit commens for enum and enum members
This commit is contained in:
parent
6d6f27cdce
commit
84fa5b421a
@ -1498,6 +1498,7 @@ module ts {
|
||||
}
|
||||
|
||||
function emitEnumDeclaration(node: EnumDeclaration) {
|
||||
emitLeadingComments(node);
|
||||
if (!(node.flags & NodeFlags.Export)) {
|
||||
emitStart(node);
|
||||
write("var ");
|
||||
@ -1516,6 +1517,7 @@ module ts {
|
||||
scopeEmitStart(node);
|
||||
forEach(node.members, member => {
|
||||
writeLine();
|
||||
emitLeadingComments(member);
|
||||
emitStart(member);
|
||||
write(resolver.getLocalNameOfContainer(node));
|
||||
write("[");
|
||||
@ -1533,6 +1535,7 @@ module ts {
|
||||
emitQuotedIdentifier(member.name);
|
||||
emitEnd(member);
|
||||
write(";");
|
||||
emitTrailingComments(member);
|
||||
});
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
@ -1554,6 +1557,7 @@ module ts {
|
||||
emitEnd(node);
|
||||
write(";");
|
||||
}
|
||||
emitTrailingComments(node);
|
||||
}
|
||||
|
||||
function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration: ModuleDeclaration): ModuleDeclaration {
|
||||
|
||||
@ -31,6 +31,7 @@ var r15 = d + null;
|
||||
var r16 = '' + null;
|
||||
|
||||
//// [additionOperatorWithNullValueAndValidOperator.js]
|
||||
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["a"] = 0] = "a";
|
||||
|
||||
@ -39,6 +39,7 @@ function foo<T, U>(t: T, u: U) {
|
||||
}
|
||||
|
||||
//// [additionOperatorWithTypeParameter.js]
|
||||
// type parameter type is not a valid operand of addition operator
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["a"] = 0] = "a";
|
||||
|
||||
@ -31,6 +31,7 @@ var r15 = d + undefined;
|
||||
var r16 = '' + undefined;
|
||||
|
||||
//// [additionOperatorWithUndefinedValueAndValidOperator.js]
|
||||
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["a"] = 0] = "a";
|
||||
|
||||
@ -151,6 +151,7 @@ var rj11 = b | E.b;
|
||||
var rj12 = 1 | E.b;
|
||||
|
||||
//// [arithmeticOperatorWithEnum.js]
|
||||
// operands of an enum type are treated as having the primitive type Number.
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["a"] = 0] = "a";
|
||||
|
||||
@ -582,6 +582,8 @@ var r10h5 = e | E.b;
|
||||
var r10h6 = f | E.b;
|
||||
|
||||
//// [arithmeticOperatorWithInvalidOperands.js]
|
||||
// these operators require their operands to be of type Any, the Number primitive type, or
|
||||
// an enum type
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["a"] = 0] = "a";
|
||||
|
||||
@ -111,6 +111,8 @@ var rj7 = 0 | null;
|
||||
var rj8 = E.b | null;
|
||||
|
||||
//// [arithmeticOperatorWithNullValueAndValidOperands.js]
|
||||
// If one operand is the null or undefined value, it is treated as having the type of the
|
||||
// other operand.
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["a"] = 0] = "a";
|
||||
|
||||
@ -111,6 +111,8 @@ var rj7 = 0 | undefined;
|
||||
var rj8 = E.b | undefined;
|
||||
|
||||
//// [arithmeticOperatorWithUndefinedValueAndValidOperands.js]
|
||||
// If one operand is the undefined or undefined value, it is treated as having the type of the
|
||||
// other operand.
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["a"] = 0] = "a";
|
||||
|
||||
@ -126,6 +126,7 @@ var obj = function (n) { return ''; };
|
||||
var obj;
|
||||
var arr = [function (n) { return ''; }];
|
||||
var arr;
|
||||
// Arrow function as enum value
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["x"] = function () { return 4; }] = "x";
|
||||
@ -161,6 +162,7 @@ var M2;
|
||||
var obj;
|
||||
var arr = [function (n) { return ''; }];
|
||||
var arr;
|
||||
// Arrow function as enum value
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["x"] = function () { return 4; }] = "x";
|
||||
|
||||
@ -36,11 +36,13 @@ module e6b { export var y = 2; } // should be error
|
||||
//import e7 = require(''); // should be error
|
||||
|
||||
//// [augmentedTypesEnum.js]
|
||||
// enum then var
|
||||
var e1111;
|
||||
(function (e1111) {
|
||||
e1111[e1111["One"] = 0] = "One";
|
||||
})(e1111 || (e1111 = {}));
|
||||
var e1111 = 1;
|
||||
// enum then function
|
||||
var e2;
|
||||
(function (e2) {
|
||||
e2[e2["One"] = 0] = "One";
|
||||
@ -53,6 +55,7 @@ var e3;
|
||||
})(e3 || (e3 = {}));
|
||||
var e3 = function () {
|
||||
};
|
||||
// enum then class
|
||||
var e4;
|
||||
(function (e4) {
|
||||
e4[e4["One"] = 0] = "One";
|
||||
@ -64,6 +67,7 @@ var e4 = (function () {
|
||||
};
|
||||
return e4;
|
||||
})();
|
||||
// enum then enum
|
||||
var e5;
|
||||
(function (e5) {
|
||||
e5[e5["One"] = 0] = "One";
|
||||
@ -80,6 +84,7 @@ var e5a;
|
||||
(function (e5a) {
|
||||
e5a[e5a["One"] = 0] = "One";
|
||||
})(e5a || (e5a = {}));
|
||||
// enum then internal module
|
||||
var e6;
|
||||
(function (e6) {
|
||||
e6[e6["One"] = 0] = "One";
|
||||
|
||||
@ -20,10 +20,13 @@ class e2 { // error
|
||||
//enum then import - covered
|
||||
|
||||
//// [augmentedTypesEnum2.js]
|
||||
// enum then interface
|
||||
var e1;
|
||||
(function (e1) {
|
||||
e1[e1["One"] = 0] = "One";
|
||||
})(e1 || (e1 = {}));
|
||||
// interface then enum works
|
||||
// enum then class
|
||||
var e2;
|
||||
(function (e2) {
|
||||
e2[e2["One"] = 0] = "One";
|
||||
|
||||
@ -19,6 +19,7 @@ var ResultIsNumber4 = ~~~(ENUM1[1] + ENUM1[2]);
|
||||
~ENUM1[1], ~ENUM1[2];
|
||||
|
||||
//// [bitwiseNotOperatorWithEnumType.js]
|
||||
// ~ operator on enum type
|
||||
var ENUM1;
|
||||
(function (ENUM1) {
|
||||
ENUM1[ENUM1["1"] = 0] = "1";
|
||||
|
||||
@ -13,9 +13,12 @@ x = Colors.FancyPink;
|
||||
|
||||
|
||||
//// [commentsEnums.js]
|
||||
/** Enum of colors*/
|
||||
var Colors;
|
||||
(function (Colors) {
|
||||
/** Fancy name for 'blue'*/
|
||||
Colors[Colors["Cornflower"] = 0] = "Cornflower";
|
||||
/** Fancy name for 'pink'*/
|
||||
Colors[Colors["FancyPink"] = 1] = "FancyPink";
|
||||
})(Colors || (Colors = {}));
|
||||
var x = 0 /* Cornflower */;
|
||||
|
||||
@ -18,6 +18,7 @@ var x5: void;
|
||||
x5 += '';
|
||||
|
||||
//// [compoundAdditionAssignmentLHSCannotBeAssigned.js]
|
||||
// string can add every type, and result string cannot be assigned to below types
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["a"] = 0] = "a";
|
||||
|
||||
@ -13,6 +13,7 @@ var ResultIsNumber2 = ENUM1[1]--;
|
||||
ENUM1[1]--;
|
||||
|
||||
//// [decrementOperatorWithEnumType.js]
|
||||
// -- operator on enum type
|
||||
var ENUM1;
|
||||
(function (ENUM1) {
|
||||
ENUM1[ENUM1["1"] = 0] = "1";
|
||||
|
||||
@ -23,6 +23,7 @@ ENUM--;
|
||||
ENUM1--;
|
||||
|
||||
//// [decrementOperatorWithEnumTypeInvalidOperations.js]
|
||||
// -- operator on enum type
|
||||
var ENUM;
|
||||
(function (ENUM) {
|
||||
})(ENUM || (ENUM = {}));
|
||||
|
||||
@ -23,6 +23,7 @@ delete ENUM1[1];
|
||||
delete ENUM, ENUM1;
|
||||
|
||||
//// [deleteOperatorWithEnumType.js]
|
||||
// delete operator on enum type
|
||||
var ENUM;
|
||||
(function (ENUM) {
|
||||
})(ENUM || (ENUM = {}));
|
||||
|
||||
@ -55,6 +55,7 @@ module Others {
|
||||
}
|
||||
|
||||
//// [enumAssignability.js]
|
||||
// enums assignable to number, any, Object, errors unless otherwise noted
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["A"] = 0] = "A";
|
||||
|
||||
@ -110,6 +110,7 @@ declare function foo17(x: E): E;
|
||||
var r4 = foo16(E.A);
|
||||
|
||||
//// [enumAssignabilityInInheritance.js]
|
||||
// enum is only a subtype of number, no types are subtypes of enum, all of these except the first are errors
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["A"] = 0] = "A";
|
||||
|
||||
@ -81,6 +81,7 @@ var doPropagate = [
|
||||
|
||||
|
||||
//// [enumBasics.js]
|
||||
// Enum without initializers have first member = 0 and successive members = N + 1
|
||||
var E1;
|
||||
(function (E1) {
|
||||
E1[E1["A"] = 0] = "A";
|
||||
@ -96,24 +97,28 @@ var e;
|
||||
// Reverse mapping of enum returns string name of property
|
||||
var s = E1[0 /* A */];
|
||||
var s;
|
||||
// Enum with only constant members
|
||||
var E2;
|
||||
(function (E2) {
|
||||
E2[E2["A"] = 1] = "A";
|
||||
E2[E2["B"] = 2] = "B";
|
||||
E2[E2["C"] = 3] = "C";
|
||||
})(E2 || (E2 = {}));
|
||||
// Enum with only computed members
|
||||
var E3;
|
||||
(function (E3) {
|
||||
E3[E3["X"] = 'foo'.length] = "X";
|
||||
E3[E3["Y"] = 4 + 3] = "Y";
|
||||
E3[E3["Z"] = +'foo'] = "Z";
|
||||
})(E3 || (E3 = {}));
|
||||
// Enum with constant members followed by computed members
|
||||
var E4;
|
||||
(function (E4) {
|
||||
E4[E4["X"] = 0] = "X";
|
||||
E4[E4["Y"] = 1] = "Y";
|
||||
E4[E4["Z"] = 'foo'.length] = "Z";
|
||||
})(E4 || (E4 = {}));
|
||||
// Enum with > 2 constant members with no initializer for first member, non zero initializer for second element
|
||||
var E5;
|
||||
(function (E5) {
|
||||
E5[E5["A"] = 0] = "A";
|
||||
@ -126,14 +131,17 @@ var E6;
|
||||
E6[E6["B"] = 0] = "B";
|
||||
E6[E6["C"] = 1] = "C";
|
||||
})(E6 || (E6 = {}));
|
||||
// Enum with computed member initializer of type 'any'
|
||||
var E7;
|
||||
(function (E7) {
|
||||
E7[E7["A"] = 'foo'['foo']] = "A";
|
||||
})(E7 || (E7 = {}));
|
||||
// Enum with computed member initializer of type number
|
||||
var E8;
|
||||
(function (E8) {
|
||||
E8[E8["B"] = 'foo'['foo']] = "B";
|
||||
})(E8 || (E8 = {}));
|
||||
//Enum with computed member intializer of same enum type
|
||||
var E9;
|
||||
(function (E9) {
|
||||
E9[E9["A"] = 0] = "A";
|
||||
|
||||
@ -32,6 +32,7 @@ enum E11 {
|
||||
|
||||
|
||||
//// [enumErrors.js]
|
||||
// Enum named with PredefinedTypes
|
||||
var any;
|
||||
(function (any) {
|
||||
})(any || (any = {}));
|
||||
@ -44,6 +45,7 @@ var string;
|
||||
var boolean;
|
||||
(function (boolean) {
|
||||
})(boolean || (boolean = {}));
|
||||
// Enum with computed member initializer of type Number
|
||||
var E5;
|
||||
(function (E5) {
|
||||
E5[E5["C"] = new Number(30)] = "C";
|
||||
@ -53,11 +55,14 @@ var E9;
|
||||
E9[E9["A"] = 0] = "A";
|
||||
E9[E9["B"] = E9.A] = "B";
|
||||
})(E9 || (E9 = {}));
|
||||
//Enum with computed member intializer of different enum type
|
||||
// Bug 707850: This should be allowed
|
||||
var E10;
|
||||
(function (E10) {
|
||||
E10[E10["A"] = 0 /* A */] = "A";
|
||||
E10[E10["B"] = E9.B] = "B";
|
||||
})(E10 || (E10 = {}));
|
||||
// Enum with computed member intializer of other types
|
||||
var E11;
|
||||
(function (E11) {
|
||||
E11[E11["A"] = ''] = "A";
|
||||
|
||||
@ -131,6 +131,7 @@ interface I20 {
|
||||
}
|
||||
|
||||
//// [enumIsNotASubtypeOfAnythingButNumber.js]
|
||||
// enums are only subtypes of number, any and no other types
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["A"] = 0] = "A";
|
||||
|
||||
@ -13,6 +13,7 @@ var ResultIsNumber2 = ENUM1[1]++;
|
||||
ENUM1[1]++;
|
||||
|
||||
//// [incrementOperatorWithEnumType.js]
|
||||
// ++ operator on enum type
|
||||
var ENUM1;
|
||||
(function (ENUM1) {
|
||||
ENUM1[ENUM1["1"] = 0] = "1";
|
||||
|
||||
@ -23,6 +23,7 @@ ENUM++;
|
||||
ENUM1++;
|
||||
|
||||
//// [incrementOperatorWithEnumTypeInvalidOperations.js]
|
||||
// ++ operator on enum type
|
||||
var ENUM;
|
||||
(function (ENUM) {
|
||||
})(ENUM || (ENUM = {}));
|
||||
|
||||
@ -124,6 +124,8 @@ var rj9 = null && undefined;
|
||||
var rj10 = undefined && undefined;
|
||||
|
||||
//// [logicalAndOperatorWithEveryType.js]
|
||||
// The && operator permits the operands to be of any type and produces a result of the same
|
||||
// type as the second operand.
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["a"] = 0] = "a";
|
||||
|
||||
@ -22,6 +22,7 @@ var ResultIsBoolean5 = !!!(ENUM[1] + ENUM[2]);
|
||||
!ENUM, ENUM1;
|
||||
|
||||
//// [logicalNotOperatorWithEnumType.js]
|
||||
// ! operator on enum type
|
||||
var ENUM;
|
||||
(function (ENUM) {
|
||||
ENUM[ENUM["1"] = 0] = "1";
|
||||
|
||||
@ -126,6 +126,10 @@ var rf9 = null || undefined; // null || undefined is any
|
||||
var rf10 = undefined || undefined; // undefined || undefined is any
|
||||
|
||||
//// [logicalOrOperatorWithEveryType.js]
|
||||
// The || operator permits the operands to be of any type.
|
||||
// If the || expression is not contextually typed, the right operand is contextually typed
|
||||
// by the type of the left operand and the result is of the best common type of the two
|
||||
// operand types.
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["a"] = 0] = "a";
|
||||
|
||||
@ -18,6 +18,7 @@ var ResultIsNumber3 = -(ENUM1[1] + ENUM1[2]);
|
||||
-ENUM, ENUM1;
|
||||
|
||||
//// [negateOperatorWithEnumType.js]
|
||||
// - operator on enum type
|
||||
var ENUM;
|
||||
(function (ENUM) {
|
||||
})(ENUM || (ENUM = {}));
|
||||
|
||||
@ -19,6 +19,7 @@ var ResultIsNumber4 = +(ENUM[0] + ENUM1[1]);
|
||||
+ENUM, ENUM1;
|
||||
|
||||
//// [plusOperatorWithEnumType.js]
|
||||
// + operator on enum type
|
||||
var ENUM;
|
||||
(function (ENUM) {
|
||||
})(ENUM || (ENUM = {}));
|
||||
|
||||
@ -28,6 +28,7 @@ z: typeof ENUM;
|
||||
z: typeof ENUM1;
|
||||
|
||||
//// [typeofOperatorWithEnumType.js]
|
||||
// typeof operator on enum type
|
||||
var ENUM;
|
||||
(function (ENUM) {
|
||||
})(ENUM || (ENUM = {}));
|
||||
@ -52,6 +53,7 @@ typeof ENUM;
|
||||
typeof ENUM1;
|
||||
typeof ENUM1[1];
|
||||
typeof ENUM, ENUM1;
|
||||
// use typeof in type query
|
||||
var z;
|
||||
(function (z) {
|
||||
})(z || (z = {}));
|
||||
|
||||
@ -23,6 +23,7 @@ void ENUM1[1];
|
||||
void ENUM, ENUM1;
|
||||
|
||||
//// [voidOperatorWithEnumType.js]
|
||||
// void operator on enum type
|
||||
var ENUM;
|
||||
(function (ENUM) {
|
||||
})(ENUM || (ENUM = {}));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user