mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Enum unification and improvements (#50528)
* Fix enum classification and evaluation * References in literal enums must be to other enum members * Accept new baselines * Unify enum types + template literal constant expressions * Accept new baselines * Fix fourslash tests * Fix new compiler errors * Fix lint error * Accept new API baselines * Fix test * Better error message + consistently check enum initializers * Accept new baselines
This commit is contained in:
1 parent
5a40875fc4
commit
7cf842b42b
99 files changed
+1349
-1418
No files matched your search
+182
-240
@@ -341,7 +341,6 @@ namespace ts {
|
||||
|
||||
let typeCount = 0;
|
||||
let symbolCount = 0;
|
||||
let enumCount = 0;
|
||||
let totalInstantiationCount = 0;
|
||||
let instantiationCount = 0;
|
||||
let instantiationDepth = 0;
|
||||
@@ -4327,6 +4326,12 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function createTypeWithSymbol(flags: TypeFlags, symbol: Symbol): Type {
|
||||
const result = createType(flags);
|
||||
result.symbol = symbol;
|
||||
return result;
|
||||
}
|
||||
|
||||
function createOriginType(flags: TypeFlags): Type {
|
||||
return new Type(checker, flags);
|
||||
}
|
||||
@@ -4339,9 +4344,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createObjectType(objectFlags: ObjectFlags, symbol?: Symbol): ObjectType {
|
||||
const type = createType(TypeFlags.Object) as ObjectType;
|
||||
const type = createTypeWithSymbol(TypeFlags.Object, symbol!) as ObjectType;
|
||||
type.objectFlags = objectFlags;
|
||||
type.symbol = symbol!;
|
||||
type.members = undefined;
|
||||
type.properties = undefined;
|
||||
type.callSignatures = undefined;
|
||||
@@ -4355,9 +4359,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createTypeParameter(symbol?: Symbol) {
|
||||
const type = createType(TypeFlags.TypeParameter) as TypeParameter;
|
||||
if (symbol) type.symbol = symbol;
|
||||
return type;
|
||||
return createTypeWithSymbol(TypeFlags.TypeParameter, symbol!) as TypeParameter;
|
||||
}
|
||||
|
||||
// A reserved member name starts with two underscores, but the third character cannot be an underscore,
|
||||
@@ -5138,31 +5140,31 @@ namespace ts {
|
||||
context.approximateLength += 7;
|
||||
return factory.createKeywordTypeNode(SyntaxKind.BooleanKeyword);
|
||||
}
|
||||
if (type.flags & TypeFlags.EnumLiteral && !(type.flags & TypeFlags.Union)) {
|
||||
const parentSymbol = getParentOfSymbol(type.symbol)!;
|
||||
const parentName = symbolToTypeNode(parentSymbol, context, SymbolFlags.Type);
|
||||
if (getDeclaredTypeOfSymbol(parentSymbol) === type) {
|
||||
return parentName;
|
||||
}
|
||||
const memberName = symbolName(type.symbol);
|
||||
if (isIdentifierText(memberName, ScriptTarget.ES3)) {
|
||||
return appendReferenceToType(
|
||||
parentName as TypeReferenceNode | ImportTypeNode,
|
||||
factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)
|
||||
);
|
||||
}
|
||||
if (isImportTypeNode(parentName)) {
|
||||
(parentName as any).isTypeOf = true; // mutably update, node is freshly manufactured anyhow
|
||||
return factory.createIndexedAccessTypeNode(parentName, factory.createLiteralTypeNode(factory.createStringLiteral(memberName)));
|
||||
}
|
||||
else if (isTypeReferenceNode(parentName)) {
|
||||
return factory.createIndexedAccessTypeNode(factory.createTypeQueryNode(parentName.typeName), factory.createLiteralTypeNode(factory.createStringLiteral(memberName)));
|
||||
}
|
||||
else {
|
||||
return Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`.");
|
||||
}
|
||||
}
|
||||
if (type.flags & TypeFlags.EnumLike) {
|
||||
if (type.symbol.flags & SymbolFlags.EnumMember) {
|
||||
const parentSymbol = getParentOfSymbol(type.symbol)!;
|
||||
const parentName = symbolToTypeNode(parentSymbol, context, SymbolFlags.Type);
|
||||
if (getDeclaredTypeOfSymbol(parentSymbol) === type) {
|
||||
return parentName;
|
||||
}
|
||||
const memberName = symbolName(type.symbol);
|
||||
if (isIdentifierText(memberName, ScriptTarget.ES3)) {
|
||||
return appendReferenceToType(
|
||||
parentName as TypeReferenceNode | ImportTypeNode,
|
||||
factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)
|
||||
);
|
||||
}
|
||||
if (isImportTypeNode(parentName)) {
|
||||
(parentName as any).isTypeOf = true; // mutably update, node is freshly manufactured anyhow
|
||||
return factory.createIndexedAccessTypeNode(parentName, factory.createLiteralTypeNode(factory.createStringLiteral(memberName)));
|
||||
}
|
||||
else if (isTypeReferenceNode(parentName)) {
|
||||
return factory.createIndexedAccessTypeNode(factory.createTypeQueryNode(parentName.typeName), factory.createLiteralTypeNode(factory.createStringLiteral(memberName)));
|
||||
}
|
||||
else {
|
||||
return Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`.");
|
||||
}
|
||||
}
|
||||
return symbolToTypeNode(type.symbol, context, SymbolFlags.Type);
|
||||
}
|
||||
if (type.flags & TypeFlags.StringLiteral) {
|
||||
@@ -10710,97 +10712,41 @@ namespace ts {
|
||||
return links.declaredType;
|
||||
}
|
||||
|
||||
function isStringConcatExpression(expr: Node): boolean {
|
||||
if (isStringLiteralLike(expr)) {
|
||||
return true;
|
||||
}
|
||||
else if (expr.kind === SyntaxKind.BinaryExpression) {
|
||||
return isStringConcatExpression((expr as BinaryExpression).left) && isStringConcatExpression((expr as BinaryExpression).right);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isLiteralEnumMember(member: EnumMember) {
|
||||
const expr = member.initializer;
|
||||
if (!expr) {
|
||||
return !(member.flags & NodeFlags.Ambient);
|
||||
}
|
||||
switch (expr.kind) {
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
return true;
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
return (expr as PrefixUnaryExpression).operator === SyntaxKind.MinusToken &&
|
||||
(expr as PrefixUnaryExpression).operand.kind === SyntaxKind.NumericLiteral;
|
||||
case SyntaxKind.Identifier:
|
||||
return nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports!.get((expr as Identifier).escapedText);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return isStringConcatExpression(expr);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getEnumKind(symbol: Symbol): EnumKind {
|
||||
const links = getSymbolLinks(symbol);
|
||||
if (links.enumKind !== undefined) {
|
||||
return links.enumKind;
|
||||
}
|
||||
let hasNonLiteralMember = false;
|
||||
if (symbol.declarations) {
|
||||
for (const declaration of symbol.declarations) {
|
||||
if (declaration.kind === SyntaxKind.EnumDeclaration) {
|
||||
for (const member of (declaration as EnumDeclaration).members) {
|
||||
if (member.initializer && isStringLiteralLike(member.initializer)) {
|
||||
return links.enumKind = EnumKind.Literal;
|
||||
}
|
||||
if (!isLiteralEnumMember(member)) {
|
||||
hasNonLiteralMember = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return links.enumKind = hasNonLiteralMember ? EnumKind.Numeric : EnumKind.Literal;
|
||||
}
|
||||
|
||||
function getBaseTypeOfEnumLiteralType(type: Type) {
|
||||
return type.flags & TypeFlags.EnumLiteral && !(type.flags & TypeFlags.Union) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)!) : type;
|
||||
}
|
||||
|
||||
function getDeclaredTypeOfEnum(symbol: Symbol): Type {
|
||||
const links = getSymbolLinks(symbol);
|
||||
if (links.declaredType) {
|
||||
return links.declaredType;
|
||||
}
|
||||
if (getEnumKind(symbol) === EnumKind.Literal) {
|
||||
enumCount++;
|
||||
if (!links.declaredType) {
|
||||
const memberTypeList: Type[] = [];
|
||||
if (symbol.declarations) {
|
||||
for (const declaration of symbol.declarations) {
|
||||
if (declaration.kind === SyntaxKind.EnumDeclaration) {
|
||||
for (const member of (declaration as EnumDeclaration).members) {
|
||||
const value = getEnumMemberValue(member);
|
||||
const memberType = getFreshTypeOfLiteralType(getEnumLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member)));
|
||||
getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType;
|
||||
memberTypeList.push(getRegularTypeOfLiteralType(memberType));
|
||||
if (hasBindableName(member)) {
|
||||
const memberSymbol = getSymbolOfNode(member);
|
||||
const value = getEnumMemberValue(member);
|
||||
const memberType = value !== undefined ?
|
||||
getFreshTypeOfLiteralType(getEnumLiteralType(value, getSymbolId(symbol), memberSymbol)) :
|
||||
createTypeWithSymbol(TypeFlags.Enum, memberSymbol);
|
||||
getSymbolLinks(memberSymbol).declaredType = memberType;
|
||||
memberTypeList.push(getRegularTypeOfLiteralType(memberType));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (memberTypeList.length) {
|
||||
const enumType = getUnionType(memberTypeList, UnionReduction.Literal, symbol, /*aliasTypeArguments*/ undefined);
|
||||
if (enumType.flags & TypeFlags.Union) {
|
||||
enumType.flags |= TypeFlags.EnumLiteral;
|
||||
enumType.symbol = symbol;
|
||||
}
|
||||
return links.declaredType = enumType;
|
||||
const enumType = memberTypeList.length ?
|
||||
getUnionType(memberTypeList, UnionReduction.Literal, symbol, /*aliasTypeArguments*/ undefined) :
|
||||
createTypeWithSymbol(TypeFlags.Enum, symbol);
|
||||
if (enumType.flags & TypeFlags.Union) {
|
||||
enumType.flags |= TypeFlags.EnumLiteral;
|
||||
enumType.symbol = symbol;
|
||||
}
|
||||
links.declaredType = enumType;
|
||||
}
|
||||
const enumType = createType(TypeFlags.Enum);
|
||||
enumType.symbol = symbol;
|
||||
return links.declaredType = enumType;
|
||||
return links.declaredType;
|
||||
}
|
||||
|
||||
function getDeclaredTypeOfEnumMember(symbol: Symbol): Type {
|
||||
@@ -13781,8 +13727,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function cloneTypeReference(source: TypeReference): TypeReference {
|
||||
const type = createType(source.flags) as TypeReference;
|
||||
type.symbol = source.symbol;
|
||||
const type = createTypeWithSymbol(source.flags, source.symbol) as TypeReference;
|
||||
type.objectFlags = source.objectFlags;
|
||||
type.target = source.target;
|
||||
type.resolvedTypeArguments = source.resolvedTypeArguments;
|
||||
@@ -15762,8 +15707,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createStringMappingType(symbol: Symbol, type: Type) {
|
||||
const result = createType(TypeFlags.StringMapping) as StringMappingType;
|
||||
result.symbol = symbol;
|
||||
const result = createTypeWithSymbol(TypeFlags.StringMapping, symbol) as StringMappingType;
|
||||
result.type = type;
|
||||
return result;
|
||||
}
|
||||
@@ -16828,8 +16772,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createLiteralType(flags: TypeFlags, value: string | number | PseudoBigInt, symbol?: Symbol, regularType?: LiteralType) {
|
||||
const type = createType(flags) as LiteralType;
|
||||
type.symbol = symbol!;
|
||||
const type = createTypeWithSymbol(flags, symbol!) as LiteralType;
|
||||
type.value = value;
|
||||
type.regularType = regularType || type;
|
||||
return type;
|
||||
@@ -16878,8 +16821,7 @@ namespace ts {
|
||||
|
||||
function getEnumLiteralType(value: string | number, enumId: number, symbol: Symbol): LiteralType {
|
||||
let type;
|
||||
const qualifier = typeof value === "string" ? "@" : "#";
|
||||
const key = enumId + qualifier + value;
|
||||
const key = `${enumId}${typeof value === "string" ? "@" : "#"}${value}`;
|
||||
const flags = TypeFlags.EnumLiteral | (typeof value === "string" ? TypeFlags.StringLiteral : TypeFlags.NumberLiteral);
|
||||
return enumLiteralTypes.get(key) ||
|
||||
(enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type);
|
||||
@@ -16897,8 +16839,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createUniqueESSymbolType(symbol: Symbol) {
|
||||
const type = createType(TypeFlags.UniqueESSymbol) as UniqueESSymbolType;
|
||||
type.symbol = symbol;
|
||||
const type = createTypeWithSymbol(TypeFlags.UniqueESSymbol, symbol) as UniqueESSymbolType;
|
||||
type.escapedName = `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}` as __String;
|
||||
return type;
|
||||
}
|
||||
@@ -18552,19 +18493,20 @@ namespace ts {
|
||||
false;
|
||||
}
|
||||
|
||||
function isEnumTypeRelatedTo(sourceSymbol: Symbol, targetSymbol: Symbol, errorReporter?: ErrorReporter) {
|
||||
function isEnumTypeRelatedTo(source: Symbol, target: Symbol, errorReporter?: ErrorReporter) {
|
||||
const sourceSymbol = source.flags & SymbolFlags.EnumMember ? getParentOfSymbol(source)! : source;
|
||||
const targetSymbol = target.flags & SymbolFlags.EnumMember ? getParentOfSymbol(target)! : target;
|
||||
if (sourceSymbol === targetSymbol) {
|
||||
return true;
|
||||
}
|
||||
if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & SymbolFlags.RegularEnum) || !(targetSymbol.flags & SymbolFlags.RegularEnum)) {
|
||||
return false;
|
||||
}
|
||||
const id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
|
||||
const entry = enumRelation.get(id);
|
||||
if (entry !== undefined && !(!(entry & RelationComparisonResult.Reported) && entry & RelationComparisonResult.Failed && errorReporter)) {
|
||||
return !!(entry & RelationComparisonResult.Succeeded);
|
||||
}
|
||||
if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & SymbolFlags.RegularEnum) || !(targetSymbol.flags & SymbolFlags.RegularEnum)) {
|
||||
enumRelation.set(id, RelationComparisonResult.Failed | RelationComparisonResult.Reported);
|
||||
return false;
|
||||
}
|
||||
const targetEnumType = getTypeOfSymbol(targetSymbol);
|
||||
for (const property of getPropertiesOfType(getTypeOfSymbol(sourceSymbol))) {
|
||||
if (property.flags & SymbolFlags.EnumMember) {
|
||||
@@ -18602,12 +18544,12 @@ namespace ts {
|
||||
if (s & TypeFlags.BigIntLike && t & TypeFlags.BigInt) return true;
|
||||
if (s & TypeFlags.BooleanLike && t & TypeFlags.Boolean) return true;
|
||||
if (s & TypeFlags.ESSymbolLike && t & TypeFlags.ESSymbol) return true;
|
||||
if (s & TypeFlags.Enum && t & TypeFlags.Enum && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
||||
if (s & TypeFlags.Enum && t & TypeFlags.Enum && source.symbol.escapedName === target.symbol.escapedName &&
|
||||
isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
||||
if (s & TypeFlags.EnumLiteral && t & TypeFlags.EnumLiteral) {
|
||||
if (s & TypeFlags.Union && t & TypeFlags.Union && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
||||
if (s & TypeFlags.Literal && t & TypeFlags.Literal &&
|
||||
(source as LiteralType).value === (target as LiteralType).value &&
|
||||
isEnumTypeRelatedTo(getParentOfSymbol(source.symbol)!, getParentOfSymbol(target.symbol)!, errorReporter)) return true;
|
||||
if (s & TypeFlags.Literal && t & TypeFlags.Literal && (source as LiteralType).value === (target as LiteralType).value &&
|
||||
isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;
|
||||
}
|
||||
// In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`.
|
||||
// Since unions and intersections may reduce to `never`, we exclude them here.
|
||||
@@ -22724,7 +22666,7 @@ namespace ts {
|
||||
function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0, contravariant = false) {
|
||||
let bivariant = false;
|
||||
let propagationType: Type;
|
||||
let inferencePriority = InferencePriority.MaxValue;
|
||||
let inferencePriority: number = InferencePriority.MaxValue;
|
||||
let allowComplexConstraintInference = true;
|
||||
let visited: ESMap<string, number>;
|
||||
let sourceStack: object[];
|
||||
@@ -32617,7 +32559,7 @@ namespace ts {
|
||||
if (symbol && symbol.flags & SymbolFlags.Alias) {
|
||||
symbol = resolveAlias(symbol);
|
||||
}
|
||||
return !!(symbol && (getAllSymbolFlags(symbol) & SymbolFlags.Enum) && getEnumKind(symbol) === EnumKind.Literal);
|
||||
return !!(symbol && getAllSymbolFlags(symbol) & SymbolFlags.Enum);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -35045,7 +34987,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkExpressionCached(node: Expression | QualifiedName, checkMode?: CheckMode): Type {
|
||||
if (checkMode && checkMode !== CheckMode.Normal) {
|
||||
if (checkMode) {
|
||||
return checkExpression(node, checkMode);
|
||||
}
|
||||
const links = getNodeLinks(node);
|
||||
@@ -36355,9 +36297,6 @@ namespace ts {
|
||||
symbol.escapedName as string
|
||||
);
|
||||
}
|
||||
if (type.flags & TypeFlags.Enum && symbol.flags & SymbolFlags.EnumMember) {
|
||||
error(node, Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41071,7 +41010,7 @@ namespace ts {
|
||||
}
|
||||
// In ambient non-const numeric enum declarations, enum members without initializers are
|
||||
// considered computed members (as opposed to having auto-incremented values).
|
||||
if (member.parent.flags & NodeFlags.Ambient && !isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === EnumKind.Numeric) {
|
||||
if (member.parent.flags & NodeFlags.Ambient && !isEnumConst(member.parent)) {
|
||||
return undefined;
|
||||
}
|
||||
// If the member declaration specifies no value, the member is considered a constant enum member.
|
||||
@@ -41086,10 +41025,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function computeConstantValue(member: EnumMember): string | number | undefined {
|
||||
const enumKind = getEnumKind(getSymbolOfNode(member.parent));
|
||||
const isConstEnum = isEnumConst(member.parent);
|
||||
const initializer = member.initializer!;
|
||||
const value = enumKind === EnumKind.Literal && !isLiteralEnumMember(member) ? undefined : evaluate(initializer);
|
||||
const value = evaluate(initializer, member);
|
||||
if (value !== undefined) {
|
||||
if (isConstEnum && typeof value === "number" && !isFinite(value)) {
|
||||
error(initializer, isNaN(value) ?
|
||||
@@ -41097,126 +41035,127 @@ namespace ts {
|
||||
Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
|
||||
}
|
||||
}
|
||||
else if (enumKind === EnumKind.Literal) {
|
||||
error(initializer, Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members);
|
||||
return 0;
|
||||
}
|
||||
else if (isConstEnum) {
|
||||
error(initializer, Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
|
||||
error(initializer, Diagnostics.const_enum_member_initializers_must_be_constant_expressions);
|
||||
}
|
||||
else if (member.parent.flags & NodeFlags.Ambient) {
|
||||
error(initializer, Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
|
||||
}
|
||||
else {
|
||||
// Only here do we need to check that the initializer is assignable to the enum type.
|
||||
const source = checkExpression(initializer);
|
||||
if (!isTypeAssignableToKind(source, TypeFlags.NumberLike)) {
|
||||
error(initializer, Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source));
|
||||
}
|
||||
else {
|
||||
checkTypeAssignableTo(source, getDeclaredTypeOfSymbol(getSymbolOfNode(member.parent)), initializer, /*headMessage*/ undefined);
|
||||
}
|
||||
checkTypeAssignableTo(checkExpression(initializer), numberType, initializer, Diagnostics.Type_0_is_not_assignable_to_type_1_as_required_for_computed_enum_member_values);
|
||||
}
|
||||
return value;
|
||||
|
||||
function evaluate(expr: Expression): string | number | undefined {
|
||||
switch (expr.kind) {
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
const value = evaluate((expr as PrefixUnaryExpression).operand);
|
||||
if (typeof value === "number") {
|
||||
switch ((expr as PrefixUnaryExpression).operator) {
|
||||
case SyntaxKind.PlusToken: return value;
|
||||
case SyntaxKind.MinusToken: return -value;
|
||||
case SyntaxKind.TildeToken: return ~value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.BinaryExpression:
|
||||
const left = evaluate((expr as BinaryExpression).left);
|
||||
const right = evaluate((expr as BinaryExpression).right);
|
||||
if (typeof left === "number" && typeof right === "number") {
|
||||
switch ((expr as BinaryExpression).operatorToken.kind) {
|
||||
case SyntaxKind.BarToken: return left | right;
|
||||
case SyntaxKind.AmpersandToken: return left & right;
|
||||
case SyntaxKind.GreaterThanGreaterThanToken: return left >> right;
|
||||
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken: return left >>> right;
|
||||
case SyntaxKind.LessThanLessThanToken: return left << right;
|
||||
case SyntaxKind.CaretToken: return left ^ right;
|
||||
case SyntaxKind.AsteriskToken: return left * right;
|
||||
case SyntaxKind.SlashToken: return left / right;
|
||||
case SyntaxKind.PlusToken: return left + right;
|
||||
case SyntaxKind.MinusToken: return left - right;
|
||||
case SyntaxKind.PercentToken: return left % right;
|
||||
case SyntaxKind.AsteriskAsteriskToken: return left ** right;
|
||||
}
|
||||
}
|
||||
else if (typeof left === "string" && typeof right === "string" && (expr as BinaryExpression).operatorToken.kind === SyntaxKind.PlusToken) {
|
||||
return left + right;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
return (expr as StringLiteralLike).text;
|
||||
case SyntaxKind.NumericLiteral:
|
||||
checkGrammarNumericLiteral(expr as NumericLiteral);
|
||||
return +(expr as NumericLiteral).text;
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return evaluate((expr as ParenthesizedExpression).expression);
|
||||
case SyntaxKind.Identifier:
|
||||
const identifier = expr as Identifier;
|
||||
if (isInfinityOrNaNString(identifier.escapedText)) {
|
||||
return +(identifier.escapedText);
|
||||
}
|
||||
return nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
if (isConstantMemberAccess(expr)) {
|
||||
const type = getTypeOfExpression(expr.expression);
|
||||
if (type.symbol && type.symbol.flags & SymbolFlags.Enum) {
|
||||
let name: __String;
|
||||
if (expr.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
name = expr.name.escapedText;
|
||||
}
|
||||
else {
|
||||
name = escapeLeadingUnderscores(cast(expr.argumentExpression, isLiteralExpression).text);
|
||||
}
|
||||
return evaluateEnumMember(expr, type.symbol, name);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function evaluateEnumMember(expr: Expression, enumSymbol: Symbol, name: __String) {
|
||||
const memberSymbol = enumSymbol.exports!.get(name);
|
||||
if (memberSymbol) {
|
||||
const declaration = memberSymbol.valueDeclaration;
|
||||
if (declaration !== member) {
|
||||
if (declaration && isBlockScopedNameDeclaredBeforeUse(declaration, member) && isEnumDeclaration(declaration.parent)) {
|
||||
return getEnumMemberValue(declaration as EnumMember);
|
||||
}
|
||||
error(expr, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
error(expr, Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(memberSymbol));
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function isConstantMemberAccess(node: Expression): node is AccessExpression {
|
||||
const type = getTypeOfExpression(node);
|
||||
if (type === errorType) {
|
||||
return false;
|
||||
function evaluate(expr: Expression, location: Declaration): string | number | undefined {
|
||||
switch (expr.kind) {
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
const value = evaluate((expr as PrefixUnaryExpression).operand, location);
|
||||
if (typeof value === "number") {
|
||||
switch ((expr as PrefixUnaryExpression).operator) {
|
||||
case SyntaxKind.PlusToken: return value;
|
||||
case SyntaxKind.MinusToken: return -value;
|
||||
case SyntaxKind.TildeToken: return ~value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.BinaryExpression:
|
||||
const left = evaluate((expr as BinaryExpression).left, location);
|
||||
const right = evaluate((expr as BinaryExpression).right, location);
|
||||
if (typeof left === "number" && typeof right === "number") {
|
||||
switch ((expr as BinaryExpression).operatorToken.kind) {
|
||||
case SyntaxKind.BarToken: return left | right;
|
||||
case SyntaxKind.AmpersandToken: return left & right;
|
||||
case SyntaxKind.GreaterThanGreaterThanToken: return left >> right;
|
||||
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken: return left >>> right;
|
||||
case SyntaxKind.LessThanLessThanToken: return left << right;
|
||||
case SyntaxKind.CaretToken: return left ^ right;
|
||||
case SyntaxKind.AsteriskToken: return left * right;
|
||||
case SyntaxKind.SlashToken: return left / right;
|
||||
case SyntaxKind.PlusToken: return left + right;
|
||||
case SyntaxKind.MinusToken: return left - right;
|
||||
case SyntaxKind.PercentToken: return left % right;
|
||||
case SyntaxKind.AsteriskAsteriskToken: return left ** right;
|
||||
}
|
||||
}
|
||||
else if ((typeof left === "string" || typeof left === "number") &&
|
||||
(typeof right === "string" || typeof right === "number") &&
|
||||
(expr as BinaryExpression).operatorToken.kind === SyntaxKind.PlusToken) {
|
||||
return "" + left + right;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
return (expr as StringLiteralLike).text;
|
||||
case SyntaxKind.TemplateExpression:
|
||||
return evaluateTemplateExpression(expr as TemplateExpression, location);
|
||||
case SyntaxKind.NumericLiteral:
|
||||
checkGrammarNumericLiteral(expr as NumericLiteral);
|
||||
return +(expr as NumericLiteral).text;
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return evaluate((expr as ParenthesizedExpression).expression, location);
|
||||
case SyntaxKind.Identifier:
|
||||
if (isInfinityOrNaNString((expr as Identifier).escapedText)) {
|
||||
return +((expr as Identifier).escapedText);
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
if (isEntityNameExpression(expr)) {
|
||||
const symbol = resolveEntityName(expr, SymbolFlags.Value, /*ignoreErrors*/ true);
|
||||
if (symbol) {
|
||||
if (symbol.flags & SymbolFlags.EnumMember) {
|
||||
return evaluateEnumMember(expr, symbol, location);
|
||||
}
|
||||
if (isConstVariable(symbol)) {
|
||||
const declaration = symbol.valueDeclaration as VariableDeclaration | undefined;
|
||||
if (declaration && !declaration.type && declaration.initializer && declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location)) {
|
||||
return evaluate(declaration.initializer, declaration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
const root = (expr as ElementAccessExpression).expression;
|
||||
if (isEntityNameExpression(root) && isStringLiteralLike((expr as ElementAccessExpression).argumentExpression)) {
|
||||
const rootSymbol = resolveEntityName(root, SymbolFlags.Value, /*ignoreErrors*/ true);
|
||||
if (rootSymbol && rootSymbol.flags & SymbolFlags.Enum) {
|
||||
const name = escapeLeadingUnderscores(((expr as ElementAccessExpression).argumentExpression as StringLiteralLike).text);
|
||||
const member = rootSymbol.exports!.get(name);
|
||||
if (member) {
|
||||
return evaluateEnumMember(expr, member, location);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return node.kind === SyntaxKind.Identifier ||
|
||||
node.kind === SyntaxKind.PropertyAccessExpression && isConstantMemberAccess((node as PropertyAccessExpression).expression) ||
|
||||
node.kind === SyntaxKind.ElementAccessExpression && isConstantMemberAccess((node as ElementAccessExpression).expression) &&
|
||||
isStringLiteralLike((node as ElementAccessExpression).argumentExpression);
|
||||
function evaluateEnumMember(expr: Expression, symbol: Symbol, location: Declaration) {
|
||||
const declaration = symbol.valueDeclaration;
|
||||
if (!declaration || declaration === location) {
|
||||
error(expr, Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(symbol));
|
||||
return undefined;
|
||||
}
|
||||
if (!isBlockScopedNameDeclaredBeforeUse(declaration, location)) {
|
||||
error(expr, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
|
||||
return 0;
|
||||
}
|
||||
return getEnumMemberValue(declaration as EnumMember);
|
||||
}
|
||||
|
||||
function evaluateTemplateExpression(expr: TemplateExpression, location: Declaration) {
|
||||
let result = expr.head.text;
|
||||
for (const span of expr.templateSpans) {
|
||||
const value = evaluate(span.expression, location);
|
||||
if (value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
result += value;
|
||||
result += span.literal.text;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function checkEnumDeclaration(node: EnumDeclaration) {
|
||||
@@ -41281,6 +41220,9 @@ namespace ts {
|
||||
if (isPrivateIdentifier(node.name)) {
|
||||
error(node, Diagnostics.An_enum_member_cannot_be_named_with_a_private_identifier);
|
||||
}
|
||||
if (node.initializer) {
|
||||
checkExpression(node.initializer);
|
||||
}
|
||||
}
|
||||
|
||||
function getFirstNonAmbientClassOrFunctionDeclaration(symbol: Symbol): Declaration | undefined {
|
||||
|
||||
@@ -2256,7 +2256,7 @@
|
||||
"category": "Error",
|
||||
"code": 2473
|
||||
},
|
||||
"const enum member initializers can only contain literal values and other computed enum values.": {
|
||||
"const enum member initializers must be constant expressions.": {
|
||||
"category": "Error",
|
||||
"code": 2474
|
||||
},
|
||||
@@ -2480,10 +2480,6 @@
|
||||
"category": "Error",
|
||||
"code": 2534
|
||||
},
|
||||
"Enum type '{0}' has members with initializers that are not literals.": {
|
||||
"category": "Error",
|
||||
"code": 2535
|
||||
},
|
||||
"Type '{0}' cannot be used to index type '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2536
|
||||
@@ -7481,7 +7477,7 @@
|
||||
"category": "Error",
|
||||
"code": 18032
|
||||
},
|
||||
"Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead.": {
|
||||
"Type '{0}' is not assignable to type '{1}' as required for computed enum member values.": {
|
||||
"category": "Error",
|
||||
"code": 18033
|
||||
},
|
||||
|
||||
@@ -3922,8 +3922,8 @@ namespace ts {
|
||||
// is distinguished from a regular type by a flags value of zero. Incomplete type
|
||||
// objects are internal to the getFlowTypeOfReference function and never escape it.
|
||||
export interface IncompleteType {
|
||||
flags: TypeFlags; // No flags set
|
||||
type: Type; // The type marked incomplete
|
||||
flags: TypeFlags | 0; // No flags set
|
||||
type: Type; // The type marked incomplete
|
||||
}
|
||||
|
||||
export interface AmdDependency {
|
||||
@@ -5583,7 +5583,7 @@ namespace ts {
|
||||
String = 1 << 2,
|
||||
Number = 1 << 3,
|
||||
Boolean = 1 << 4,
|
||||
Enum = 1 << 5,
|
||||
Enum = 1 << 5, // Numeric computed enum member value
|
||||
BigInt = 1 << 6,
|
||||
StringLiteral = 1 << 7,
|
||||
NumberLiteral = 1 << 8,
|
||||
|
||||
@@ -82,13 +82,13 @@ declare enum E1 {
|
||||
>E1 : E1
|
||||
|
||||
x,
|
||||
>x : E1
|
||||
>x : E1.x
|
||||
|
||||
y,
|
||||
>y : E1
|
||||
>y : E1.y
|
||||
|
||||
z
|
||||
>z : E1
|
||||
>z : E1.z
|
||||
}
|
||||
|
||||
// Ambient enum with integer literal initializer
|
||||
@@ -96,21 +96,21 @@ declare enum E2 {
|
||||
>E2 : E2
|
||||
|
||||
q,
|
||||
>q : E2
|
||||
>q : E2.q
|
||||
|
||||
a = 1,
|
||||
>a : E2
|
||||
>a : E2.a
|
||||
>1 : 1
|
||||
|
||||
b,
|
||||
>b : E2
|
||||
>b : E2.b
|
||||
|
||||
c = 2,
|
||||
>c : E2
|
||||
>c : E2.c
|
||||
>2 : 2
|
||||
|
||||
d
|
||||
>d : E2
|
||||
>d : E2.d
|
||||
}
|
||||
|
||||
// Ambient enum members are always exported with or without export keyword
|
||||
|
||||
@@ -5,28 +5,28 @@ declare enum E {
|
||||
>E : E
|
||||
|
||||
a = 10,
|
||||
>a : E
|
||||
>a : E.a
|
||||
>10 : 10
|
||||
|
||||
b = 10 + 1,
|
||||
>b : E
|
||||
>b : E.b
|
||||
>10 + 1 : number
|
||||
>10 : 10
|
||||
>1 : 1
|
||||
|
||||
c = b,
|
||||
>c : E
|
||||
>b : E
|
||||
>c : E.b
|
||||
>b : E.b
|
||||
|
||||
d = (c) + 1,
|
||||
>d : E
|
||||
>d : E.d
|
||||
>(c) + 1 : number
|
||||
>(c) : E
|
||||
>c : E
|
||||
>(c) : E.b
|
||||
>c : E.b
|
||||
>1 : 1
|
||||
|
||||
e = 10 << 2 * 8,
|
||||
>e : E
|
||||
>e : E.e
|
||||
>10 << 2 * 8 : number
|
||||
>10 : 10
|
||||
>2 * 8 : number
|
||||
|
||||
@@ -6,18 +6,18 @@ declare enum E {
|
||||
>E : E
|
||||
|
||||
a, // E.a
|
||||
>a : E
|
||||
>a : E.a
|
||||
|
||||
b, // E.b
|
||||
>b : E
|
||||
>b : E.b
|
||||
}
|
||||
|
||||
declare const enum E1 {
|
||||
>E1 : E1
|
||||
|
||||
a, // E.a = 0
|
||||
>a : E1
|
||||
>a : E1.a
|
||||
|
||||
b, // E.b = 1
|
||||
>b : E1
|
||||
>b : E1.b
|
||||
}
|
||||
+1
-1
@@ -2063,7 +2063,7 @@ declare namespace ts {
|
||||
}
|
||||
export type FlowType = Type | IncompleteType;
|
||||
export interface IncompleteType {
|
||||
flags: TypeFlags;
|
||||
flags: TypeFlags | 0;
|
||||
type: Type;
|
||||
}
|
||||
export interface AmdDependency {
|
||||
|
||||
+1
-1
@@ -2063,7 +2063,7 @@ declare namespace ts {
|
||||
}
|
||||
export type FlowType = Type | IncompleteType;
|
||||
export interface IncompleteType {
|
||||
flags: TypeFlags;
|
||||
flags: TypeFlags | 0;
|
||||
type: Type;
|
||||
}
|
||||
export interface AmdDependency {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(2,1): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'.
|
||||
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(30,9): error TS18033: Only numeric enums can have computed members, but this expression has type '() => number'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(30,9): error TS18033: Type '() => number' is not assignable to type 'number' as required for computed enum member values.
|
||||
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(31,16): error TS2332: 'this' cannot be referenced in current location.
|
||||
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(43,5): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'.
|
||||
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(71,13): error TS18033: Only numeric enums can have computed members, but this expression has type '() => number'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(71,13): error TS18033: Type '() => number' is not assignable to type 'number' as required for computed enum member values.
|
||||
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(72,20): error TS2332: 'this' cannot be referenced in current location.
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(72,20): e
|
||||
enum E {
|
||||
x = () => 4, // Error expected
|
||||
~~~~~~~
|
||||
!!! error TS18033: Only numeric enums can have computed members, but this expression has type '() => number'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
!!! error TS18033: Type '() => number' is not assignable to type 'number' as required for computed enum member values.
|
||||
y = (() => this).length // error, can't use this in enum
|
||||
~~~~
|
||||
!!! error TS2332: 'this' cannot be referenced in current location.
|
||||
@@ -87,7 +87,7 @@ tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(72,20): e
|
||||
enum E {
|
||||
x = () => 4, // Error expected
|
||||
~~~~~~~
|
||||
!!! error TS18033: Only numeric enums can have computed members, but this expression has type '() => number'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
!!! error TS18033: Type '() => number' is not assignable to type 'number' as required for computed enum member values.
|
||||
y = (() => this).length
|
||||
~~~~
|
||||
!!! error TS2332: 'this' cannot be referenced in current location.
|
||||
|
||||
@@ -68,12 +68,12 @@ enum E {
|
||||
>E : E
|
||||
|
||||
x = () => 4, // Error expected
|
||||
>x : E
|
||||
>x : E.x
|
||||
>() => 4 : () => number
|
||||
>4 : 4
|
||||
|
||||
y = (() => this).length // error, can't use this in enum
|
||||
>y : E
|
||||
>y : E.y
|
||||
>(() => this).length : number
|
||||
>(() => this) : () => any
|
||||
>() => this : () => any
|
||||
@@ -171,12 +171,12 @@ module M2 {
|
||||
>E : E
|
||||
|
||||
x = () => 4, // Error expected
|
||||
>x : E
|
||||
>x : E.x
|
||||
>() => 4 : () => number
|
||||
>4 : 4
|
||||
|
||||
y = (() => this).length
|
||||
>y : E
|
||||
>y : E.y
|
||||
>(() => this).length : number
|
||||
>(() => this) : () => any
|
||||
>() => this : () => any
|
||||
|
||||
@@ -3,19 +3,19 @@ export declare enum require {
|
||||
>require : require
|
||||
|
||||
_thisVal1,
|
||||
>_thisVal1 : require
|
||||
>_thisVal1 : require._thisVal1
|
||||
|
||||
_thisVal2,
|
||||
>_thisVal2 : require
|
||||
>_thisVal2 : require._thisVal2
|
||||
}
|
||||
export declare enum exports {
|
||||
>exports : exports
|
||||
|
||||
_thisVal1,
|
||||
>_thisVal1 : exports
|
||||
>_thisVal1 : exports._thisVal1
|
||||
|
||||
_thisVal2,
|
||||
>_thisVal2 : exports
|
||||
>_thisVal2 : exports._thisVal2
|
||||
}
|
||||
declare module m1 {
|
||||
>m1 : typeof m1
|
||||
@@ -24,19 +24,19 @@ declare module m1 {
|
||||
>require : require
|
||||
|
||||
_thisVal1,
|
||||
>_thisVal1 : require
|
||||
>_thisVal1 : require._thisVal1
|
||||
|
||||
_thisVal2,
|
||||
>_thisVal2 : require
|
||||
>_thisVal2 : require._thisVal2
|
||||
}
|
||||
enum exports {
|
||||
>exports : exports
|
||||
|
||||
_thisVal1,
|
||||
>_thisVal1 : exports
|
||||
>_thisVal1 : exports._thisVal1
|
||||
|
||||
_thisVal2,
|
||||
>_thisVal2 : exports
|
||||
>_thisVal2 : exports._thisVal2
|
||||
}
|
||||
}
|
||||
module m2 {
|
||||
@@ -46,19 +46,19 @@ module m2 {
|
||||
>require : require
|
||||
|
||||
_thisVal1,
|
||||
>_thisVal1 : require
|
||||
>_thisVal1 : require._thisVal1
|
||||
|
||||
_thisVal2,
|
||||
>_thisVal2 : require
|
||||
>_thisVal2 : require._thisVal2
|
||||
}
|
||||
export declare enum exports {
|
||||
>exports : exports
|
||||
|
||||
_thisVal1,
|
||||
>_thisVal1 : exports
|
||||
>_thisVal1 : exports._thisVal1
|
||||
|
||||
_thisVal2,
|
||||
>_thisVal2 : exports
|
||||
>_thisVal2 : exports._thisVal2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,19 +67,19 @@ declare enum require {
|
||||
>require : require
|
||||
|
||||
_thisVal1,
|
||||
>_thisVal1 : require
|
||||
>_thisVal1 : require._thisVal1
|
||||
|
||||
_thisVal2,
|
||||
>_thisVal2 : require
|
||||
>_thisVal2 : require._thisVal2
|
||||
}
|
||||
declare enum exports {
|
||||
>exports : exports
|
||||
|
||||
_thisVal1,
|
||||
>_thisVal1 : exports
|
||||
>_thisVal1 : exports._thisVal1
|
||||
|
||||
_thisVal2,
|
||||
>_thisVal2 : exports
|
||||
>_thisVal2 : exports._thisVal2
|
||||
}
|
||||
declare module m3 {
|
||||
>m3 : typeof m3
|
||||
@@ -88,19 +88,19 @@ declare module m3 {
|
||||
>require : require
|
||||
|
||||
_thisVal1,
|
||||
>_thisVal1 : require
|
||||
>_thisVal1 : require._thisVal1
|
||||
|
||||
_thisVal2,
|
||||
>_thisVal2 : require
|
||||
>_thisVal2 : require._thisVal2
|
||||
}
|
||||
enum exports {
|
||||
>exports : exports
|
||||
|
||||
_thisVal1,
|
||||
>_thisVal1 : exports
|
||||
>_thisVal1 : exports._thisVal1
|
||||
|
||||
_thisVal2,
|
||||
>_thisVal2 : exports
|
||||
>_thisVal2 : exports._thisVal2
|
||||
}
|
||||
}
|
||||
module m4 {
|
||||
@@ -110,18 +110,18 @@ module m4 {
|
||||
>require : require
|
||||
|
||||
_thisVal1,
|
||||
>_thisVal1 : require
|
||||
>_thisVal1 : require._thisVal1
|
||||
|
||||
_thisVal2,
|
||||
>_thisVal2 : require
|
||||
>_thisVal2 : require._thisVal2
|
||||
}
|
||||
export declare enum exports {
|
||||
>exports : exports
|
||||
|
||||
_thisVal1,
|
||||
>_thisVal1 : exports
|
||||
>_thisVal1 : exports._thisVal1
|
||||
|
||||
_thisVal2,
|
||||
>_thisVal2 : exports
|
||||
>_thisVal2 : exports._thisVal2
|
||||
}
|
||||
}
|
||||
@@ -14,13 +14,13 @@ declare enum C {
|
||||
>C : C
|
||||
|
||||
a,
|
||||
>a : C
|
||||
>a : C.a
|
||||
|
||||
b,
|
||||
>b : C
|
||||
>b : C.b
|
||||
|
||||
c
|
||||
>c : C
|
||||
>c : C.c
|
||||
}
|
||||
|
||||
// Don't keep this comment.
|
||||
|
||||
@@ -7,47 +7,47 @@ const enum E {
|
||||
>E : E
|
||||
|
||||
a = 10,
|
||||
>a : E
|
||||
>a : E.a
|
||||
>10 : 10
|
||||
|
||||
b = a,
|
||||
>b : E
|
||||
>a : E
|
||||
>b : E.a
|
||||
>a : E.a
|
||||
|
||||
c = (a+1),
|
||||
>c : E
|
||||
>c : E.c
|
||||
>(a+1) : number
|
||||
>a+1 : number
|
||||
>a : E
|
||||
>a : E.a
|
||||
>1 : 1
|
||||
|
||||
e,
|
||||
>e : E
|
||||
>e : E.e
|
||||
|
||||
d = ~e,
|
||||
>d : E
|
||||
>d : E.d
|
||||
>~e : number
|
||||
>e : E
|
||||
>e : E.e
|
||||
|
||||
f = a << 2 >> 1,
|
||||
>f : E
|
||||
>f : E.f
|
||||
>a << 2 >> 1 : number
|
||||
>a << 2 : number
|
||||
>a : E
|
||||
>a : E.a
|
||||
>2 : 2
|
||||
>1 : 1
|
||||
|
||||
g = a << 2 >>> 1,
|
||||
>g : E
|
||||
>g : E.f
|
||||
>a << 2 >>> 1 : number
|
||||
>a << 2 : number
|
||||
>a : E
|
||||
>a : E.a
|
||||
>2 : 2
|
||||
>1 : 1
|
||||
|
||||
h = a | b
|
||||
>h : E
|
||||
>h : E.a
|
||||
>a | b : number
|
||||
>a : E
|
||||
>b : E
|
||||
>a : E.a
|
||||
>b : E.a
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
tests/cases/conformance/constEnums/constEnum2.ts(10,9): error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
tests/cases/conformance/constEnums/constEnum2.ts(11,9): error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
tests/cases/conformance/constEnums/constEnum2.ts(12,5): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/constEnums/constEnum2.ts(12,9): error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
tests/cases/conformance/constEnums/constEnum2.ts(10,9): error TS2474: const enum member initializers must be constant expressions.
|
||||
tests/cases/conformance/constEnums/constEnum2.ts(11,9): error TS2474: const enum member initializers must be constant expressions.
|
||||
|
||||
|
||||
==== tests/cases/conformance/constEnums/constEnum2.ts (4 errors) ====
|
||||
==== tests/cases/conformance/constEnums/constEnum2.ts (2 errors) ====
|
||||
// An enum declaration that specifies a const modifier is a constant enum declaration.
|
||||
// In a constant enum declaration, all members must have constant values and
|
||||
// it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression.
|
||||
@@ -16,13 +14,9 @@ tests/cases/conformance/constEnums/constEnum2.ts(12,9): error TS2474: const enum
|
||||
d = 10,
|
||||
e = 199 * Math.floor(Math.random() * 1000),
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
f = d - (100 * Math.floor(Math.random() % 8))
|
||||
!!! error TS2474: const enum member initializers must be constant expressions.
|
||||
f = d - (100 * Math.floor(Math.random() % 8)),
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
!!! error TS2474: const enum member initializers must be constant expressions.
|
||||
g = CONST,
|
||||
~
|
||||
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
~~~~~
|
||||
!!! error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
}
|
||||
@@ -9,7 +9,7 @@ const CONST = 9000 % 2;
|
||||
const enum D {
|
||||
d = 10,
|
||||
e = 199 * Math.floor(Math.random() * 1000),
|
||||
f = d - (100 * Math.floor(Math.random() % 8))
|
||||
f = d - (100 * Math.floor(Math.random() % 8)),
|
||||
g = CONST,
|
||||
}
|
||||
|
||||
@@ -27,5 +27,5 @@ declare const enum D {
|
||||
d = 10,
|
||||
e,
|
||||
f,
|
||||
g
|
||||
g = 0
|
||||
}
|
||||
@@ -23,7 +23,7 @@ const enum D {
|
||||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
f = d - (100 * Math.floor(Math.random() % 8))
|
||||
f = d - (100 * Math.floor(Math.random() % 8)),
|
||||
>f : Symbol(D.f, Decl(constEnum2.ts, 9, 47))
|
||||
>d : Symbol(D.d, Decl(constEnum2.ts, 7, 14))
|
||||
>Math.floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --))
|
||||
@@ -34,6 +34,6 @@ const enum D {
|
||||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
g = CONST,
|
||||
>g : Symbol(D.g, Decl(constEnum2.ts, 10, 49))
|
||||
>g : Symbol(D.g, Decl(constEnum2.ts, 10, 50))
|
||||
>CONST : Symbol(CONST, Decl(constEnum2.ts, 6, 5))
|
||||
}
|
||||
@@ -15,11 +15,11 @@ const enum D {
|
||||
>D : D
|
||||
|
||||
d = 10,
|
||||
>d : D
|
||||
>d : D.d
|
||||
>10 : 10
|
||||
|
||||
e = 199 * Math.floor(Math.random() * 1000),
|
||||
>e : D
|
||||
>e : D.e
|
||||
>199 * Math.floor(Math.random() * 1000) : number
|
||||
>199 : 199
|
||||
>Math.floor(Math.random() * 1000) : number
|
||||
@@ -33,10 +33,10 @@ const enum D {
|
||||
>random : () => number
|
||||
>1000 : 1000
|
||||
|
||||
f = d - (100 * Math.floor(Math.random() % 8))
|
||||
>f : D
|
||||
f = d - (100 * Math.floor(Math.random() % 8)),
|
||||
>f : D.f
|
||||
>d - (100 * Math.floor(Math.random() % 8)) : number
|
||||
>d : D
|
||||
>d : D.d
|
||||
>(100 * Math.floor(Math.random() % 8)) : number
|
||||
>100 * Math.floor(Math.random() % 8) : number
|
||||
>100 : 100
|
||||
@@ -52,6 +52,6 @@ const enum D {
|
||||
>8 : 8
|
||||
|
||||
g = CONST,
|
||||
>g : D
|
||||
>g : D.g
|
||||
>CONST : number
|
||||
}
|
||||
@@ -3,18 +3,18 @@ const enum E {
|
||||
>E : E
|
||||
|
||||
A = 1,
|
||||
>A : E
|
||||
>A : E.A
|
||||
>1 : 1
|
||||
|
||||
B = 2,
|
||||
>B : E
|
||||
>B : E.B
|
||||
>2 : 2
|
||||
|
||||
C = A | B
|
||||
>C : E
|
||||
>C : E.C
|
||||
>A | B : number
|
||||
>A : E
|
||||
>B : E
|
||||
>A : E.A
|
||||
>B : E.B
|
||||
}
|
||||
|
||||
const enum E2 {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/compiler/constEnumErrors.ts(1,12): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
|
||||
tests/cases/compiler/constEnumErrors.ts(5,8): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
|
||||
tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
|
||||
tests/cases/compiler/constEnumErrors.ts(14,9): error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
tests/cases/compiler/constEnumErrors.ts(14,9): error TS2474: const enum member initializers must be constant expressions.
|
||||
tests/cases/compiler/constEnumErrors.ts(14,12): error TS2339: Property 'Z' does not exist on type 'typeof E1'.
|
||||
tests/cases/compiler/constEnumErrors.ts(15,10): error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
tests/cases/compiler/constEnumErrors.ts(15,10): error TS2474: const enum member initializers must be constant expressions.
|
||||
tests/cases/compiler/constEnumErrors.ts(15,13): error TS2339: Property 'Z' does not exist on type 'typeof E1'.
|
||||
tests/cases/compiler/constEnumErrors.ts(22,13): error TS2476: A const enum member can only be accessed using a string literal.
|
||||
tests/cases/compiler/constEnumErrors.ts(24,13): error TS2476: A const enum member can only be accessed using a string literal.
|
||||
@@ -38,12 +38,12 @@ tests/cases/compiler/constEnumErrors.ts(43,9): error TS2478: 'const' enum member
|
||||
// forward reference to the element of the same enum
|
||||
Y = E1.Z,
|
||||
~~~~
|
||||
!!! error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
!!! error TS2474: const enum member initializers must be constant expressions.
|
||||
~
|
||||
!!! error TS2339: Property 'Z' does not exist on type 'typeof E1'.
|
||||
Y1 = E1["Z"]
|
||||
~~~~~~~
|
||||
!!! error TS2474: const enum member initializers can only contain literal values and other computed enum values.
|
||||
!!! error TS2474: const enum member initializers must be constant expressions.
|
||||
~~~
|
||||
!!! error TS2339: Property 'Z' does not exist on type 'typeof E1'.
|
||||
}
|
||||
|
||||
@@ -20,18 +20,18 @@ const enum E1 {
|
||||
// illegal case
|
||||
// forward reference to the element of the same enum
|
||||
X = Y,
|
||||
>X : E1
|
||||
>Y : E1
|
||||
>X : E1.X
|
||||
>Y : E1.Y
|
||||
|
||||
// forward reference to the element of the same enum
|
||||
Y = E1.Z,
|
||||
>Y : E1
|
||||
>Y : E1.Y
|
||||
>E1.Z : any
|
||||
>E1 : typeof E1
|
||||
>Z : any
|
||||
|
||||
Y1 = E1["Z"]
|
||||
>Y1 : E1
|
||||
>Y1 : E1.Y1
|
||||
>E1["Z"] : any
|
||||
>E1 : typeof E1
|
||||
>"Z" : "Z"
|
||||
@@ -90,47 +90,47 @@ const enum NaNOrInfinity {
|
||||
>NaNOrInfinity : NaNOrInfinity
|
||||
|
||||
A = 9007199254740992,
|
||||
>A : NaNOrInfinity
|
||||
>A : NaNOrInfinity.A
|
||||
>9007199254740992 : 9007199254740992
|
||||
|
||||
B = A * A,
|
||||
>B : NaNOrInfinity
|
||||
>B : NaNOrInfinity.B
|
||||
>A * A : number
|
||||
>A : NaNOrInfinity
|
||||
>A : NaNOrInfinity
|
||||
>A : NaNOrInfinity.A
|
||||
>A : NaNOrInfinity.A
|
||||
|
||||
C = B * B,
|
||||
>C : NaNOrInfinity
|
||||
>C : NaNOrInfinity.C
|
||||
>B * B : number
|
||||
>B : NaNOrInfinity
|
||||
>B : NaNOrInfinity
|
||||
>B : NaNOrInfinity.B
|
||||
>B : NaNOrInfinity.B
|
||||
|
||||
D = C * C,
|
||||
>D : NaNOrInfinity
|
||||
>D : NaNOrInfinity.D
|
||||
>C * C : number
|
||||
>C : NaNOrInfinity
|
||||
>C : NaNOrInfinity
|
||||
>C : NaNOrInfinity.C
|
||||
>C : NaNOrInfinity.C
|
||||
|
||||
E = D * D,
|
||||
>E : NaNOrInfinity
|
||||
>E : NaNOrInfinity.E
|
||||
>D * D : number
|
||||
>D : NaNOrInfinity
|
||||
>D : NaNOrInfinity
|
||||
>D : NaNOrInfinity.D
|
||||
>D : NaNOrInfinity.D
|
||||
|
||||
F = E * E, // overflow
|
||||
>F : NaNOrInfinity
|
||||
>F : NaNOrInfinity.F
|
||||
>E * E : number
|
||||
>E : NaNOrInfinity
|
||||
>E : NaNOrInfinity
|
||||
>E : NaNOrInfinity.E
|
||||
>E : NaNOrInfinity.E
|
||||
|
||||
G = 1 / 0, // overflow
|
||||
>G : NaNOrInfinity
|
||||
>G : NaNOrInfinity.F
|
||||
>1 / 0 : number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
|
||||
H = 0 / 0 // NaN
|
||||
>H : NaNOrInfinity
|
||||
>H : NaNOrInfinity.H
|
||||
>0 / 0 : number
|
||||
>0 : 0
|
||||
>0 : 0
|
||||
|
||||
@@ -3,10 +3,10 @@ export const enum MyConstEnum {
|
||||
>MyConstEnum : MyConstEnum
|
||||
|
||||
Foo,
|
||||
>Foo : MyConstEnum
|
||||
>Foo : MyConstEnum.Foo
|
||||
|
||||
Bar
|
||||
>Bar : MyConstEnum
|
||||
>Bar : MyConstEnum.Bar
|
||||
}
|
||||
=== tests/cases/compiler/ImportExport.d.ts ===
|
||||
import { MyConstEnum } from './ConstEnum';
|
||||
@@ -31,17 +31,17 @@ import StillEnum from "./ReExport";
|
||||
>StillEnum : typeof MyConstEnum
|
||||
|
||||
MyConstEnum.Foo;
|
||||
>MyConstEnum.Foo : MyConstEnum
|
||||
>MyConstEnum.Foo : MyConstEnum.Foo
|
||||
>MyConstEnum : typeof MyConstEnum
|
||||
>Foo : MyConstEnum
|
||||
>Foo : MyConstEnum.Foo
|
||||
|
||||
AlsoEnum.Foo;
|
||||
>AlsoEnum.Foo : MyConstEnum
|
||||
>AlsoEnum.Foo : MyConstEnum.Foo
|
||||
>AlsoEnum : typeof MyConstEnum
|
||||
>Foo : MyConstEnum
|
||||
>Foo : MyConstEnum.Foo
|
||||
|
||||
StillEnum.Foo;
|
||||
>StillEnum.Foo : MyConstEnum
|
||||
>StillEnum.Foo : MyConstEnum.Foo
|
||||
>StillEnum : typeof MyConstEnum
|
||||
>Foo : MyConstEnum
|
||||
>Foo : MyConstEnum.Foo
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
tests/cases/conformance/constEnums/constEnumPropertyAccess1.ts(25,9): error TS2322: Type 'boolean' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/constEnums/constEnumPropertyAccess1.ts (1 errors) ====
|
||||
// constant enum declarations are completely erased in the emitted JavaScript code.
|
||||
// it is an error to reference a constant enum object in any other context
|
||||
// than a property access that selects one of the enum's members
|
||||
|
||||
const enum G {
|
||||
A = 1,
|
||||
B = 2,
|
||||
C = A + B,
|
||||
D = A * 2
|
||||
}
|
||||
|
||||
var o: {
|
||||
[idx: number]: boolean
|
||||
} = {
|
||||
1: true
|
||||
};
|
||||
|
||||
var a = G.A;
|
||||
var a1 = G["A"];
|
||||
var g = o[G.A];
|
||||
|
||||
class C {
|
||||
[G.A]() { }
|
||||
get [G.B]() {
|
||||
return true;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'number'.
|
||||
}
|
||||
set [G.B](x: number) { }
|
||||
}
|
||||
|
||||
|
||||
@@ -63,4 +63,7 @@ declare var a: G;
|
||||
declare var a1: G;
|
||||
declare var g: boolean;
|
||||
declare class C {
|
||||
[G.A](): void;
|
||||
get [G.B](): number;
|
||||
set [G.B](x: number);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class C {
|
||||
>A : Symbol(G.A, Decl(constEnumPropertyAccess1.ts, 4, 14))
|
||||
|
||||
get [G.B]() {
|
||||
>[G.B] : Symbol(C[G.B], Decl(constEnumPropertyAccess1.ts, 22, 15))
|
||||
>[G.B] : Symbol(C[G.B], Decl(constEnumPropertyAccess1.ts, 22, 15), Decl(constEnumPropertyAccess1.ts, 25, 5))
|
||||
>G.B : Symbol(G.B, Decl(constEnumPropertyAccess1.ts, 5, 10))
|
||||
>G : Symbol(G, Decl(constEnumPropertyAccess1.ts, 0, 0))
|
||||
>B : Symbol(G.B, Decl(constEnumPropertyAccess1.ts, 5, 10))
|
||||
@@ -70,7 +70,7 @@ class C {
|
||||
return true;
|
||||
}
|
||||
set [G.B](x: number) { }
|
||||
>[G.B] : Symbol(C[G.B], Decl(constEnumPropertyAccess1.ts, 25, 5))
|
||||
>[G.B] : Symbol(C[G.B], Decl(constEnumPropertyAccess1.ts, 22, 15), Decl(constEnumPropertyAccess1.ts, 25, 5))
|
||||
>G.B : Symbol(G.B, Decl(constEnumPropertyAccess1.ts, 5, 10))
|
||||
>G : Symbol(G, Decl(constEnumPropertyAccess1.ts, 0, 0))
|
||||
>B : Symbol(G.B, Decl(constEnumPropertyAccess1.ts, 5, 10))
|
||||
|
||||
@@ -7,23 +7,23 @@ const enum G {
|
||||
>G : G
|
||||
|
||||
A = 1,
|
||||
>A : G
|
||||
>A : G.A
|
||||
>1 : 1
|
||||
|
||||
B = 2,
|
||||
>B : G
|
||||
>B : G.B
|
||||
>2 : 2
|
||||
|
||||
C = A + B,
|
||||
>C : G
|
||||
>C : G.C
|
||||
>A + B : number
|
||||
>A : G
|
||||
>B : G
|
||||
>A : G.A
|
||||
>B : G.B
|
||||
|
||||
D = A * 2
|
||||
>D : G
|
||||
>D : G.B
|
||||
>A * 2 : number
|
||||
>A : G
|
||||
>A : G.A
|
||||
>2 : 2
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ var o: {
|
||||
|
||||
var a = G.A;
|
||||
>a : G
|
||||
>G.A : G
|
||||
>G.A : G.A
|
||||
>G : typeof G
|
||||
>A : G
|
||||
>A : G.A
|
||||
|
||||
var a1 = G["A"];
|
||||
>a1 : G
|
||||
>G["A"] : G
|
||||
>G["A"] : G.A
|
||||
>G : typeof G
|
||||
>"A" : "A"
|
||||
|
||||
@@ -58,33 +58,33 @@ var g = o[G.A];
|
||||
>g : boolean
|
||||
>o[G.A] : boolean
|
||||
>o : { [idx: number]: boolean; }
|
||||
>G.A : G
|
||||
>G.A : G.A
|
||||
>G : typeof G
|
||||
>A : G
|
||||
>A : G.A
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[G.A]() { }
|
||||
>[G.A] : () => void
|
||||
>G.A : G
|
||||
>G.A : G.A
|
||||
>G : typeof G
|
||||
>A : G
|
||||
>A : G.A
|
||||
|
||||
get [G.B]() {
|
||||
>[G.B] : boolean
|
||||
>G.B : G
|
||||
>[G.B] : number
|
||||
>G.B : G.B
|
||||
>G : typeof G
|
||||
>B : G
|
||||
>B : G.B
|
||||
|
||||
return true;
|
||||
>true : true
|
||||
}
|
||||
set [G.B](x: number) { }
|
||||
>[G.B] : number
|
||||
>G.B : G
|
||||
>G.B : G.B
|
||||
>G : typeof G
|
||||
>B : G
|
||||
>B : G.B
|
||||
>x : number
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(13,9): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
|
||||
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(14,12): error TS2476: A const enum member can only be accessed using a string literal.
|
||||
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(16,1): error TS2322: Type 'string' is not assignable to type 'G'.
|
||||
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(16,1): error TS2322: Type '"string"' is not assignable to type 'G'.
|
||||
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(18,3): error TS2540: Cannot assign to 'B' because it is a read-only property.
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(18,3): error TS25
|
||||
var g: G;
|
||||
g = "string";
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'G'.
|
||||
!!! error TS2322: Type '"string"' is not assignable to type 'G'.
|
||||
function foo(x: G) { }
|
||||
G.B = 3;
|
||||
~
|
||||
|
||||
@@ -7,23 +7,23 @@ const enum G {
|
||||
>G : G
|
||||
|
||||
A = 1,
|
||||
>A : G
|
||||
>A : G.A
|
||||
>1 : 1
|
||||
|
||||
B = 2,
|
||||
>B : G
|
||||
>B : G.B
|
||||
>2 : 2
|
||||
|
||||
C = A + B,
|
||||
>C : G
|
||||
>C : G.C
|
||||
>A + B : number
|
||||
>A : G
|
||||
>B : G
|
||||
>A : G.A
|
||||
>B : G.B
|
||||
|
||||
D = A * 2
|
||||
>D : G
|
||||
>D : G.B
|
||||
>A * 2 : number
|
||||
>A : G
|
||||
>A : G.A
|
||||
>2 : 2
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ var z1 = G[G.A];
|
||||
>z1 : any
|
||||
>G[G.A] : any
|
||||
>G : typeof G
|
||||
>G.A : G
|
||||
>G.A : G.A
|
||||
>G : typeof G
|
||||
>A : G
|
||||
>A : G.A
|
||||
|
||||
var g: G;
|
||||
>g : G
|
||||
|
||||
@@ -3,7 +3,7 @@ const enum Enum1 {
|
||||
>Enum1 : Enum1
|
||||
|
||||
A0 = 100,
|
||||
>A0 : Enum1
|
||||
>A0 : Enum1.A0
|
||||
>100 : 100
|
||||
}
|
||||
|
||||
@@ -12,62 +12,62 @@ const enum Enum1 {
|
||||
|
||||
// correct cases
|
||||
A,
|
||||
>A : Enum1
|
||||
>A : Enum1.A
|
||||
|
||||
B,
|
||||
>B : Enum1
|
||||
>B : Enum1.B
|
||||
|
||||
C = 10,
|
||||
>C : Enum1
|
||||
>C : Enum1.C
|
||||
>10 : 10
|
||||
|
||||
D = A | B,
|
||||
>D : Enum1
|
||||
>D : Enum1.B
|
||||
>A | B : number
|
||||
>A : Enum1
|
||||
>B : Enum1
|
||||
>A : Enum1.A
|
||||
>B : Enum1.B
|
||||
|
||||
E = A | 1,
|
||||
>E : Enum1
|
||||
>E : Enum1.B
|
||||
>A | 1 : number
|
||||
>A : Enum1
|
||||
>A : Enum1.A
|
||||
>1 : 1
|
||||
|
||||
F = 1 | A,
|
||||
>F : Enum1
|
||||
>F : Enum1.B
|
||||
>1 | A : number
|
||||
>1 : 1
|
||||
>A : Enum1
|
||||
>A : Enum1.A
|
||||
|
||||
G = (1 & 1),
|
||||
>G : Enum1
|
||||
>G : Enum1.B
|
||||
>(1 & 1) : number
|
||||
>1 & 1 : number
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
|
||||
H = ~(A | B),
|
||||
>H : Enum1
|
||||
>H : Enum1.H
|
||||
>~(A | B) : number
|
||||
>(A | B) : number
|
||||
>A | B : number
|
||||
>A : Enum1
|
||||
>B : Enum1
|
||||
>A : Enum1.A
|
||||
>B : Enum1.B
|
||||
|
||||
I = A >>> 1,
|
||||
>I : Enum1
|
||||
>I : Enum1.A
|
||||
>A >>> 1 : number
|
||||
>A : Enum1
|
||||
>A : Enum1.A
|
||||
>1 : 1
|
||||
|
||||
J = 1 & A,
|
||||
>J : Enum1
|
||||
>J : Enum1.A
|
||||
>1 & A : number
|
||||
>1 : 1
|
||||
>A : Enum1
|
||||
>A : Enum1.A
|
||||
|
||||
K = ~(1 | 5),
|
||||
>K : Enum1
|
||||
>K : Enum1.K
|
||||
>~(1 | 5) : number
|
||||
>(1 | 5) : number
|
||||
>1 | 5 : number
|
||||
@@ -75,107 +75,107 @@ const enum Enum1 {
|
||||
>5 : 5
|
||||
|
||||
L = ~D,
|
||||
>L : Enum1
|
||||
>L : Enum1.H
|
||||
>~D : number
|
||||
>D : Enum1
|
||||
>D : Enum1.B
|
||||
|
||||
M = E << B,
|
||||
>M : Enum1
|
||||
>M : Enum1.M
|
||||
>E << B : number
|
||||
>E : Enum1
|
||||
>B : Enum1
|
||||
>E : Enum1.B
|
||||
>B : Enum1.B
|
||||
|
||||
N = E << 1,
|
||||
>N : Enum1
|
||||
>N : Enum1.M
|
||||
>E << 1 : number
|
||||
>E : Enum1
|
||||
>E : Enum1.B
|
||||
>1 : 1
|
||||
|
||||
O = E >> B,
|
||||
>O : Enum1
|
||||
>O : Enum1.A
|
||||
>E >> B : number
|
||||
>E : Enum1
|
||||
>B : Enum1
|
||||
>E : Enum1.B
|
||||
>B : Enum1.B
|
||||
|
||||
P = E >> 1,
|
||||
>P : Enum1
|
||||
>P : Enum1.A
|
||||
>E >> 1 : number
|
||||
>E : Enum1
|
||||
>E : Enum1.B
|
||||
>1 : 1
|
||||
|
||||
PQ = E ** 2,
|
||||
>PQ : Enum1
|
||||
>PQ : Enum1.B
|
||||
>E ** 2 : number
|
||||
>E : Enum1
|
||||
>E : Enum1.B
|
||||
>2 : 2
|
||||
|
||||
Q = -D,
|
||||
>Q : Enum1
|
||||
>Q : Enum1.Q
|
||||
>-D : number
|
||||
>D : Enum1
|
||||
>D : Enum1.B
|
||||
|
||||
R = C & 5,
|
||||
>R : Enum1
|
||||
>R : Enum1.A
|
||||
>C & 5 : number
|
||||
>C : Enum1
|
||||
>C : Enum1.C
|
||||
>5 : 5
|
||||
|
||||
S = 5 & C,
|
||||
>S : Enum1
|
||||
>S : Enum1.A
|
||||
>5 & C : number
|
||||
>5 : 5
|
||||
>C : Enum1
|
||||
>C : Enum1.C
|
||||
|
||||
T = C | D,
|
||||
>T : Enum1
|
||||
>T : Enum1.T
|
||||
>C | D : number
|
||||
>C : Enum1
|
||||
>D : Enum1
|
||||
>C : Enum1.C
|
||||
>D : Enum1.B
|
||||
|
||||
U = C | 1,
|
||||
>U : Enum1
|
||||
>U : Enum1.T
|
||||
>C | 1 : number
|
||||
>C : Enum1
|
||||
>C : Enum1.C
|
||||
>1 : 1
|
||||
|
||||
V = 10 | D,
|
||||
>V : Enum1
|
||||
>V : Enum1.T
|
||||
>10 | D : number
|
||||
>10 : 10
|
||||
>D : Enum1
|
||||
>D : Enum1.B
|
||||
|
||||
W = Enum1.V,
|
||||
>W : Enum1
|
||||
>Enum1.V : Enum1
|
||||
>W : Enum1.T
|
||||
>Enum1.V : Enum1.T
|
||||
>Enum1 : typeof Enum1
|
||||
>V : Enum1
|
||||
>V : Enum1.T
|
||||
|
||||
// correct cases: reference to the enum member from different enum declaration
|
||||
W1 = A0,
|
||||
>W1 : Enum1
|
||||
>A0 : Enum1
|
||||
>W1 : Enum1.A0
|
||||
>A0 : Enum1.A0
|
||||
|
||||
W2 = Enum1.A0,
|
||||
>W2 : Enum1
|
||||
>Enum1.A0 : Enum1
|
||||
>W2 : Enum1.A0
|
||||
>Enum1.A0 : Enum1.A0
|
||||
>Enum1 : typeof Enum1
|
||||
>A0 : Enum1
|
||||
>A0 : Enum1.A0
|
||||
|
||||
W3 = Enum1["A0"],
|
||||
>W3 : Enum1
|
||||
>Enum1["A0"] : Enum1
|
||||
>W3 : Enum1.A0
|
||||
>Enum1["A0"] : Enum1.A0
|
||||
>Enum1 : typeof Enum1
|
||||
>"A0" : "A0"
|
||||
|
||||
W4 = Enum1["W"],
|
||||
>W4 : Enum1
|
||||
>Enum1["W"] : Enum1
|
||||
>W4 : Enum1.T
|
||||
>Enum1["W"] : Enum1.T
|
||||
>Enum1 : typeof Enum1
|
||||
>"W" : "W"
|
||||
|
||||
W5 = Enum1[`V`],
|
||||
>W5 : Enum1
|
||||
>Enum1[`V`] : Enum1
|
||||
>W5 : Enum1.T
|
||||
>Enum1[`V`] : Enum1.T
|
||||
>Enum1 : typeof Enum1
|
||||
>`V` : "V"
|
||||
}
|
||||
@@ -212,13 +212,13 @@ module A {
|
||||
>E : E
|
||||
|
||||
V1 = 1,
|
||||
>V1 : E
|
||||
>V1 : E.V1
|
||||
>1 : 1
|
||||
|
||||
V2 = A.B.C.E.V1 | 100
|
||||
>V2 : E
|
||||
>V2 : E.V2
|
||||
>A.B.C.E.V1 | 100 : number
|
||||
>A.B.C.E.V1 : E
|
||||
>A.B.C.E.V1 : E.V1
|
||||
>A.B.C.E : typeof E
|
||||
>A.B.C : typeof C
|
||||
>A.B : typeof B
|
||||
@@ -226,7 +226,7 @@ module A {
|
||||
>B : typeof B
|
||||
>C : typeof C
|
||||
>E : typeof E
|
||||
>V1 : E
|
||||
>V1 : E.V1
|
||||
>100 : 100
|
||||
}
|
||||
}
|
||||
@@ -240,9 +240,9 @@ module A {
|
||||
>E : E
|
||||
|
||||
V3 = A.B.C.E["V2"] & 200,
|
||||
>V3 : E
|
||||
>V3 : E.V3
|
||||
>A.B.C.E["V2"] & 200 : number
|
||||
>A.B.C.E["V2"] : E
|
||||
>A.B.C.E["V2"] : E.V2
|
||||
>A.B.C.E : typeof E
|
||||
>A.B.C : typeof C
|
||||
>A.B : typeof B
|
||||
@@ -254,9 +254,9 @@ module A {
|
||||
>200 : 200
|
||||
|
||||
V4 = A.B.C.E[`V1`] << 1,
|
||||
>V4 : E
|
||||
>V4 : E.V4
|
||||
>A.B.C.E[`V1`] << 1 : number
|
||||
>A.B.C.E[`V1`] : E
|
||||
>A.B.C.E[`V1`] : E.V1
|
||||
>A.B.C.E : typeof E
|
||||
>A.B.C : typeof C
|
||||
>A.B : typeof B
|
||||
@@ -343,16 +343,16 @@ function foo0(e: I): void {
|
||||
if (e === I.V1) {
|
||||
>e === I.V1 : boolean
|
||||
>e : I
|
||||
>I.V1 : I
|
||||
>I.V1 : I.V1
|
||||
>I : typeof I
|
||||
>V1 : I
|
||||
>V1 : I.V1
|
||||
}
|
||||
else if (e === I.V2) {
|
||||
>e === I.V2 : boolean
|
||||
>e : I
|
||||
>I.V2 : I
|
||||
>e : I.V2 | I.V3 | I.V4
|
||||
>I.V2 : I.V2
|
||||
>I : typeof I
|
||||
>V2 : I
|
||||
>V2 : I.V2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,144 +425,144 @@ function foo(x: Enum1) {
|
||||
>x : Enum1
|
||||
|
||||
case Enum1.A:
|
||||
>Enum1.A : Enum1
|
||||
>Enum1.A : Enum1.A
|
||||
>Enum1 : typeof Enum1
|
||||
>A : Enum1
|
||||
>A : Enum1.A
|
||||
|
||||
case Enum1.B:
|
||||
>Enum1.B : Enum1
|
||||
>Enum1.B : Enum1.B
|
||||
>Enum1 : typeof Enum1
|
||||
>B : Enum1
|
||||
>B : Enum1.B
|
||||
|
||||
case Enum1.C:
|
||||
>Enum1.C : Enum1
|
||||
>Enum1.C : Enum1.C
|
||||
>Enum1 : typeof Enum1
|
||||
>C : Enum1
|
||||
>C : Enum1.C
|
||||
|
||||
case Enum1.D:
|
||||
>Enum1.D : Enum1
|
||||
>Enum1.D : Enum1.B
|
||||
>Enum1 : typeof Enum1
|
||||
>D : Enum1
|
||||
>D : Enum1.B
|
||||
|
||||
case Enum1.E:
|
||||
>Enum1.E : Enum1
|
||||
>Enum1.E : Enum1.B
|
||||
>Enum1 : typeof Enum1
|
||||
>E : Enum1
|
||||
>E : Enum1.B
|
||||
|
||||
case Enum1.F:
|
||||
>Enum1.F : Enum1
|
||||
>Enum1.F : Enum1.B
|
||||
>Enum1 : typeof Enum1
|
||||
>F : Enum1
|
||||
>F : Enum1.B
|
||||
|
||||
case Enum1.G:
|
||||
>Enum1.G : Enum1
|
||||
>Enum1.G : Enum1.B
|
||||
>Enum1 : typeof Enum1
|
||||
>G : Enum1
|
||||
>G : Enum1.B
|
||||
|
||||
case Enum1.H:
|
||||
>Enum1.H : Enum1
|
||||
>Enum1.H : Enum1.H
|
||||
>Enum1 : typeof Enum1
|
||||
>H : Enum1
|
||||
>H : Enum1.H
|
||||
|
||||
case Enum1.I:
|
||||
>Enum1.I : Enum1
|
||||
>Enum1.I : Enum1.A
|
||||
>Enum1 : typeof Enum1
|
||||
>I : Enum1
|
||||
>I : Enum1.A
|
||||
|
||||
case Enum1.J:
|
||||
>Enum1.J : Enum1
|
||||
>Enum1.J : Enum1.A
|
||||
>Enum1 : typeof Enum1
|
||||
>J : Enum1
|
||||
>J : Enum1.A
|
||||
|
||||
case Enum1.K:
|
||||
>Enum1.K : Enum1
|
||||
>Enum1.K : Enum1.K
|
||||
>Enum1 : typeof Enum1
|
||||
>K : Enum1
|
||||
>K : Enum1.K
|
||||
|
||||
case Enum1.L:
|
||||
>Enum1.L : Enum1
|
||||
>Enum1.L : Enum1.H
|
||||
>Enum1 : typeof Enum1
|
||||
>L : Enum1
|
||||
>L : Enum1.H
|
||||
|
||||
case Enum1.M:
|
||||
>Enum1.M : Enum1
|
||||
>Enum1.M : Enum1.M
|
||||
>Enum1 : typeof Enum1
|
||||
>M : Enum1
|
||||
>M : Enum1.M
|
||||
|
||||
case Enum1.N:
|
||||
>Enum1.N : Enum1
|
||||
>Enum1.N : Enum1.M
|
||||
>Enum1 : typeof Enum1
|
||||
>N : Enum1
|
||||
>N : Enum1.M
|
||||
|
||||
case Enum1.O:
|
||||
>Enum1.O : Enum1
|
||||
>Enum1.O : Enum1.A
|
||||
>Enum1 : typeof Enum1
|
||||
>O : Enum1
|
||||
>O : Enum1.A
|
||||
|
||||
case Enum1.P:
|
||||
>Enum1.P : Enum1
|
||||
>Enum1.P : Enum1.A
|
||||
>Enum1 : typeof Enum1
|
||||
>P : Enum1
|
||||
>P : Enum1.A
|
||||
|
||||
case Enum1.PQ:
|
||||
>Enum1.PQ : Enum1
|
||||
>Enum1.PQ : Enum1.B
|
||||
>Enum1 : typeof Enum1
|
||||
>PQ : Enum1
|
||||
>PQ : Enum1.B
|
||||
|
||||
case Enum1.Q:
|
||||
>Enum1.Q : Enum1
|
||||
>Enum1.Q : Enum1.Q
|
||||
>Enum1 : typeof Enum1
|
||||
>Q : Enum1
|
||||
>Q : Enum1.Q
|
||||
|
||||
case Enum1.R:
|
||||
>Enum1.R : Enum1
|
||||
>Enum1.R : Enum1.A
|
||||
>Enum1 : typeof Enum1
|
||||
>R : Enum1
|
||||
>R : Enum1.A
|
||||
|
||||
case Enum1.S:
|
||||
>Enum1.S : Enum1
|
||||
>Enum1.S : Enum1.A
|
||||
>Enum1 : typeof Enum1
|
||||
>S : Enum1
|
||||
>S : Enum1.A
|
||||
|
||||
case Enum1["T"]:
|
||||
>Enum1["T"] : Enum1
|
||||
>Enum1["T"] : Enum1.T
|
||||
>Enum1 : typeof Enum1
|
||||
>"T" : "T"
|
||||
|
||||
case Enum1[`U`]:
|
||||
>Enum1[`U`] : Enum1
|
||||
>Enum1[`U`] : Enum1.T
|
||||
>Enum1 : typeof Enum1
|
||||
>`U` : "U"
|
||||
|
||||
case Enum1.V:
|
||||
>Enum1.V : Enum1
|
||||
>Enum1.V : Enum1.T
|
||||
>Enum1 : typeof Enum1
|
||||
>V : Enum1
|
||||
>V : Enum1.T
|
||||
|
||||
case Enum1.W:
|
||||
>Enum1.W : Enum1
|
||||
>Enum1.W : Enum1.T
|
||||
>Enum1 : typeof Enum1
|
||||
>W : Enum1
|
||||
>W : Enum1.T
|
||||
|
||||
case Enum1.W1:
|
||||
>Enum1.W1 : Enum1
|
||||
>Enum1.W1 : Enum1.A0
|
||||
>Enum1 : typeof Enum1
|
||||
>W1 : Enum1
|
||||
>W1 : Enum1.A0
|
||||
|
||||
case Enum1.W2:
|
||||
>Enum1.W2 : Enum1
|
||||
>Enum1.W2 : Enum1.A0
|
||||
>Enum1 : typeof Enum1
|
||||
>W2 : Enum1
|
||||
>W2 : Enum1.A0
|
||||
|
||||
case Enum1.W3:
|
||||
>Enum1.W3 : Enum1
|
||||
>Enum1.W3 : Enum1.A0
|
||||
>Enum1 : typeof Enum1
|
||||
>W3 : Enum1
|
||||
>W3 : Enum1.A0
|
||||
|
||||
case Enum1.W4:
|
||||
>Enum1.W4 : Enum1
|
||||
>Enum1.W4 : Enum1.T
|
||||
>Enum1 : typeof Enum1
|
||||
>W4 : Enum1
|
||||
>W4 : Enum1.T
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -579,7 +579,7 @@ function bar(e: A.B.C.E): number {
|
||||
>e : I
|
||||
|
||||
case A.B.C.E.V1: return 1;
|
||||
>A.B.C.E.V1 : I
|
||||
>A.B.C.E.V1 : I.V1
|
||||
>A.B.C.E : typeof I
|
||||
>A.B.C : typeof A.B.C
|
||||
>A.B : typeof A.B
|
||||
@@ -587,11 +587,11 @@ function bar(e: A.B.C.E): number {
|
||||
>B : typeof A.B
|
||||
>C : typeof A.B.C
|
||||
>E : typeof I
|
||||
>V1 : I
|
||||
>V1 : I.V1
|
||||
>1 : 1
|
||||
|
||||
case A.B.C.E.V2: return 1;
|
||||
>A.B.C.E.V2 : I
|
||||
>A.B.C.E.V2 : I.V2
|
||||
>A.B.C.E : typeof I
|
||||
>A.B.C : typeof A.B.C
|
||||
>A.B : typeof A.B
|
||||
@@ -599,11 +599,11 @@ function bar(e: A.B.C.E): number {
|
||||
>B : typeof A.B
|
||||
>C : typeof A.B.C
|
||||
>E : typeof I
|
||||
>V2 : I
|
||||
>V2 : I.V2
|
||||
>1 : 1
|
||||
|
||||
case A.B.C.E.V3: return 1;
|
||||
>A.B.C.E.V3 : I
|
||||
>A.B.C.E.V3 : I.V3
|
||||
>A.B.C.E : typeof I
|
||||
>A.B.C : typeof A.B.C
|
||||
>A.B : typeof A.B
|
||||
@@ -611,7 +611,7 @@ function bar(e: A.B.C.E): number {
|
||||
>B : typeof A.B
|
||||
>C : typeof A.B.C
|
||||
>E : typeof I
|
||||
>V3 : I
|
||||
>V3 : I.V3
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
tests/cases/compiler/constantEnumAssert.ts(45,20): error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
|
||||
tests/cases/compiler/constantEnumAssert.ts(49,20): error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constantEnumAssert.ts (2 errors) ====
|
||||
==== tests/cases/compiler/constantEnumAssert.ts (1 errors) ====
|
||||
enum E1 {
|
||||
a,
|
||||
b
|
||||
@@ -48,8 +47,6 @@ tests/cases/compiler/constantEnumAssert.ts(49,20): error TS1355: A 'const' asser
|
||||
const foo9 = { a: E2.a as const }
|
||||
|
||||
const foo10 = { a: E3.a as const }
|
||||
~~~~
|
||||
!!! error TS1355: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.
|
||||
|
||||
const foo11 = { a: E4.a as const }
|
||||
|
||||
|
||||
@@ -25,19 +25,19 @@ enum E3 {
|
||||
>E3 : E3
|
||||
|
||||
a = 1,
|
||||
>a : E3
|
||||
>a : E3.a
|
||||
>1 : 1
|
||||
|
||||
b = a << 1,
|
||||
>b : E3
|
||||
>b : E3.b
|
||||
>a << 1 : number
|
||||
>a : E3
|
||||
>a : E3.a
|
||||
>1 : 1
|
||||
|
||||
c = a << 2,
|
||||
>c : E3
|
||||
>c : E3.c
|
||||
>a << 2 : number
|
||||
>a : E3
|
||||
>a : E3.a
|
||||
>2 : 2
|
||||
}
|
||||
|
||||
@@ -99,13 +99,13 @@ const foo4 = { a: E2.a } as const
|
||||
>a : E2.a
|
||||
|
||||
const foo5 = { a: E3.a } as const
|
||||
>foo5 : { readonly a: E3; }
|
||||
>{ a: E3.a } as const : { readonly a: E3; }
|
||||
>{ a: E3.a } : { readonly a: E3; }
|
||||
>a : E3
|
||||
>E3.a : E3
|
||||
>foo5 : { readonly a: E3.a; }
|
||||
>{ a: E3.a } as const : { readonly a: E3.a; }
|
||||
>{ a: E3.a } : { readonly a: E3.a; }
|
||||
>a : E3.a
|
||||
>E3.a : E3.a
|
||||
>E3 : typeof E3
|
||||
>a : E3
|
||||
>a : E3.a
|
||||
|
||||
const foo6 = { a: E4.a } as const
|
||||
>foo6 : { readonly a: E4.a; }
|
||||
@@ -144,13 +144,13 @@ const foo9 = { a: E2.a as const }
|
||||
>a : E2.a
|
||||
|
||||
const foo10 = { a: E3.a as const }
|
||||
>foo10 : { a: E3; }
|
||||
>{ a: E3.a as const } : { a: E3; }
|
||||
>a : E3
|
||||
>E3.a as const : E3
|
||||
>E3.a : E3
|
||||
>foo10 : { a: E3.a; }
|
||||
>{ a: E3.a as const } : { a: E3.a; }
|
||||
>a : E3.a
|
||||
>E3.a as const : E3.a
|
||||
>E3.a : E3.a
|
||||
>E3 : typeof E3
|
||||
>a : E3
|
||||
>a : E3.a
|
||||
|
||||
const foo11 = { a: E4.a as const }
|
||||
>foo11 : { a: E4.a; }
|
||||
|
||||
@@ -16,17 +16,17 @@ enum e2 {
|
||||
>e2 : e2
|
||||
|
||||
a = 10,
|
||||
>a : e2
|
||||
>a : e2.a
|
||||
>10 : 10
|
||||
|
||||
b = a + 2,
|
||||
>b : e2
|
||||
>b : e2.b
|
||||
>a + 2 : number
|
||||
>a : e2
|
||||
>a : e2.a
|
||||
>2 : 2
|
||||
|
||||
c = 10,
|
||||
>c : e2
|
||||
>c : e2.a
|
||||
>10 : 10
|
||||
}
|
||||
|
||||
@@ -34,19 +34,19 @@ enum e3 {
|
||||
>e3 : e3
|
||||
|
||||
a = 10,
|
||||
>a : e3
|
||||
>a : e3.a
|
||||
>10 : 10
|
||||
|
||||
b = Math.PI,
|
||||
>b : e3
|
||||
>b : e3.b
|
||||
>Math.PI : number
|
||||
>Math : Math
|
||||
>PI : number
|
||||
|
||||
c = a + 3
|
||||
>c : e3
|
||||
>c : e3.c
|
||||
>a + 3 : number
|
||||
>a : e3
|
||||
>a : e3.a
|
||||
>3 : 3
|
||||
}
|
||||
|
||||
|
||||
@@ -3,20 +3,18 @@ tests/cases/compiler/enumAssignmentCompat3.ts(68,1): error TS2322: Type 'Abcd.E'
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(70,1): error TS2322: Type 'Cd.E' is not assignable to type 'First.E'.
|
||||
Property 'd' is missing in type 'First.E'.
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(71,1): error TS2322: Type 'Nope' is not assignable to type 'E'.
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(72,1): error TS2322: Type 'Decl.E' is not assignable to type 'First.E'.
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(75,1): error TS2322: Type 'First.E' is not assignable to type 'Ab.E'.
|
||||
Property 'c' is missing in type 'Ab.E'.
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(76,1): error TS2322: Type 'First.E' is not assignable to type 'Cd.E'.
|
||||
Property 'a' is missing in type 'Cd.E'.
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(77,1): error TS2322: Type 'E' is not assignable to type 'Nope'.
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(78,1): error TS2322: Type 'First.E' is not assignable to type 'Decl.E'.
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(82,1): error TS2322: Type 'Const.E' is not assignable to type 'First.E'.
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(83,1): error TS2322: Type 'First.E' is not assignable to type 'Const.E'.
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(86,1): error TS2322: Type 'Merged.E' is not assignable to type 'First.E'.
|
||||
Property 'd' is missing in type 'First.E'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enumAssignmentCompat3.ts (11 errors) ====
|
||||
==== tests/cases/compiler/enumAssignmentCompat3.ts (9 errors) ====
|
||||
namespace First {
|
||||
export enum E {
|
||||
a, b, c,
|
||||
@@ -97,8 +95,6 @@ tests/cases/compiler/enumAssignmentCompat3.ts(86,1): error TS2322: Type 'Merged.
|
||||
~~~
|
||||
!!! error TS2322: Type 'Nope' is not assignable to type 'E'.
|
||||
abc = decl; // ok
|
||||
~~~
|
||||
!!! error TS2322: Type 'Decl.E' is not assignable to type 'First.E'.
|
||||
secondAbc = abc; // ok
|
||||
secondAbcd = abc; // ok
|
||||
secondAb = abc; // missing 'c'
|
||||
@@ -113,8 +109,6 @@ tests/cases/compiler/enumAssignmentCompat3.ts(86,1): error TS2322: Type 'Merged.
|
||||
~~~~
|
||||
!!! error TS2322: Type 'E' is not assignable to type 'Nope'.
|
||||
decl = abc; // ok
|
||||
~~~~
|
||||
!!! error TS2322: Type 'First.E' is not assignable to type 'Decl.E'.
|
||||
|
||||
// const is only assignable to itself
|
||||
k = k;
|
||||
|
||||
@@ -83,9 +83,9 @@ namespace Decl {
|
||||
>E : E
|
||||
|
||||
a, b, c = 3,
|
||||
>a : E
|
||||
>b : E
|
||||
>c : E
|
||||
>a : E.a
|
||||
>b : E.b
|
||||
>c : E.c
|
||||
>3 : 3
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
tests/cases/compiler/enumAssignmentCompat5.ts(20,9): error TS2535: Enum type 'Computed' has members with initializers that are not literals.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enumAssignmentCompat5.ts (1 errors) ====
|
||||
enum E {
|
||||
A, B, C
|
||||
}
|
||||
enum Computed {
|
||||
A = 1 << 1,
|
||||
B = 1 << 2,
|
||||
C = 1 << 3,
|
||||
}
|
||||
let n: number;
|
||||
let e: E = n; // ok because it's too inconvenient otherwise
|
||||
e = 0; // ok, in range
|
||||
e = 4; // ok, out of range, but allowed computed enums don't have all members
|
||||
let a: E.A = 0; // ok, A === 0
|
||||
a = 2; // error, 2 !== 0
|
||||
a = n; // ok
|
||||
|
||||
let c: Computed = n; // ok
|
||||
c = n; // ok
|
||||
c = 4; // ok
|
||||
let ca: Computed.A = 1; // error, Computed.A isn't a literal type because Computed has no enum literals
|
||||
~~~~~~~~~~
|
||||
!!! error TS2535: Enum type 'Computed' has members with initializers that are not literals.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,19 +11,19 @@ enum Computed {
|
||||
>Computed : Computed
|
||||
|
||||
A = 1 << 1,
|
||||
>A : Computed
|
||||
>A : Computed.A
|
||||
>1 << 1 : number
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
|
||||
B = 1 << 2,
|
||||
>B : Computed
|
||||
>B : Computed.B
|
||||
>1 << 2 : number
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
|
||||
C = 1 << 3,
|
||||
>C : Computed
|
||||
>C : Computed.C
|
||||
>1 << 3 : number
|
||||
>1 : 1
|
||||
>3 : 3
|
||||
@@ -75,7 +75,7 @@ c = 4; // ok
|
||||
>4 : 4
|
||||
|
||||
let ca: Computed.A = 1; // error, Computed.A isn't a literal type because Computed has no enum literals
|
||||
>ca : Computed
|
||||
>ca : Computed.A
|
||||
>Computed : any
|
||||
>1 : 1
|
||||
|
||||
|
||||
@@ -79,15 +79,15 @@ enum E3 {
|
||||
>E3 : E3
|
||||
|
||||
X = 'foo'.length, Y = 4 + 3, Z = +'foo'
|
||||
>X : E3
|
||||
>X : E3.X
|
||||
>'foo'.length : number
|
||||
>'foo' : "foo"
|
||||
>length : number
|
||||
>Y : E3
|
||||
>Y : E3.Y
|
||||
>4 + 3 : number
|
||||
>4 : 4
|
||||
>3 : 3
|
||||
>Z : E3
|
||||
>Z : E3.Z
|
||||
>+'foo' : number
|
||||
>'foo' : "foo"
|
||||
}
|
||||
@@ -97,10 +97,10 @@ enum E4 {
|
||||
>E4 : E4
|
||||
|
||||
X = 0, Y, Z = 'foo'.length
|
||||
>X : E4
|
||||
>X : E4.X
|
||||
>0 : 0
|
||||
>Y : E4
|
||||
>Z : E4
|
||||
>Y : E4.Y
|
||||
>Z : E4.Z
|
||||
>'foo'.length : number
|
||||
>'foo' : "foo"
|
||||
>length : number
|
||||
@@ -172,8 +172,8 @@ enum E9 {
|
||||
// (refer to .js to validate)
|
||||
// Enum constant members are propagated
|
||||
var doNotPropagate = [
|
||||
>doNotPropagate : (E3 | E4 | E7 | E8)[]
|
||||
>[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : (E3 | E4 | E7 | E8)[]
|
||||
>doNotPropagate : (E8 | E7 | E4.Z | E3)[]
|
||||
>[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : (E8 | E7 | E4.Z | E3)[]
|
||||
|
||||
E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z
|
||||
>E8.B : E8
|
||||
@@ -182,18 +182,18 @@ var doNotPropagate = [
|
||||
>E7.A : E7
|
||||
>E7 : typeof E7
|
||||
>A : E7
|
||||
>E4.Z : E4
|
||||
>E4.Z : E4.Z
|
||||
>E4 : typeof E4
|
||||
>Z : E4
|
||||
>E3.X : E3
|
||||
>Z : E4.Z
|
||||
>E3.X : E3.X
|
||||
>E3 : typeof E3
|
||||
>X : E3
|
||||
>E3.Y : E3
|
||||
>X : E3.X
|
||||
>E3.Y : E3.Y
|
||||
>E3 : typeof E3
|
||||
>Y : E3
|
||||
>E3.Z : E3
|
||||
>Y : E3.Y
|
||||
>E3.Z : E3.Z
|
||||
>E3 : typeof E3
|
||||
>Z : E3
|
||||
>Z : E3.Z
|
||||
|
||||
];
|
||||
// Enum computed members are not propagated
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/compiler/enumBasics2.ts(4,9): error TS2339: Property 'b' does not exist on type 'Foo'.
|
||||
tests/cases/compiler/enumBasics2.ts(5,9): error TS2339: Property 'a' does not exist on type 'Foo'.
|
||||
tests/cases/compiler/enumBasics2.ts(6,9): error TS2339: Property 'x' does not exist on type 'Foo'.
|
||||
tests/cases/compiler/enumBasics2.ts(6,15): error TS2339: Property 'x' does not exist on type 'Foo'.
|
||||
tests/cases/compiler/enumBasics2.ts(13,13): error TS2339: Property 'a' does not exist on type 'Foo'.
|
||||
tests/cases/compiler/enumBasics2.ts(4,9): error TS2339: Property 'b' does not exist on type 'Foo.a'.
|
||||
tests/cases/compiler/enumBasics2.ts(5,9): error TS2339: Property 'a' does not exist on type 'Foo.b'.
|
||||
tests/cases/compiler/enumBasics2.ts(6,9): error TS2339: Property 'x' does not exist on type 'Foo.y'.
|
||||
tests/cases/compiler/enumBasics2.ts(6,15): error TS2339: Property 'x' does not exist on type 'Foo.a'.
|
||||
tests/cases/compiler/enumBasics2.ts(13,13): error TS2339: Property 'a' does not exist on type 'Foo.a'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enumBasics2.ts (5 errors) ====
|
||||
@@ -11,15 +11,15 @@ tests/cases/compiler/enumBasics2.ts(13,13): error TS2339: Property 'a' does not
|
||||
b = 3,
|
||||
x = a.b, // should error
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'Foo'.
|
||||
!!! error TS2339: Property 'b' does not exist on type 'Foo.a'.
|
||||
y = b.a, // should error
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'Foo'.
|
||||
!!! error TS2339: Property 'a' does not exist on type 'Foo.b'.
|
||||
z = y.x * a.x, // should error
|
||||
~
|
||||
!!! error TS2339: Property 'x' does not exist on type 'Foo'.
|
||||
!!! error TS2339: Property 'x' does not exist on type 'Foo.y'.
|
||||
~
|
||||
!!! error TS2339: Property 'x' does not exist on type 'Foo'.
|
||||
!!! error TS2339: Property 'x' does not exist on type 'Foo.a'.
|
||||
}
|
||||
|
||||
enum Bar {
|
||||
@@ -28,6 +28,6 @@ tests/cases/compiler/enumBasics2.ts(13,13): error TS2339: Property 'a' does not
|
||||
c = Foo.a.valueOf(), // ok
|
||||
d = Foo.a.a, // should error
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'Foo'.
|
||||
!!! error TS2339: Property 'a' does not exist on type 'Foo.a'.
|
||||
}
|
||||
|
||||
@@ -3,33 +3,33 @@ enum Foo {
|
||||
>Foo : Foo
|
||||
|
||||
a = 2,
|
||||
>a : Foo
|
||||
>a : Foo.a
|
||||
>2 : 2
|
||||
|
||||
b = 3,
|
||||
>b : Foo
|
||||
>b : Foo.b
|
||||
>3 : 3
|
||||
|
||||
x = a.b, // should error
|
||||
>x : Foo
|
||||
>x : Foo.x
|
||||
>a.b : any
|
||||
>a : Foo
|
||||
>a : Foo.a
|
||||
>b : any
|
||||
|
||||
y = b.a, // should error
|
||||
>y : Foo
|
||||
>y : Foo.y
|
||||
>b.a : any
|
||||
>b : Foo
|
||||
>b : Foo.b
|
||||
>a : any
|
||||
|
||||
z = y.x * a.x, // should error
|
||||
>z : Foo
|
||||
>z : Foo.z
|
||||
>y.x * a.x : number
|
||||
>y.x : any
|
||||
>y : Foo
|
||||
>y : Foo.y
|
||||
>x : any
|
||||
>a.x : any
|
||||
>a : Foo
|
||||
>a : Foo.a
|
||||
>x : any
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ enum Bar {
|
||||
>Bar : Bar
|
||||
|
||||
a = (1).valueOf(), // ok
|
||||
>a : Bar
|
||||
>a : Bar.a
|
||||
>(1).valueOf() : number
|
||||
>(1).valueOf : () => number
|
||||
>(1) : 1
|
||||
@@ -45,26 +45,26 @@ enum Bar {
|
||||
>valueOf : () => number
|
||||
|
||||
b = Foo.a, // ok
|
||||
>b : Bar
|
||||
>Foo.a : Foo
|
||||
>b : Bar.b
|
||||
>Foo.a : Foo.a
|
||||
>Foo : typeof Foo
|
||||
>a : Foo
|
||||
>a : Foo.a
|
||||
|
||||
c = Foo.a.valueOf(), // ok
|
||||
>c : Bar
|
||||
>c : Bar.c
|
||||
>Foo.a.valueOf() : number
|
||||
>Foo.a.valueOf : () => number
|
||||
>Foo.a : Foo
|
||||
>Foo.a : Foo.a
|
||||
>Foo : typeof Foo
|
||||
>a : Foo
|
||||
>a : Foo.a
|
||||
>valueOf : () => number
|
||||
|
||||
d = Foo.a.a, // should error
|
||||
>d : Bar
|
||||
>d : Bar.d
|
||||
>Foo.a.a : any
|
||||
>Foo.a : Foo
|
||||
>Foo.a : Foo.a
|
||||
>Foo : typeof Foo
|
||||
>a : Foo
|
||||
>a : Foo.a
|
||||
>a : any
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/enumBasics3.ts(5,13): error TS2339: Property 'a' does not exist on type 'E1'.
|
||||
tests/cases/compiler/enumBasics3.ts(14,20): error TS2339: Property 'a' does not exist on type 'E1'.
|
||||
tests/cases/compiler/enumBasics3.ts(5,13): error TS2339: Property 'a' does not exist on type 'E1.a'.
|
||||
tests/cases/compiler/enumBasics3.ts(14,20): error TS2339: Property 'a' does not exist on type 'E1.a'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enumBasics3.ts (2 errors) ====
|
||||
@@ -9,7 +9,7 @@ tests/cases/compiler/enumBasics3.ts(14,20): error TS2339: Property 'a' does not
|
||||
a = 1,
|
||||
b = a.a, // should error
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'E1'.
|
||||
!!! error TS2339: Property 'a' does not exist on type 'E1.a'.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ tests/cases/compiler/enumBasics3.ts(14,20): error TS2339: Property 'a' does not
|
||||
b = M.N.E1.a,
|
||||
c = M.N.E1.a.a, // should error
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'E1'.
|
||||
!!! error TS2339: Property 'a' does not exist on type 'E1.a'.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ module M {
|
||||
>E1 : E1
|
||||
|
||||
a = 1,
|
||||
>a : E1
|
||||
>a : E1.a
|
||||
>1 : 1
|
||||
|
||||
b = a.a, // should error
|
||||
>b : E1
|
||||
>b : E1.b
|
||||
>a.a : any
|
||||
>a : E1
|
||||
>a : E1.a
|
||||
>a : any
|
||||
}
|
||||
}
|
||||
@@ -31,25 +31,25 @@ module M {
|
||||
>E2 : E2
|
||||
|
||||
b = M.N.E1.a,
|
||||
>b : E2
|
||||
>M.N.E1.a : E1
|
||||
>b : E2.b
|
||||
>M.N.E1.a : E1.a
|
||||
>M.N.E1 : typeof E1
|
||||
>M.N : typeof N
|
||||
>M : typeof M
|
||||
>N : typeof N
|
||||
>E1 : typeof E1
|
||||
>a : E1
|
||||
>a : E1.a
|
||||
|
||||
c = M.N.E1.a.a, // should error
|
||||
>c : E2
|
||||
>c : E2.c
|
||||
>M.N.E1.a.a : any
|
||||
>M.N.E1.a : E1
|
||||
>M.N.E1.a : E1.a
|
||||
>M.N.E1 : typeof E1
|
||||
>M.N : typeof N
|
||||
>M : typeof M
|
||||
>N : typeof N
|
||||
>E1 : typeof E1
|
||||
>a : E1
|
||||
>a : E1.a
|
||||
>a : any
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,34 +130,34 @@ enum E11 {
|
||||
>E11 : E11
|
||||
|
||||
A = +0,
|
||||
>A : E11
|
||||
>A : E11.A
|
||||
>+0 : 0
|
||||
>0 : 0
|
||||
|
||||
B,
|
||||
>B : E11
|
||||
>B : E11.B
|
||||
|
||||
C
|
||||
>C : E11
|
||||
>C : E11.C
|
||||
}
|
||||
|
||||
enum E12 {
|
||||
>E12 : E12
|
||||
|
||||
A = 1 << 0,
|
||||
>A : E12
|
||||
>A : E12.A
|
||||
>1 << 0 : number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
|
||||
B = 1 << 1,
|
||||
>B : E12
|
||||
>B : E12.B
|
||||
>1 << 1 : number
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
|
||||
C = 1 << 2
|
||||
>C : E12
|
||||
>C : E12.C
|
||||
>1 << 2 : number
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
@@ -169,24 +169,24 @@ enum E20 {
|
||||
>E20 : E20
|
||||
|
||||
A = "foo".length,
|
||||
>A : E20
|
||||
>A : E20.A
|
||||
>"foo".length : number
|
||||
>"foo" : "foo"
|
||||
>length : number
|
||||
|
||||
B = A + 1,
|
||||
>B : E20
|
||||
>B : E20.B
|
||||
>A + 1 : number
|
||||
>A : E20
|
||||
>A : E20.A
|
||||
>1 : 1
|
||||
|
||||
C = +"123",
|
||||
>C : E20
|
||||
>C : E20.C
|
||||
>+"123" : number
|
||||
>"123" : "123"
|
||||
|
||||
D = Math.sin(1)
|
||||
>D : E20
|
||||
>D : E20.D
|
||||
>Math.sin(1) : number
|
||||
>Math.sin : (x: number) => number
|
||||
>Math : Math
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
tests/cases/conformance/enums/enumConstantMemberWithString.ts(5,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumConstantMemberWithString.ts(6,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumConstantMemberWithString.ts(18,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumConstantMemberWithString.ts(5,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/enums/enumConstantMemberWithString.ts(5,15): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/enums/enumConstantMemberWithString.ts (3 errors) ====
|
||||
==== tests/cases/conformance/enums/enumConstantMemberWithString.ts (2 errors) ====
|
||||
enum T1 {
|
||||
a = "1",
|
||||
b = "1" + "2",
|
||||
c = "1" + "2" + "3",
|
||||
d = "a" - "a",
|
||||
~~~~~~~~~
|
||||
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
e = "a" + 1
|
||||
~~~~~~~
|
||||
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
}
|
||||
|
||||
enum T2 {
|
||||
@@ -26,8 +25,6 @@ tests/cases/conformance/enums/enumConstantMemberWithString.ts(18,9): error TS255
|
||||
b = "1" + "2",
|
||||
c = 1,
|
||||
d = 1 + 2
|
||||
~~~~~
|
||||
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
}
|
||||
|
||||
enum T4 {
|
||||
|
||||
@@ -39,8 +39,8 @@ var T1;
|
||||
T1["a"] = "1";
|
||||
T1["b"] = "12";
|
||||
T1["c"] = "123";
|
||||
T1[T1["d"] = 0] = "d";
|
||||
T1[T1["e"] = 0] = "e";
|
||||
T1[T1["d"] = "a" - "a"] = "d";
|
||||
T1["e"] = "a1";
|
||||
})(T1 || (T1 = {}));
|
||||
var T2;
|
||||
(function (T2) {
|
||||
@@ -52,7 +52,7 @@ var T3;
|
||||
T3["a"] = "1";
|
||||
T3["b"] = "12";
|
||||
T3[T3["c"] = 1] = "c";
|
||||
T3[T3["d"] = 0] = "d";
|
||||
T3[T3["d"] = 3] = "d";
|
||||
})(T3 || (T3 = {}));
|
||||
var T4;
|
||||
(function (T4) {
|
||||
|
||||
@@ -27,7 +27,7 @@ enum T1 {
|
||||
>"a" : "a"
|
||||
|
||||
e = "a" + 1
|
||||
>e : T1.d
|
||||
>e : T1.e
|
||||
>"a" + 1 : string
|
||||
>"a" : "a"
|
||||
>1 : 1
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
tests/cases/conformance/enums/enumConstantMemberWithTemplateLiterals.ts(28,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumConstantMemberWithTemplateLiterals.ts(29,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumConstantMemberWithTemplateLiterals.ts(30,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumConstantMemberWithTemplateLiterals.ts(31,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumConstantMemberWithTemplateLiterals.ts(28,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/conformance/enums/enumConstantMemberWithTemplateLiterals.ts(28,15): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/enums/enumConstantMemberWithTemplateLiterals.ts (4 errors) ====
|
||||
==== tests/cases/conformance/enums/enumConstantMemberWithTemplateLiterals.ts (2 errors) ====
|
||||
enum T1 {
|
||||
a = `1`
|
||||
}
|
||||
@@ -33,17 +31,13 @@ tests/cases/conformance/enums/enumConstantMemberWithTemplateLiterals.ts(31,9): e
|
||||
c = `1` + `2` + `3`,
|
||||
d = 1,
|
||||
e = `1` - `1`,
|
||||
~~~~~~~~~
|
||||
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
f = `1` + 1,
|
||||
~~~~~~~
|
||||
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
g = `1${"2"}3`,
|
||||
~~~~~~~~~~
|
||||
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
h = `1`.length
|
||||
~~~~~~~~~~
|
||||
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
}
|
||||
|
||||
enum T6 {
|
||||
|
||||
@@ -73,10 +73,10 @@ var T5;
|
||||
T5["b"] = "12";
|
||||
T5["c"] = "123";
|
||||
T5[T5["d"] = 1] = "d";
|
||||
T5[T5["e"] = 0] = "e";
|
||||
T5[T5["f"] = 0] = "f";
|
||||
T5[T5["g"] = 0] = "g";
|
||||
T5[T5["h"] = 0] = "h";
|
||||
T5[T5["e"] = "1" - "1"] = "e";
|
||||
T5["f"] = "11";
|
||||
T5["g"] = "123";
|
||||
T5[T5["h"] = "1".length] = "h";
|
||||
})(T5 || (T5 = {}));
|
||||
var T6;
|
||||
(function (T6) {
|
||||
|
||||
@@ -99,18 +99,18 @@ enum T5 {
|
||||
>`1` : "1"
|
||||
|
||||
f = `1` + 1,
|
||||
>f : T5.e
|
||||
>f : T5.f
|
||||
>`1` + 1 : string
|
||||
>`1` : "1"
|
||||
>1 : 1
|
||||
|
||||
g = `1${"2"}3`,
|
||||
>g : T5.e
|
||||
>g : T5.c
|
||||
>`1${"2"}3` : string
|
||||
>"2" : "2"
|
||||
|
||||
h = `1`.length
|
||||
>h : T5.e
|
||||
>h : T5.h
|
||||
>`1`.length : number
|
||||
>`1` : "1"
|
||||
>length : number
|
||||
@@ -120,11 +120,11 @@ enum T6 {
|
||||
>T6 : T6
|
||||
|
||||
a = 1,
|
||||
>a : T6
|
||||
>a : T6.a
|
||||
>1 : 1
|
||||
|
||||
b = `12`.length
|
||||
>b : T6
|
||||
>b : T6.b
|
||||
>`12`.length : number
|
||||
>`12` : "12"
|
||||
>length : number
|
||||
|
||||
+2
-2
@@ -97,11 +97,11 @@ enum T6 {
|
||||
>T6 : T6
|
||||
|
||||
a = 1,
|
||||
>a : T6
|
||||
>a : T6.a
|
||||
>1 : 1
|
||||
|
||||
b = `12`.length
|
||||
>b : T6
|
||||
>b : T6.b
|
||||
>`12`.length : number
|
||||
>`12` : "12"
|
||||
>length : number
|
||||
|
||||
@@ -53,39 +53,39 @@ enum E5 {
|
||||
>E5 : E5
|
||||
|
||||
a = 1 / 0,
|
||||
>a : E5
|
||||
>a : E5.a
|
||||
>1 / 0 : number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
|
||||
b = 2 / 0.0,
|
||||
>b : E5
|
||||
>b : E5.a
|
||||
>2 / 0.0 : number
|
||||
>2 : 2
|
||||
>0.0 : 0
|
||||
|
||||
c = 1.0 / 0.0,
|
||||
>c : E5
|
||||
>c : E5.a
|
||||
>1.0 / 0.0 : number
|
||||
>1.0 : 1
|
||||
>0.0 : 0
|
||||
|
||||
d = 0.0 / 0.0,
|
||||
>d : E5
|
||||
>d : E5.d
|
||||
>0.0 / 0.0 : number
|
||||
>0.0 : 0
|
||||
>0.0 : 0
|
||||
|
||||
e = NaN,
|
||||
>e : E5
|
||||
>e : E5.d
|
||||
>NaN : number
|
||||
|
||||
f = Infinity,
|
||||
>f : E5
|
||||
>f : E5.a
|
||||
>Infinity : number
|
||||
|
||||
g = -Infinity
|
||||
>g : E5
|
||||
>g : E5.g
|
||||
>-Infinity : number
|
||||
>Infinity : number
|
||||
}
|
||||
@@ -94,39 +94,39 @@ const enum E6 {
|
||||
>E6 : E6
|
||||
|
||||
a = 1 / 0,
|
||||
>a : E6
|
||||
>a : E6.a
|
||||
>1 / 0 : number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
|
||||
b = 2 / 0.0,
|
||||
>b : E6
|
||||
>b : E6.a
|
||||
>2 / 0.0 : number
|
||||
>2 : 2
|
||||
>0.0 : 0
|
||||
|
||||
c = 1.0 / 0.0,
|
||||
>c : E6
|
||||
>c : E6.a
|
||||
>1.0 / 0.0 : number
|
||||
>1.0 : 1
|
||||
>0.0 : 0
|
||||
|
||||
d = 0.0 / 0.0,
|
||||
>d : E6
|
||||
>d : E6.d
|
||||
>0.0 / 0.0 : number
|
||||
>0.0 : 0
|
||||
>0.0 : 0
|
||||
|
||||
e = NaN,
|
||||
>e : E6
|
||||
>e : E6.d
|
||||
>NaN : number
|
||||
|
||||
f = Infinity,
|
||||
>f : E6
|
||||
>f : E6.a
|
||||
>Infinity : number
|
||||
|
||||
g = -Infinity
|
||||
>g : E6
|
||||
>g : E6.g
|
||||
>-Infinity : number
|
||||
>Infinity : number
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ declare module mAmbient {
|
||||
>e : e
|
||||
|
||||
x,
|
||||
>x : e
|
||||
>x : e.x
|
||||
|
||||
y,
|
||||
>y : e
|
||||
>y : e.y
|
||||
|
||||
z
|
||||
>z : e
|
||||
>z : e.z
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@ tests/cases/conformance/enums/enumErrors.ts(2,6): error TS2431: Enum name cannot
|
||||
tests/cases/conformance/enums/enumErrors.ts(3,6): error TS2431: Enum name cannot be 'number'.
|
||||
tests/cases/conformance/enums/enumErrors.ts(4,6): error TS2431: Enum name cannot be 'string'.
|
||||
tests/cases/conformance/enums/enumErrors.ts(5,6): error TS2431: Enum name cannot be 'boolean'.
|
||||
tests/cases/conformance/enums/enumErrors.ts(9,9): error TS18033: Only numeric enums can have computed members, but this expression has type 'Number'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
tests/cases/conformance/enums/enumErrors.ts(26,9): error TS18033: Only numeric enums can have computed members, but this expression has type 'true'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
tests/cases/conformance/enums/enumErrors.ts(27,9): error TS18033: Only numeric enums can have computed members, but this expression has type 'Date'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
tests/cases/conformance/enums/enumErrors.ts(28,9): error TS18033: Only numeric enums can have computed members, but this expression has type 'Window & typeof globalThis'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
tests/cases/conformance/enums/enumErrors.ts(29,9): error TS18033: Only numeric enums can have computed members, but this expression has type '{}'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
tests/cases/conformance/enums/enumErrors.ts(30,9): error TS18033: Only numeric enums can have computed members, but this expression has type 'string'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
tests/cases/conformance/enums/enumErrors.ts(36,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumErrors.ts(37,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumErrors.ts(38,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumErrors.ts(39,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumErrors.ts(40,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
tests/cases/conformance/enums/enumErrors.ts(9,9): error TS18033: Type 'Number' is not assignable to type 'number' as required for computed enum member values.
|
||||
'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible.
|
||||
tests/cases/conformance/enums/enumErrors.ts(26,9): error TS18033: Type 'boolean' is not assignable to type 'number' as required for computed enum member values.
|
||||
tests/cases/conformance/enums/enumErrors.ts(27,9): error TS18033: Type 'Date' is not assignable to type 'number' as required for computed enum member values.
|
||||
tests/cases/conformance/enums/enumErrors.ts(28,9): error TS18033: Type 'Window & typeof globalThis' is not assignable to type 'number' as required for computed enum member values.
|
||||
tests/cases/conformance/enums/enumErrors.ts(29,9): error TS18033: Type '{}' is not assignable to type 'number' as required for computed enum member values.
|
||||
tests/cases/conformance/enums/enumErrors.ts(30,9): error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values.
|
||||
tests/cases/conformance/enums/enumErrors.ts(36,9): error TS18033: Type 'Date' is not assignable to type 'number' as required for computed enum member values.
|
||||
tests/cases/conformance/enums/enumErrors.ts(37,9): error TS18033: Type 'Window & typeof globalThis' is not assignable to type 'number' as required for computed enum member values.
|
||||
tests/cases/conformance/enums/enumErrors.ts(38,9): error TS18033: Type '{}' is not assignable to type 'number' as required for computed enum member values.
|
||||
tests/cases/conformance/enums/enumErrors.ts(40,9): error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values.
|
||||
tests/cases/conformance/enums/enumErrors.ts(48,18): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/enums/enumErrors.ts(49,24): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
|
||||
tests/cases/conformance/enums/enumErrors.ts(49,26): error TS2452: An enum member cannot have a numeric name.
|
||||
@@ -25,7 +25,7 @@ tests/cases/conformance/enums/enumErrors.ts(53,30): error TS1357: An enum member
|
||||
tests/cases/conformance/enums/enumErrors.ts(53,33): error TS2452: An enum member cannot have a numeric name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/enums/enumErrors.ts (25 errors) ====
|
||||
==== tests/cases/conformance/enums/enumErrors.ts (24 errors) ====
|
||||
// Enum named with PredefinedTypes
|
||||
enum any { }
|
||||
~~~
|
||||
@@ -44,7 +44,8 @@ tests/cases/conformance/enums/enumErrors.ts(53,33): error TS2452: An enum member
|
||||
enum E5 {
|
||||
C = new Number(30)
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS18033: Only numeric enums can have computed members, but this expression has type 'Number'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
!!! error TS18033: Type 'Number' is not assignable to type 'number' as required for computed enum member values.
|
||||
!!! error TS18033: 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible.
|
||||
}
|
||||
|
||||
enum E9 {
|
||||
@@ -63,19 +64,19 @@ tests/cases/conformance/enums/enumErrors.ts(53,33): error TS2452: An enum member
|
||||
enum E11 {
|
||||
A = true,
|
||||
~~~~
|
||||
!!! error TS18033: Only numeric enums can have computed members, but this expression has type 'true'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
!!! error TS18033: Type 'boolean' is not assignable to type 'number' as required for computed enum member values.
|
||||
B = new Date(),
|
||||
~~~~~~~~~~
|
||||
!!! error TS18033: Only numeric enums can have computed members, but this expression has type 'Date'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
!!! error TS18033: Type 'Date' is not assignable to type 'number' as required for computed enum member values.
|
||||
C = window,
|
||||
~~~~~~
|
||||
!!! error TS18033: Only numeric enums can have computed members, but this expression has type 'Window & typeof globalThis'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
!!! error TS18033: Type 'Window & typeof globalThis' is not assignable to type 'number' as required for computed enum member values.
|
||||
D = {},
|
||||
~~
|
||||
!!! error TS18033: Only numeric enums can have computed members, but this expression has type '{}'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
!!! error TS18033: Type '{}' is not assignable to type 'number' as required for computed enum member values.
|
||||
E = (() => 'foo')(),
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS18033: Only numeric enums can have computed members, but this expression has type 'string'. If you do not need exhaustiveness checks, consider using an object literal instead.
|
||||
!!! error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values.
|
||||
}
|
||||
|
||||
// Enum with string valued member and computed member initializers
|
||||
@@ -83,19 +84,17 @@ tests/cases/conformance/enums/enumErrors.ts(53,33): error TS2452: An enum member
|
||||
A = '',
|
||||
B = new Date(),
|
||||
~~~~~~~~~~
|
||||
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
!!! error TS18033: Type 'Date' is not assignable to type 'number' as required for computed enum member values.
|
||||
C = window,
|
||||
~~~~~~
|
||||
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
!!! error TS18033: Type 'Window & typeof globalThis' is not assignable to type 'number' as required for computed enum member values.
|
||||
D = {},
|
||||
~~
|
||||
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
!!! error TS18033: Type '{}' is not assignable to type 'number' as required for computed enum member values.
|
||||
E = 1 + 1,
|
||||
~~~~~
|
||||
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
F = (() => 'foo')(),
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||
!!! error TS18033: Type 'string' is not assignable to type 'number' as required for computed enum member values.
|
||||
}
|
||||
|
||||
// Enum with incorrect syntax
|
||||
|
||||
@@ -98,11 +98,11 @@ var E11;
|
||||
var E12;
|
||||
(function (E12) {
|
||||
E12["A"] = "";
|
||||
E12[E12["B"] = 0] = "B";
|
||||
E12[E12["C"] = 0] = "C";
|
||||
E12[E12["D"] = 0] = "D";
|
||||
E12[E12["E"] = 0] = "E";
|
||||
E12[E12["F"] = 0] = "F";
|
||||
E12[E12["B"] = new Date()] = "B";
|
||||
E12[E12["C"] = window] = "C";
|
||||
E12[E12["D"] = {}] = "D";
|
||||
E12[E12["E"] = 2] = "E";
|
||||
E12[E12["F"] = (function () { return 'foo'; })()] = "F";
|
||||
})(E12 || (E12 = {}));
|
||||
// Enum with incorrect syntax
|
||||
var E13;
|
||||
|
||||
@@ -40,13 +40,13 @@ enum E10 {
|
||||
>E10 : E10
|
||||
|
||||
A = E9.A,
|
||||
>A : E10
|
||||
>A : E10.A
|
||||
>E9.A : E9
|
||||
>E9 : typeof E9
|
||||
>A : E9
|
||||
|
||||
B = E9.B
|
||||
>B : E10
|
||||
>B : E10.A
|
||||
>E9.B : E9
|
||||
>E9 : typeof E9
|
||||
>B : E9
|
||||
@@ -57,24 +57,24 @@ enum E11 {
|
||||
>E11 : E11
|
||||
|
||||
A = true,
|
||||
>A : E11
|
||||
>A : E11.A
|
||||
>true : true
|
||||
|
||||
B = new Date(),
|
||||
>B : E11
|
||||
>B : E11.B
|
||||
>new Date() : Date
|
||||
>Date : DateConstructor
|
||||
|
||||
C = window,
|
||||
>C : E11
|
||||
>C : E11.C
|
||||
>window : Window & typeof globalThis
|
||||
|
||||
D = {},
|
||||
>D : E11
|
||||
>D : E11.D
|
||||
>{} : {}
|
||||
|
||||
E = (() => 'foo')(),
|
||||
>E : E11
|
||||
>E : E11.E
|
||||
>(() => 'foo')() : string
|
||||
>(() => 'foo') : () => string
|
||||
>() => 'foo' : () => string
|
||||
@@ -95,21 +95,21 @@ enum E12 {
|
||||
>Date : DateConstructor
|
||||
|
||||
C = window,
|
||||
>C : E12.B
|
||||
>C : E12.C
|
||||
>window : Window & typeof globalThis
|
||||
|
||||
D = {},
|
||||
>D : E12.B
|
||||
>D : E12.D
|
||||
>{} : {}
|
||||
|
||||
E = 1 + 1,
|
||||
>E : E12.B
|
||||
>E : E12.E
|
||||
>1 + 1 : number
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
|
||||
F = (() => 'foo')(),
|
||||
>F : E12.B
|
||||
>F : E12.F
|
||||
>(() => 'foo')() : string
|
||||
>(() => 'foo') : () => string
|
||||
>() => 'foo' : () => string
|
||||
|
||||
@@ -3,23 +3,23 @@ export enum Animals {
|
||||
>Animals : Animals
|
||||
|
||||
Cat = 1
|
||||
>Cat : Animals
|
||||
>Cat : Animals.Cat
|
||||
>1 : 1
|
||||
}
|
||||
export enum Animals {
|
||||
>Animals : Animals
|
||||
|
||||
Dog = 2
|
||||
>Dog : Animals
|
||||
>Dog : Animals.Dog
|
||||
>2 : 2
|
||||
}
|
||||
export enum Animals {
|
||||
>Animals : Animals
|
||||
|
||||
CatDog = Cat | Dog
|
||||
>CatDog : Animals
|
||||
>CatDog : Animals.CatDog
|
||||
>Cat | Dog : number
|
||||
>Cat : Animals
|
||||
>Dog : Animals
|
||||
>Cat : Animals.Cat
|
||||
>Dog : Animals.Dog
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(24,7): error TS2322: Type 'Foo' is not assignable to type 'boolean | Foo'.
|
||||
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(25,7): error TS2322: Type 'Foo' is not assignable to type 'boolean | Foo'.
|
||||
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(26,7): error TS2322: Type 'Foo' is not assignable to type 'boolean | Foo.B'.
|
||||
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(27,7): error TS2322: Type 'Foo' is not assignable to type 'boolean | Foo.A'.
|
||||
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(24,7): error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo'.
|
||||
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(25,7): error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo'.
|
||||
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(26,7): error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo.B'.
|
||||
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(27,7): error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo.A'.
|
||||
tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(28,7): error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts (4 errors) ====
|
||||
==== tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts (5 errors) ====
|
||||
module X {
|
||||
export enum Foo {
|
||||
A, B
|
||||
@@ -30,15 +31,17 @@ tests/cases/compiler/enumLiteralAssignableToEnumInsideUnion.ts(27,7): error TS23
|
||||
const e0: X.Foo | boolean = Y.Foo.A; // ok
|
||||
const e1: X.Foo | boolean = Z.Foo.A; // not legal, Z is computed
|
||||
~~
|
||||
!!! error TS2322: Type 'Foo' is not assignable to type 'boolean | Foo'.
|
||||
!!! error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo'.
|
||||
const e2: X.Foo.A | X.Foo.B | boolean = Z.Foo.A; // still not legal
|
||||
~~
|
||||
!!! error TS2322: Type 'Foo' is not assignable to type 'boolean | Foo'.
|
||||
!!! error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo'.
|
||||
const e3: X.Foo.B | boolean = Z.Foo.A; // not legal
|
||||
~~
|
||||
!!! error TS2322: Type 'Foo' is not assignable to type 'boolean | Foo.B'.
|
||||
!!! error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo.B'.
|
||||
const e4: X.Foo.A | boolean = Z.Foo.A; // not legal either because Z.Foo is computed and Z.Foo.A is not necessarily assignable to X.Foo.A
|
||||
~~
|
||||
!!! error TS2322: Type 'Foo' is not assignable to type 'boolean | Foo.A'.
|
||||
!!! error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo.A'.
|
||||
const e5: Ka.Foo | boolean = Z.Foo.A; // ok
|
||||
~~
|
||||
!!! error TS2322: Type 'Foo.A' is not assignable to type 'boolean | Foo'.
|
||||
|
||||
@@ -28,13 +28,13 @@ module Z {
|
||||
>Foo : Foo
|
||||
|
||||
A = 1 << 1,
|
||||
>A : Foo
|
||||
>A : Foo.A
|
||||
>1 << 1 : number
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
|
||||
B = 1 << 2,
|
||||
>B : Foo
|
||||
>B : Foo.B
|
||||
>1 << 2 : number
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
@@ -47,13 +47,13 @@ module Ka {
|
||||
>Foo : Foo
|
||||
|
||||
A = 1 << 10,
|
||||
>A : Foo
|
||||
>A : Foo.A
|
||||
>1 << 10 : number
|
||||
>1 : 1
|
||||
>10 : 10
|
||||
|
||||
B = 1 << 11,
|
||||
>B : Foo
|
||||
>B : Foo.B
|
||||
>1 << 11 : number
|
||||
>1 : 1
|
||||
>11 : 11
|
||||
@@ -71,11 +71,11 @@ const e0: X.Foo | boolean = Y.Foo.A; // ok
|
||||
const e1: X.Foo | boolean = Z.Foo.A; // not legal, Z is computed
|
||||
>e1 : boolean | X.Foo
|
||||
>X : any
|
||||
>Z.Foo.A : Z.Foo
|
||||
>Z.Foo.A : Z.Foo.A
|
||||
>Z.Foo : typeof Z.Foo
|
||||
>Z : typeof Z
|
||||
>Foo : typeof Z.Foo
|
||||
>A : Z.Foo
|
||||
>A : Z.Foo.A
|
||||
|
||||
const e2: X.Foo.A | X.Foo.B | boolean = Z.Foo.A; // still not legal
|
||||
>e2 : boolean | X.Foo
|
||||
@@ -83,38 +83,38 @@ const e2: X.Foo.A | X.Foo.B | boolean = Z.Foo.A; // still not legal
|
||||
>Foo : any
|
||||
>X : any
|
||||
>Foo : any
|
||||
>Z.Foo.A : Z.Foo
|
||||
>Z.Foo.A : Z.Foo.A
|
||||
>Z.Foo : typeof Z.Foo
|
||||
>Z : typeof Z
|
||||
>Foo : typeof Z.Foo
|
||||
>A : Z.Foo
|
||||
>A : Z.Foo.A
|
||||
|
||||
const e3: X.Foo.B | boolean = Z.Foo.A; // not legal
|
||||
>e3 : boolean | X.Foo.B
|
||||
>X : any
|
||||
>Foo : any
|
||||
>Z.Foo.A : Z.Foo
|
||||
>Z.Foo.A : Z.Foo.A
|
||||
>Z.Foo : typeof Z.Foo
|
||||
>Z : typeof Z
|
||||
>Foo : typeof Z.Foo
|
||||
>A : Z.Foo
|
||||
>A : Z.Foo.A
|
||||
|
||||
const e4: X.Foo.A | boolean = Z.Foo.A; // not legal either because Z.Foo is computed and Z.Foo.A is not necessarily assignable to X.Foo.A
|
||||
>e4 : boolean | X.Foo.A
|
||||
>X : any
|
||||
>Foo : any
|
||||
>Z.Foo.A : Z.Foo
|
||||
>Z.Foo.A : Z.Foo.A
|
||||
>Z.Foo : typeof Z.Foo
|
||||
>Z : typeof Z
|
||||
>Foo : typeof Z.Foo
|
||||
>A : Z.Foo
|
||||
>A : Z.Foo.A
|
||||
|
||||
const e5: Ka.Foo | boolean = Z.Foo.A; // ok
|
||||
>e5 : boolean | Ka.Foo
|
||||
>Ka : any
|
||||
>Z.Foo.A : Z.Foo
|
||||
>Z.Foo.A : Z.Foo.A
|
||||
>Z.Foo : typeof Z.Foo
|
||||
>Z : typeof Z
|
||||
>Foo : typeof Z.Foo
|
||||
>A : Z.Foo
|
||||
>A : Z.Foo.A
|
||||
|
||||
@@ -19,7 +19,7 @@ type C = A | B.foo;
|
||||
>B : any
|
||||
|
||||
type D = A | "foo";
|
||||
>D : A | "foo"
|
||||
>D : "foo" | A
|
||||
|
||||
class List<T>
|
||||
>List : List<T>
|
||||
|
||||
@@ -5,8 +5,8 @@ declare namespace lf {
|
||||
|
||||
export enum Order { ASC, DESC }
|
||||
>Order : Order
|
||||
>ASC : Order
|
||||
>DESC : Order
|
||||
>ASC : Order.ASC
|
||||
>DESC : Order.DESC
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/salsa/enums.js ===
|
||||
|
||||
@@ -78,15 +78,15 @@ module M2 {
|
||||
>EComp2 : EComp2
|
||||
|
||||
A = 'foo'.length, B = 'foo'.length, C = 'foo'.length
|
||||
>A : EComp2
|
||||
>A : EComp2.A
|
||||
>'foo'.length : number
|
||||
>'foo' : "foo"
|
||||
>length : number
|
||||
>B : EComp2
|
||||
>B : EComp2.B
|
||||
>'foo'.length : number
|
||||
>'foo' : "foo"
|
||||
>length : number
|
||||
>C : EComp2
|
||||
>C : EComp2.C
|
||||
>'foo'.length : number
|
||||
>'foo' : "foo"
|
||||
>length : number
|
||||
@@ -96,41 +96,41 @@ module M2 {
|
||||
>EComp2 : EComp2
|
||||
|
||||
D = 'foo'.length, E = 'foo'.length, F = 'foo'.length
|
||||
>D : EComp2
|
||||
>D : EComp2.D
|
||||
>'foo'.length : number
|
||||
>'foo' : "foo"
|
||||
>length : number
|
||||
>E : EComp2
|
||||
>E : EComp2.E
|
||||
>'foo'.length : number
|
||||
>'foo' : "foo"
|
||||
>length : number
|
||||
>F : EComp2
|
||||
>F : EComp2.F
|
||||
>'foo'.length : number
|
||||
>'foo' : "foo"
|
||||
>length : number
|
||||
}
|
||||
|
||||
var x = [EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F];
|
||||
>x : EComp2[]
|
||||
>[EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F] : EComp2[]
|
||||
>EComp2.A : EComp2
|
||||
>x : (EComp2.A | EComp2.B | EComp2.C | EComp2.D | EComp2.E | EComp2.F)[]
|
||||
>[EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F] : (EComp2.A | EComp2.B | EComp2.C | EComp2.D | EComp2.E | EComp2.F)[]
|
||||
>EComp2.A : EComp2.A
|
||||
>EComp2 : typeof EComp2
|
||||
>A : EComp2
|
||||
>EComp2.B : EComp2
|
||||
>A : EComp2.A
|
||||
>EComp2.B : EComp2.B
|
||||
>EComp2 : typeof EComp2
|
||||
>B : EComp2
|
||||
>EComp2.C : EComp2
|
||||
>B : EComp2.B
|
||||
>EComp2.C : EComp2.C
|
||||
>EComp2 : typeof EComp2
|
||||
>C : EComp2
|
||||
>EComp2.D : EComp2
|
||||
>C : EComp2.C
|
||||
>EComp2.D : EComp2.D
|
||||
>EComp2 : typeof EComp2
|
||||
>D : EComp2
|
||||
>EComp2.E : EComp2
|
||||
>D : EComp2.D
|
||||
>EComp2.E : EComp2.E
|
||||
>EComp2 : typeof EComp2
|
||||
>E : EComp2
|
||||
>EComp2.F : EComp2
|
||||
>E : EComp2.E
|
||||
>EComp2.F : EComp2.F
|
||||
>EComp2 : typeof EComp2
|
||||
>F : EComp2
|
||||
>F : EComp2.F
|
||||
}
|
||||
|
||||
// Enum with initializer in only one of two declarations with constant members with the same root module
|
||||
|
||||
@@ -5,16 +5,16 @@ module M {
|
||||
|
||||
export enum E1 { A = 0 }
|
||||
>E1 : E1
|
||||
>A : E1
|
||||
>A : E1.A
|
||||
>0 : 0
|
||||
|
||||
export enum E2 { C }
|
||||
>E2 : E2
|
||||
>C : E2
|
||||
>C : E2.C
|
||||
|
||||
export enum E3 { A = 0 }
|
||||
>E3 : E3
|
||||
>A : E3
|
||||
>A : E3.A
|
||||
>0 : 0
|
||||
}
|
||||
module M {
|
||||
@@ -22,37 +22,37 @@ module M {
|
||||
|
||||
export enum E1 { B = 'foo'.length }
|
||||
>E1 : E1
|
||||
>B : E1
|
||||
>B : E1.B
|
||||
>'foo'.length : number
|
||||
>'foo' : "foo"
|
||||
>length : number
|
||||
|
||||
export enum E2 { B = 'foo'.length }
|
||||
>E2 : E2
|
||||
>B : E2
|
||||
>B : E2.B
|
||||
>'foo'.length : number
|
||||
>'foo' : "foo"
|
||||
>length : number
|
||||
|
||||
export enum E3 { C }
|
||||
>E3 : E3
|
||||
>C : E3
|
||||
>C : E3.A
|
||||
}
|
||||
module M {
|
||||
>M : typeof M
|
||||
|
||||
export enum E1 { C }
|
||||
>E1 : E1
|
||||
>C : E1
|
||||
>C : E1.A
|
||||
|
||||
export enum E2 { A = 0 }
|
||||
>E2 : E2
|
||||
>A : E2
|
||||
>A : E2.C
|
||||
>0 : 0
|
||||
|
||||
export enum E3 { B = 'foo'.length }
|
||||
>E3 : E3
|
||||
>B : E3
|
||||
>B : E3.B
|
||||
>'foo'.length : number
|
||||
>'foo' : "foo"
|
||||
>length : number
|
||||
|
||||
@@ -3,13 +3,13 @@ enum Test {
|
||||
>Test : Test
|
||||
|
||||
A,
|
||||
>A : Test
|
||||
>A : Test.A
|
||||
|
||||
B,
|
||||
>B : Test
|
||||
>B : Test.B
|
||||
|
||||
C = Math.floor(Math.random() * 1000),
|
||||
>C : Test
|
||||
>C : Test.C
|
||||
>Math.floor(Math.random() * 1000) : number
|
||||
>Math.floor : (x: number) => number
|
||||
>Math : Math
|
||||
@@ -22,10 +22,10 @@ enum Test {
|
||||
>1000 : 1000
|
||||
|
||||
D = 10,
|
||||
>D : Test
|
||||
>D : Test.D
|
||||
>10 : 10
|
||||
|
||||
E // Error but shouldn't be
|
||||
>E : Test
|
||||
>E : Test.E
|
||||
}
|
||||
|
||||
@@ -3,25 +3,25 @@ enum E {
|
||||
>E : E
|
||||
|
||||
A = A,
|
||||
>A : E
|
||||
>A : E
|
||||
>A : E.A
|
||||
>A : E.A
|
||||
|
||||
B = E.B,
|
||||
>B : E
|
||||
>E.B : E
|
||||
>B : E.B
|
||||
>E.B : E.B
|
||||
>E : typeof E
|
||||
>B : E
|
||||
>B : E.B
|
||||
|
||||
C = E["C"],
|
||||
>C : E
|
||||
>E["C"] : E
|
||||
>C : E.C
|
||||
>E["C"] : E.C
|
||||
>E : typeof E
|
||||
>"C" : "C"
|
||||
|
||||
D = 1 + D
|
||||
>D : E
|
||||
>D : E.D
|
||||
>1 + D : number
|
||||
>1 : 1
|
||||
>D : E
|
||||
>D : E.D
|
||||
}
|
||||
|
||||
@@ -3,16 +3,16 @@ enum A {
|
||||
>A : A
|
||||
|
||||
X = "".length,
|
||||
>X : A
|
||||
>X : A.X
|
||||
>"".length : number
|
||||
>"" : ""
|
||||
>length : number
|
||||
|
||||
Y = X,
|
||||
>Y : A
|
||||
>X : A
|
||||
>Y : A.Y
|
||||
>X : A.X
|
||||
|
||||
Z
|
||||
>Z : A
|
||||
>Z : A.Z
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/enumWithExport.ts(5,7): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
|
||||
tests/cases/compiler/enumWithExport.ts(5,7): error TS2304: Cannot find name 'y'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enumWithExport.ts (1 errors) ====
|
||||
@@ -8,5 +8,5 @@ tests/cases/compiler/enumWithExport.ts(5,7): error TS2651: A member initializer
|
||||
enum x {
|
||||
z = y
|
||||
~
|
||||
!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
|
||||
!!! error TS2304: Cannot find name 'y'.
|
||||
}
|
||||
@@ -12,5 +12,5 @@ var x;
|
||||
x.y = 123;
|
||||
})(x || (x = {}));
|
||||
(function (x) {
|
||||
x[x["z"] = 0] = "z";
|
||||
x[x["z"] = y] = "z";
|
||||
})(x || (x = {}));
|
||||
@@ -10,6 +10,6 @@ enum x {
|
||||
>x : x
|
||||
|
||||
z = y
|
||||
>z : x.z
|
||||
>z : x
|
||||
>y : any
|
||||
}
|
||||
@@ -3,7 +3,7 @@ enum E {
|
||||
>E : E
|
||||
|
||||
e = -(3
|
||||
>e : E
|
||||
>e : E.e
|
||||
>-(3 : number
|
||||
>(3 : 3
|
||||
>3 : 3
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
tests/cases/conformance/types/typeRelationships/comparable/equalityWithEnumTypes.ts(14,9): error TS2367: This comparison appears to be unintentional because the types 'E1' and '0' have no overlap.
|
||||
tests/cases/conformance/types/typeRelationships/comparable/equalityWithEnumTypes.ts(23,9): error TS2367: This comparison appears to be unintentional because the types 'E1' and '3' have no overlap.
|
||||
tests/cases/conformance/types/typeRelationships/comparable/equalityWithEnumTypes.ts(29,9): error TS2367: This comparison appears to be unintentional because the types 'E2' and '0' have no overlap.
|
||||
tests/cases/conformance/types/typeRelationships/comparable/equalityWithEnumTypes.ts(38,9): error TS2367: This comparison appears to be unintentional because the types 'E2' and '3' have no overlap.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/comparable/equalityWithEnumTypes.ts (2 errors) ====
|
||||
==== tests/cases/conformance/types/typeRelationships/comparable/equalityWithEnumTypes.ts (4 errors) ====
|
||||
// Literal enum type
|
||||
enum E1 {
|
||||
a = 1,
|
||||
@@ -36,6 +38,8 @@ tests/cases/conformance/types/typeRelationships/comparable/equalityWithEnumTypes
|
||||
|
||||
function f2(v: E2) {
|
||||
if (v !== 0) {
|
||||
~~~~~~~
|
||||
!!! error TS2367: This comparison appears to be unintentional because the types 'E2' and '0' have no overlap.
|
||||
v;
|
||||
}
|
||||
if (v !== 1) {
|
||||
@@ -45,6 +49,8 @@ tests/cases/conformance/types/typeRelationships/comparable/equalityWithEnumTypes
|
||||
v;
|
||||
}
|
||||
if (v !== 3) {
|
||||
~~~~~~~
|
||||
!!! error TS2367: This comparison appears to be unintentional because the types 'E2' and '3' have no overlap.
|
||||
v;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ enum E2 {
|
||||
>E2 : E2
|
||||
|
||||
a = 1 << 0,
|
||||
>a : E2
|
||||
>a : E2.a
|
||||
>1 << 0 : number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
|
||||
b = 1 << 1
|
||||
>b : E2
|
||||
>b : E2.b
|
||||
>1 << 1 : number
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
@@ -85,7 +85,7 @@ function f2(v: E2) {
|
||||
>1 : 1
|
||||
|
||||
v;
|
||||
>v : E2
|
||||
>v : E2.b
|
||||
}
|
||||
if (v !== 2) {
|
||||
>v !== 2 : boolean
|
||||
@@ -93,7 +93,7 @@ function f2(v: E2) {
|
||||
>2 : 2
|
||||
|
||||
v;
|
||||
>v : E2
|
||||
>v : E2.a
|
||||
}
|
||||
if (v !== 3) {
|
||||
>v !== 3 : boolean
|
||||
|
||||
@@ -5,19 +5,19 @@ enum U8 {
|
||||
>U8 : U8
|
||||
|
||||
BIT_0 = 1 << 0,
|
||||
>BIT_0 : U8
|
||||
>BIT_0 : U8.BIT_0
|
||||
>1 << 0 : number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
|
||||
BIT_1 = 1 << 1,
|
||||
>BIT_1 : U8
|
||||
>BIT_1 : U8.BIT_1
|
||||
>1 << 1 : number
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
|
||||
BIT_2 = 1 << 2
|
||||
>BIT_2 : U8
|
||||
>BIT_2 : U8.BIT_2
|
||||
>1 << 2 : number
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
|
||||
@@ -5,25 +5,25 @@ enum E1 {
|
||||
// illegal case
|
||||
// forward reference to the element of the same enum
|
||||
X = Y,
|
||||
>X : E1
|
||||
>Y : E1
|
||||
>X : E1.X
|
||||
>Y : E1.X
|
||||
|
||||
X1 = E1["Y"],
|
||||
>X1 : E1
|
||||
>E1["Y"] : E1
|
||||
>X1 : E1.X
|
||||
>E1["Y"] : E1.X
|
||||
>E1 : typeof E1
|
||||
>"Y" : "Y"
|
||||
|
||||
// forward reference to the element of the same enum
|
||||
Y = E1.Z,
|
||||
>Y : E1
|
||||
>E1.Z : E1
|
||||
>Y : E1.X
|
||||
>E1.Z : E1.Z
|
||||
>E1 : typeof E1
|
||||
>Z : E1
|
||||
>Z : E1.Z
|
||||
|
||||
Y1 = E1["Z"]
|
||||
>Y1 : E1
|
||||
>E1["Z"] : E1
|
||||
>Y1 : E1.X
|
||||
>E1["Z"] : E1.Z
|
||||
>E1 : typeof E1
|
||||
>"Z" : "Z"
|
||||
}
|
||||
@@ -32,7 +32,7 @@ enum E1 {
|
||||
>E1 : E1
|
||||
|
||||
Z = 4
|
||||
>Z : E1
|
||||
>Z : E1.Z
|
||||
>4 : 4
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ enum MyEnum {
|
||||
>MyEnum : MyEnum
|
||||
|
||||
a = MyEnumFromModule.a
|
||||
>a : MyEnum
|
||||
>a : MyEnum.a
|
||||
>MyEnumFromModule.a : MyEnumFromModule.a
|
||||
>MyEnumFromModule : typeof MyEnumFromModule
|
||||
>a : MyEnumFromModule.a
|
||||
|
||||
@@ -3,15 +3,15 @@ declare enum E {
|
||||
>E : E
|
||||
|
||||
a = 10,
|
||||
>a : E
|
||||
>a : E.a
|
||||
>10 : 10
|
||||
|
||||
b = a,
|
||||
>b : E
|
||||
>a : E
|
||||
>b : E.a
|
||||
>a : E.a
|
||||
|
||||
e = 10 << 2 * 8,
|
||||
>e : E
|
||||
>e : E.e
|
||||
>10 << 2 * 8 : number
|
||||
>10 : 10
|
||||
>2 * 8 : number
|
||||
|
||||
@@ -102,9 +102,9 @@ declare class CX { a: number }
|
||||
|
||||
declare enum EX { A, B, C }
|
||||
>EX : EX
|
||||
>A : EX
|
||||
>B : EX
|
||||
>C : EX
|
||||
>A : EX.A
|
||||
>B : EX.B
|
||||
>C : EX.C
|
||||
|
||||
declare namespace NX { export const a = 1 }
|
||||
>NX : typeof NX
|
||||
|
||||
@@ -29,7 +29,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(31,11): error TS2430: Interface 'I11' incorrectly extends interface 'typeof EX'.
|
||||
Types of property 'C' are incompatible.
|
||||
Type 'string' is not assignable to type 'EX'.
|
||||
Type 'string' is not assignable to type 'EX.C'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(32,11): error TS2430: Interface 'I12' incorrectly extends interface 'typeof NX'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'number' is not assignable to type '"hello"'.
|
||||
@@ -130,7 +130,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI
|
||||
~~~
|
||||
!!! error TS2430: Interface 'I11' incorrectly extends interface 'typeof EX'.
|
||||
!!! error TS2430: Types of property 'C' are incompatible.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'EX'.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'EX.C'.
|
||||
interface I12 extends TNX { a: number }
|
||||
~~~
|
||||
!!! error TS2430: Interface 'I12' incorrectly extends interface 'typeof NX'.
|
||||
|
||||
@@ -73,9 +73,9 @@ declare class CX { static a: string }
|
||||
|
||||
declare enum EX { A, B, C }
|
||||
>EX : EX
|
||||
>A : EX
|
||||
>B : EX
|
||||
>C : EX
|
||||
>A : EX.A
|
||||
>B : EX.B
|
||||
>C : EX.C
|
||||
|
||||
declare namespace NX { export const a = "hello" }
|
||||
>NX : typeof NX
|
||||
|
||||
@@ -98,67 +98,67 @@ export enum K {
|
||||
>K : K
|
||||
|
||||
None = 0,
|
||||
>None : K
|
||||
>None : K.None
|
||||
>0 : 0
|
||||
|
||||
A = 1 << 0,
|
||||
>A : K
|
||||
>A : K.A
|
||||
>1 << 0 : number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
|
||||
B = 1 << 1,
|
||||
>B : K
|
||||
>B : K.B
|
||||
>1 << 1 : number
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
|
||||
C = 1 << 2,
|
||||
>C : K
|
||||
>C : K.C
|
||||
>1 << 2 : number
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
|
||||
Mask = A | B | C,
|
||||
>Mask : K
|
||||
>Mask : K.Mask
|
||||
>A | B | C : number
|
||||
>A | B : number
|
||||
>A : K
|
||||
>B : K
|
||||
>C : K
|
||||
>A : K.A
|
||||
>B : K.B
|
||||
>C : K.C
|
||||
}
|
||||
|
||||
export const enum L {
|
||||
>L : L
|
||||
|
||||
None = 0,
|
||||
>None : L
|
||||
>None : L.None
|
||||
>0 : 0
|
||||
|
||||
A = 1 << 0,
|
||||
>A : L
|
||||
>A : L.A
|
||||
>1 << 0 : number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
|
||||
B = 1 << 1,
|
||||
>B : L
|
||||
>B : L.B
|
||||
>1 << 1 : number
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
|
||||
C = 1 << 2,
|
||||
>C : L
|
||||
>C : L.C
|
||||
>1 << 2 : number
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
|
||||
Mask = A | B | C,
|
||||
>Mask : L
|
||||
>Mask : L.Mask
|
||||
>A | B | C : number
|
||||
>A | B : number
|
||||
>A : L
|
||||
>B : L
|
||||
>C : L
|
||||
>A : L.A
|
||||
>B : L.B
|
||||
>C : L.C
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ declare module "./reexport" {
|
||||
>Root : Root
|
||||
|
||||
A,
|
||||
>A : Root
|
||||
>A : Root.A
|
||||
|
||||
B,
|
||||
>B : Root
|
||||
>B : Root.B
|
||||
|
||||
C
|
||||
>C : Root
|
||||
>C : Root.C
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ declare const f: ns.Root.Foo;
|
||||
const g: ns.Root = ns.Root.A;
|
||||
>g : ns.Root
|
||||
>ns : any
|
||||
>ns.Root.A : ns.Root
|
||||
>ns.Root.A : ns.Root.A
|
||||
>ns.Root : typeof ns.Root
|
||||
>ns : typeof ns
|
||||
>Root : typeof ns.Root
|
||||
>A : ns.Root
|
||||
>A : ns.Root.A
|
||||
|
||||
f.x;
|
||||
>f.x : number
|
||||
|
||||
@@ -19,9 +19,9 @@ declare module "./reexport" {
|
||||
>Foo : Foo
|
||||
|
||||
A, B, C
|
||||
>A : Foo
|
||||
>B : Foo
|
||||
>C : Foo
|
||||
>A : Foo.A
|
||||
>B : Foo.B
|
||||
>C : Foo.C
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -397,13 +397,13 @@ declare module mAmbient {
|
||||
>e : e
|
||||
|
||||
x,
|
||||
>x : e
|
||||
>x : e.x
|
||||
|
||||
y,
|
||||
>y : e
|
||||
>y : e.y
|
||||
|
||||
z
|
||||
>z : e
|
||||
>z : e.z
|
||||
}
|
||||
|
||||
module m3 {
|
||||
@@ -433,13 +433,13 @@ declare module mAmbient {
|
||||
>e : e
|
||||
|
||||
x,
|
||||
>x : e
|
||||
>x : e.x
|
||||
|
||||
y,
|
||||
>y : e
|
||||
>y : e.y
|
||||
|
||||
z
|
||||
>z : e
|
||||
>z : e.z
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ class C {
|
||||
}
|
||||
enum E { A = 0, B = E.A }
|
||||
>E : E
|
||||
>A : E
|
||||
>A : E.A
|
||||
>0 : 0
|
||||
>B : E
|
||||
>B : E.A
|
||||
>E.A : E
|
||||
>E : typeof E
|
||||
>A : E
|
||||
|
||||
@@ -102,8 +102,8 @@ type T1 = {
|
||||
[K in N1 | N2]: K;
|
||||
};
|
||||
declare enum E {
|
||||
ONE = 0,
|
||||
TWO = 1,
|
||||
ONE,
|
||||
TWO,
|
||||
THREE = "x"
|
||||
}
|
||||
declare const e: E;
|
||||
|
||||
@@ -9,9 +9,9 @@ enum E1 { ONE, TWO, THREE }
|
||||
|
||||
declare enum E2 { ONE, TWO, THREE }
|
||||
>E2 : E2
|
||||
>ONE : E2
|
||||
>TWO : E2
|
||||
>THREE : E2
|
||||
>ONE : E2.ONE
|
||||
>TWO : E2.TWO
|
||||
>THREE : E2.THREE
|
||||
|
||||
type Bins1 = { [k in E1]?: string; }
|
||||
>Bins1 : { 0?: string | undefined; 1?: string | undefined; 2?: string | undefined; }
|
||||
@@ -35,9 +35,9 @@ const e1: E1 = E1.ONE;
|
||||
|
||||
const e2: E2 = E2.ONE;
|
||||
>e2 : E2
|
||||
>E2.ONE : E2
|
||||
>E2.ONE : E2.ONE
|
||||
>E2 : typeof E2
|
||||
>ONE : E2
|
||||
>ONE : E2.ONE
|
||||
|
||||
b1[1] = "a";
|
||||
>b1[1] = "a" : "a"
|
||||
@@ -64,7 +64,7 @@ b2[e2] = "b";
|
||||
>b2[e2] = "b" : "b"
|
||||
>b2[e2] : string | undefined
|
||||
>b2 : Bins2
|
||||
>e2 : E2
|
||||
>e2 : E2.ONE
|
||||
>"b" : "b"
|
||||
|
||||
// Multiple numeric enum types accrue to the same numeric index signature in a mapped type
|
||||
@@ -74,24 +74,24 @@ declare function val(): number;
|
||||
|
||||
enum N1 { A = val(), B = val() }
|
||||
>N1 : N1
|
||||
>A : N1
|
||||
>A : N1.A
|
||||
>val() : number
|
||||
>val : () => number
|
||||
>B : N1
|
||||
>B : N1.B
|
||||
>val() : number
|
||||
>val : () => number
|
||||
|
||||
enum N2 { C = val(), D = val() }
|
||||
>N2 : N2
|
||||
>C : N2
|
||||
>C : N2.C
|
||||
>val() : number
|
||||
>val : () => number
|
||||
>D : N2
|
||||
>D : N2.D
|
||||
>val() : number
|
||||
>val : () => number
|
||||
|
||||
type T1 = { [K in N1 | N2]: K };
|
||||
>T1 : { [x: number]: N1 | N2; }
|
||||
>T1 : { [x: number]: N1.A | N1.B | N2.C | N2.D; }
|
||||
|
||||
// Enum types with string valued members are always literal enum types and therefore
|
||||
// ONE and TWO below are not computed members but rather just numerically valued members
|
||||
|
||||
@@ -3,7 +3,7 @@ enum E {
|
||||
>E : E
|
||||
|
||||
[e] = 1
|
||||
>[e] : E.__computed
|
||||
>[e] : E
|
||||
>e : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -3,7 +3,7 @@ enum E {
|
||||
>E : E
|
||||
|
||||
[e] = 1
|
||||
>[e] : E.__computed
|
||||
>[e] : E
|
||||
>e : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -3,21 +3,21 @@
|
||||
>SignatureFlags : SignatureFlags
|
||||
|
||||
None = 0,
|
||||
>None : SignatureFlags
|
||||
>None : SignatureFlags.None
|
||||
>0 : 0
|
||||
|
||||
IsIndexer = 1,
|
||||
>IsIndexer : SignatureFlags
|
||||
>IsIndexer : SignatureFlags.IsIndexer
|
||||
>1 : 1
|
||||
|
||||
IsStringIndexer = 1 << 1,
|
||||
>IsStringIndexer : SignatureFlags
|
||||
>IsStringIndexer : SignatureFlags.IsStringIndexer
|
||||
>1 << 1 : number
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
|
||||
IsNumberIndexer = 1 << 2,
|
||||
>IsNumberIndexer : SignatureFlags
|
||||
>IsNumberIndexer : SignatureFlags.IsNumberIndexer
|
||||
>1 << 2 : number
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
|
||||
@@ -3,21 +3,21 @@
|
||||
>SignatureFlags : SignatureFlags
|
||||
|
||||
None = 0,
|
||||
>None : SignatureFlags
|
||||
>None : SignatureFlags.None
|
||||
>0 : 0
|
||||
|
||||
IsIndexer = 1,
|
||||
>IsIndexer : SignatureFlags
|
||||
>IsIndexer : SignatureFlags.IsIndexer
|
||||
>1 : 1
|
||||
|
||||
IsStringIndexer = 1 << 1,
|
||||
>IsStringIndexer : SignatureFlags
|
||||
>IsStringIndexer : SignatureFlags.IsStringIndexer
|
||||
>1 << 1 : number
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
|
||||
IsNumberIndexer = 1 << 2
|
||||
>IsNumberIndexer : SignatureFlags
|
||||
>IsNumberIndexer : SignatureFlags.IsNumberIndexer
|
||||
>1 << 2 : number
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
|
||||
@@ -3,18 +3,18 @@ enum E {
|
||||
>E : E
|
||||
|
||||
A = 1,
|
||||
>A : E
|
||||
>A : E.A
|
||||
>1 : 1
|
||||
|
||||
B,
|
||||
>B : E
|
||||
>B : E.B
|
||||
|
||||
C = 1 << 1,
|
||||
>C : E
|
||||
>C : E.B
|
||||
>1 << 1 : number
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
|
||||
D,
|
||||
>D : E
|
||||
>D : E.D
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -3805,11 +3805,11 @@ module TypeScript {
|
||||
>GetAstPathOptions : GetAstPathOptions
|
||||
|
||||
Default = 0,
|
||||
>Default : GetAstPathOptions
|
||||
>Default : GetAstPathOptions.Default
|
||||
>0 : 0
|
||||
|
||||
EdgeInclusive = 1,
|
||||
>EdgeInclusive : GetAstPathOptions
|
||||
>EdgeInclusive : GetAstPathOptions.EdgeInclusive
|
||||
>1 : 1
|
||||
|
||||
//We need this options dealing with an AST coming from an incomplete AST. For example:
|
||||
@@ -3820,7 +3820,7 @@ module TypeScript {
|
||||
// we don't find the "precomment" attached to the errorneous empty stmt.
|
||||
//TODO: It would be nice to be able to get rid of this.
|
||||
DontPruneSearchBasedOnPosition = 1 << 1,
|
||||
>DontPruneSearchBasedOnPosition : GetAstPathOptions
|
||||
>DontPruneSearchBasedOnPosition : GetAstPathOptions.DontPruneSearchBasedOnPosition
|
||||
>1 << 1 : number
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
@@ -3835,9 +3835,9 @@ module TypeScript {
|
||||
>TypeScript : any
|
||||
>pos : number
|
||||
>options : GetAstPathOptions
|
||||
>GetAstPathOptions.Default : GetAstPathOptions
|
||||
>GetAstPathOptions.Default : GetAstPathOptions.Default
|
||||
>GetAstPathOptions : typeof GetAstPathOptions
|
||||
>Default : GetAstPathOptions
|
||||
>Default : GetAstPathOptions.Default
|
||||
>TypeScript : any
|
||||
|
||||
var lookInComments = (comments: TypeScript.Comment[]) => {
|
||||
@@ -3948,9 +3948,9 @@ module TypeScript {
|
||||
>hasFlag(options, GetAstPathOptions.EdgeInclusive) : any
|
||||
>hasFlag : any
|
||||
>options : GetAstPathOptions
|
||||
>GetAstPathOptions.EdgeInclusive : GetAstPathOptions
|
||||
>GetAstPathOptions.EdgeInclusive : GetAstPathOptions.EdgeInclusive
|
||||
>GetAstPathOptions : typeof GetAstPathOptions
|
||||
>EdgeInclusive : GetAstPathOptions
|
||||
>EdgeInclusive : GetAstPathOptions.EdgeInclusive
|
||||
|
||||
cur.nodeType === TypeScript.NodeType.Name ||
|
||||
>cur.nodeType === TypeScript.NodeType.Name : boolean
|
||||
@@ -4075,9 +4075,9 @@ module TypeScript {
|
||||
>hasFlag(options, GetAstPathOptions.DontPruneSearchBasedOnPosition) : any
|
||||
>hasFlag : any
|
||||
>options : GetAstPathOptions
|
||||
>GetAstPathOptions.DontPruneSearchBasedOnPosition : GetAstPathOptions
|
||||
>GetAstPathOptions.DontPruneSearchBasedOnPosition : GetAstPathOptions.DontPruneSearchBasedOnPosition
|
||||
>GetAstPathOptions : typeof GetAstPathOptions
|
||||
>DontPruneSearchBasedOnPosition : GetAstPathOptions
|
||||
>DontPruneSearchBasedOnPosition : GetAstPathOptions.DontPruneSearchBasedOnPosition
|
||||
|
||||
// Don't go further down the tree if pos is outside of [minChar, limChar]
|
||||
walker.options.goChildren = (minChar <= pos && pos <= limChar);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -3,7 +3,7 @@ export enum E {
|
||||
>E : E
|
||||
|
||||
A = 12 + 01
|
||||
>A : E
|
||||
>A : E.A
|
||||
>12 + 01 : number
|
||||
>12 : 12
|
||||
>01 : 1
|
||||
|
||||
@@ -106,17 +106,17 @@ type TNumberLiteralEnum0 = "0" extends `${infer T extends NumberLiteralEnum}` ?
|
||||
// infer from non-literal enums
|
||||
const enum NonLiteralEnum { Zero = NumberLiteralEnum.Zero, One = NumberLiteralEnum.One }
|
||||
>NonLiteralEnum : NonLiteralEnum
|
||||
>Zero : NonLiteralEnum
|
||||
>Zero : NonLiteralEnum.Zero
|
||||
>NumberLiteralEnum.Zero : NumberLiteralEnum.Zero
|
||||
>NumberLiteralEnum : typeof NumberLiteralEnum
|
||||
>Zero : NumberLiteralEnum.Zero
|
||||
>One : NonLiteralEnum
|
||||
>One : NonLiteralEnum.One
|
||||
>NumberLiteralEnum.One : NumberLiteralEnum.One
|
||||
>NumberLiteralEnum : typeof NumberLiteralEnum
|
||||
>One : NumberLiteralEnum.One
|
||||
|
||||
type TNonLiteralEnum0 = "0" extends `${infer T extends NonLiteralEnum}` ? T : never; // 0
|
||||
>TNonLiteralEnum0 : 0
|
||||
>TNonLiteralEnum0 : NonLiteralEnum.Zero
|
||||
|
||||
// infer using priority:
|
||||
// string > template-literal > (string-literal | string-literal-enum) >
|
||||
@@ -346,15 +346,15 @@ type PNumber3 = "0" extends `${infer T extends number | 0n}` ? T : never; // 0
|
||||
// #region enum
|
||||
// enum > number-literal-enum
|
||||
type PEnum0 = "0" extends `${infer T extends NonLiteralEnum | NumberLiteralEnum}` ? T : never; // 0
|
||||
>PEnum0 : 0
|
||||
>PEnum0 : NumberLiteralEnum.Zero
|
||||
|
||||
// enum > bigint
|
||||
type PEnum1 = "0" extends `${infer T extends NonLiteralEnum | bigint}` ? T : never; // 0
|
||||
>PEnum1 : 0
|
||||
>PEnum1 : NonLiteralEnum.Zero
|
||||
|
||||
// enum > bigint-literal
|
||||
type PEnum2 = "0" extends `${infer T extends NonLiteralEnum | 0n}` ? T : never; // 0
|
||||
>PEnum2 : 0
|
||||
>PEnum2 : NonLiteralEnum.Zero
|
||||
|
||||
// #endregion enum
|
||||
|
||||
|
||||
@@ -72,11 +72,11 @@ enum SomeEnum {
|
||||
>SomeEnum : SomeEnum
|
||||
|
||||
A = this, // Should not be allowed
|
||||
>A : SomeEnum
|
||||
>A : SomeEnum.A
|
||||
>this : any
|
||||
|
||||
B = this.spaaaace // Also should not be allowed
|
||||
>B : SomeEnum
|
||||
>B : SomeEnum.B
|
||||
>this.spaaaace : any
|
||||
>this : any
|
||||
>spaaaace : any
|
||||
|
||||
@@ -72,11 +72,11 @@ enum SomeEnum {
|
||||
>SomeEnum : SomeEnum
|
||||
|
||||
A = this, // Should not be allowed
|
||||
>A : SomeEnum
|
||||
>A : SomeEnum.A
|
||||
>this : any
|
||||
|
||||
B = this.spaaaace // Also should not be allowed
|
||||
>B : SomeEnum
|
||||
>B : SomeEnum.B
|
||||
>this.spaaaace : any
|
||||
>this : any
|
||||
>spaaaace : any
|
||||
|
||||
@@ -3,13 +3,13 @@ enum E {
|
||||
>E : E
|
||||
|
||||
"__foo" = 1,
|
||||
>"__foo" : E
|
||||
>"__foo" : E.__foo
|
||||
>1 : 1
|
||||
|
||||
bar = E["__foo"] + 1
|
||||
>bar : E
|
||||
>bar : E.bar
|
||||
>E["__foo"] + 1 : number
|
||||
>E["__foo"] : E
|
||||
>E["__foo"] : E.__foo
|
||||
>E : typeof E
|
||||
>"__foo" : "__foo"
|
||||
>1 : 1
|
||||
|
||||
@@ -10,6 +10,6 @@ const CONST = 9000 % 2;
|
||||
const enum D {
|
||||
d = 10,
|
||||
e = 199 * Math.floor(Math.random() * 1000),
|
||||
f = d - (100 * Math.floor(Math.random() % 8))
|
||||
f = d - (100 * Math.floor(Math.random() % 8)),
|
||||
g = CONST,
|
||||
}
|
||||
@@ -19,7 +19,7 @@ verify.codeFix({
|
||||
}
|
||||
enum A {
|
||||
a = E.c,
|
||||
b
|
||||
b = "b"
|
||||
}
|
||||
A.b`
|
||||
});
|
||||
@@ -25,7 +25,7 @@ enum A {
|
||||
}
|
||||
enum B {
|
||||
b = A.a,
|
||||
c
|
||||
c = "c"
|
||||
}
|
||||
B.c`
|
||||
});
|
||||
Reference in new issue
Block a user