diff --git a/bin/tsc.js b/bin/tsc.js index 52ffd2b3b1b79..84b02f9492b0d 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -21,6 +21,12 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ts.ExitStatus || (ts.ExitStatus = {})); var ExitStatus = ts.ExitStatus; + (function (IndexAlphaNumeric) { + IndexAlphaNumeric[IndexAlphaNumeric["NO"] = 0] = "NO"; + IndexAlphaNumeric[IndexAlphaNumeric["YES"] = 1] = "YES"; + IndexAlphaNumeric[IndexAlphaNumeric["INHERITED"] = 2] = "INHERITED"; + })(ts.IndexAlphaNumeric || (ts.IndexAlphaNumeric = {})); + var IndexAlphaNumeric = ts.IndexAlphaNumeric; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; @@ -926,7 +932,7 @@ var ts; An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, + An_index_signature_parameter_type_must_be_string_number_or_an_enum_type: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string', 'number', or an enum type." }, A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: ts.DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: ts.DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, A_class_can_only_extend_a_single_class: { code: 1026, category: ts.DiagnosticCategory.Error, key: "A class can only extend a single class." }, @@ -1076,6 +1082,12 @@ var ts; Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." }, + Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, + Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -1104,8 +1116,8 @@ var ts; Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible." }, Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, + Missing_0_index_signature_in_type_1: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Missing {0} index signature in type '{1}'." }, + Index_signatures_0_and_1_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures '{0}' and '{1}' are incompatible." }, this_cannot_be_referenced_in_a_module_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module body." }, this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, @@ -1180,9 +1192,9 @@ var ts; Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" }, All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, + Property_0_of_type_1_is_not_assignable_to_string_index_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index '{2}'." }, + Property_0_of_type_1_is_not_assignable_to_numeric_index_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index '{2}'." }, + Numeric_index_0_is_not_assignable_to_string_index_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index '{0}' is not assignable to string index '{1}'." }, Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class name cannot be '{0}'" }, Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly extends base class '{1}'." }, Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, @@ -5492,7 +5504,7 @@ var ts; if (token === 111 && inYieldContext()) { return false; } - return inStrictModeContext() ? token > 111 : token > 101; + return token > 101; } function parseExpected(kind, diagnosticMessage) { if (token === kind) { @@ -5586,6 +5598,9 @@ var ts; identifierCount++; if (isIdentifier) { var node = createNode(65); + if (token !== 65) { + node.originalKeywordKind = token; + } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); @@ -7716,6 +7731,17 @@ var ts; node.body = parseFunctionBlockOrSemicolon(false); return finishNode(node); } + function isClassMemberModifier(idToken) { + switch (idToken) { + case 109: + case 107: + case 108: + case 110: + return true; + default: + return false; + } + } function isClassMemberStart() { var idToken; if (token === 52) { @@ -7723,6 +7749,9 @@ var ts; } while (ts.isModifier(token)) { idToken = token; + if (isClassMemberModifier(idToken)) { + return true; + } nextToken(); } if (token === 35) { @@ -8386,7 +8415,7 @@ var ts; getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: getIndexTypeOfType, + getIndexTypeOfType: getIndexValueOfType, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, @@ -8432,7 +8461,9 @@ var ts; var globalFunctionType; var globalArrayType; var globalStringType; + var globalStringSubsetType; var globalNumberType; + var globalNumberSubsetType; var globalBooleanType; var globalRegExpType; var globalTemplateStringsArrayType; @@ -9170,6 +9201,19 @@ var ts; type.symbol = symbol; return type; } + function cloneInterfaceType(type, flags) { + var cloneType = createType(type.flags); + cloneType.symbol = type.symbol; + cloneType.flags |= flags; + cloneType.baseTypes = type.baseTypes; + cloneType.declaredCallSignatures = type.declaredCallSignatures; + cloneType.declaredConstructSignatures = type.declaredCallSignatures; + cloneType.declaredNumberIndex = type.declaredNumberIndex; + cloneType.declaredStringIndex = type.declaredStringIndex; + cloneType.declaredProperties = type.declaredProperties; + cloneType.typeParameters = type.typeParameters; + return cloneType; + } function isReservedMemberName(name) { return name.charCodeAt(0) === 95 && name.charCodeAt(1) === 95 && @@ -9192,19 +9236,27 @@ var ts; } return result || emptyArray; } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex) { type.members = members; type.properties = getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexType) - type.stringIndexType = stringIndexType; - if (numberIndexType) - type.numberIndexType = numberIndexType; + if (stringIndex) + type.stringIndex = stringIndex; + if (numberIndex) + type.numberIndex = numberIndex; + if (stringIndex && numberIndex) { + if (numberIndex.inherited && (numberIndex.inherited === stringIndex.inherited)) { + type.alphaNumericIndex = ts.IndexAlphaNumeric.INHERITED; + } + else { + type.alphaNumericIndex = ts.IndexAlphaNumeric.YES; + } + } return type; } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(32768, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndex, numberIndex) { + return setObjectTypeMembers(createObjectType(32768, symbol), members, callSignatures, constructSignatures, stringIndex, numberIndex); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -9418,6 +9470,10 @@ var ts; } return result; } + function indexTypeToString(type) { + var index = type.typeOfIndex || ((type.kind === 0) ? stringType : numberType); + return '[' + typeToString(index) + ']: ' + typeToString(type.typeOfValue); + } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; @@ -9611,7 +9667,8 @@ var ts; buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } function getIndexerParameterName(type, indexKind, fallbackName) { - var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + var indexMap = getDeclaredIndexTypesOfSymbol(type.symbol); + var declaration = indexMap[indexKind] ? indexMap[indexKind].declaredNode : null; if (!declaration) { return fallbackName; } @@ -9620,7 +9677,7 @@ var ts; } function writeLiteralType(type, flags) { var resolved = resolveObjectOrUnionTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.properties.length && !resolved.stringIndex && !resolved.numberIndex) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, 14); writePunctuation(writer, 15); @@ -9666,32 +9723,30 @@ var ts; writePunctuation(writer, 22); writer.writeLine(); } - if (resolved.stringIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 51); - writeSpace(writer); - writeKeyword(writer, 121); - writePunctuation(writer, 19); - writePunctuation(writer, 51); - writeSpace(writer); - writeType(resolved.stringIndexType, 0); - writePunctuation(writer, 22); - writer.writeLine(); - } - if (resolved.numberIndexType) { + function writeIndexType(indexType) { + if (!indexType) { + return; + } writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); + writer.writeParameter(getIndexerParameterName(resolved, indexType.kind, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 119); + if (indexType.typeOfIndex && (indexType.typeOfIndex.flags & 2097152)) { + writeType(indexType.typeOfIndex, 0); + writer.writeStringLiteral(indexType.kind === 0 ? " < string" : " < number"); + } + else { + writeKeyword(writer, indexType.kind === 0 ? 121 : 119); + } writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); - writeType(resolved.numberIndexType, 0); + writeType(indexType.typeOfValue, 0); writePunctuation(writer, 22); writer.writeLine(); } + writeIndexType(resolved.stringIndex); + writeIndexType(resolved.numberIndex); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -10004,8 +10059,8 @@ var ts; if (pattern.kind === 150) { var name_5 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_5.text) || - isNumericLiteralName(name_5.text) && getIndexTypeOfType(parentType, 1) || - getIndexTypeOfType(parentType, 0); + isNumericLiteralName(name_5.text) && getIndexValueOfType(parentType, 1) || + getIndexValueOfType(parentType, 0); if (!type) { error(name_5, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_5)); return unknownType; @@ -10345,8 +10400,9 @@ var ts; type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = emptyArray; type.declaredConstructSignatures = emptyArray; - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); + var indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + type.declaredStringIndex = indexTypes[0]; + type.declaredNumberIndex = indexTypes[1]; } return links.declaredType; } @@ -10387,8 +10443,9 @@ var ts; type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); + var indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + type.declaredStringIndex = indexTypes[0]; + type.declaredNumberIndex = indexTypes[1]; } return links.declaredType; } @@ -10412,7 +10469,7 @@ var ts; function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(128); + var type = createType(128 | 2097152); type.symbol = symbol; links.declaredType = type; } @@ -10491,23 +10548,55 @@ var ts; } } } + function createNumberIndex(value, index) { + return createIndexType(1, value, index); + } + function createStringIndex(value, index) { + return createIndexType(0, value, index); + } + function createIndexType(kind, value, index) { + var indexType = { + kind: kind, + typeOfValue: value + }; + if (index) { + indexType.typeOfIndex = index; + } + return indexType; + } + function getInheritedIndexFrom(baseType) { + var resolved = resolveObjectOrUnionType(baseType); + var index = [ + resolved.stringIndex, + resolved.numberIndex + ]; + for (var i in index) { + if (index[i]) { + index[i].inherited = baseType.symbol; + } + } + return index; + } function resolveClassOrInterfaceMembers(type) { var members = type.symbol.members; var callSignatures = type.declaredCallSignatures; var constructSignatures = type.declaredConstructSignatures; - var stringIndexType = type.declaredStringIndexType; - var numberIndexType = type.declaredNumberIndexType; - if (type.baseTypes.length) { + var stringIndex = type.declaredStringIndex; + var numberIndex = type.declaredNumberIndex; + if (type.baseTypes && type.baseTypes.length) { members = createSymbolTable(type.declaredProperties); ts.forEach(type.baseTypes, function (baseType) { addInheritedMembers(members, getPropertiesOfObjectType(baseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1); + if (!stringIndex || !numberIndex) { + var index = getInheritedIndexFrom(baseType); + stringIndex = stringIndex || index[0]; + numberIndex = numberIndex || index[1]; + } }); } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function resolveTypeReferenceMembers(type) { var target = type.target; @@ -10515,17 +10604,20 @@ var ts; var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; + var stringIndex = target.declaredStringIndex ? instantiateIndexType(target.declaredStringIndex, mapper) : undefined; + var numberIndex = target.declaredNumberIndex ? instantiateIndexType(target.declaredNumberIndex, mapper) : undefined; ts.forEach(target.baseTypes, function (baseType) { var instantiatedBaseType = instantiateType(baseType, mapper); addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); + if (!stringIndex || !numberIndex) { + var index = getInheritedIndexFrom(instantiatedBaseType); + stringIndex = stringIndex || index[0]; + numberIndex = numberIndex || index[1]; + } }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -10568,7 +10660,7 @@ var ts; var arrayType = resolveObjectOrUnionTypeMembers(createArrayType(getUnionType(type.elementTypes))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); + setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndex, arrayType.numberIndex); } function signatureListsIdentical(s, t) { if (s.length !== t.length) { @@ -10607,7 +10699,7 @@ var ts; var indexTypes = []; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - var indexType = getIndexTypeOfType(type, kind); + var indexType = getIndexValueOfType(type, kind); if (!indexType) { return undefined; } @@ -10620,21 +10712,21 @@ var ts; var constructSignatures = getUnionSignatures(type.types, 1); var stringIndexType = getUnionIndexType(type.types, 0); var numberIndexType = getUnionIndexType(type.types, 1); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType ? createStringIndex(stringIndexType) : undefined, numberIndexType ? createNumberIndex(numberIndexType) : undefined); } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; var members; var callSignatures; var constructSignatures; - var stringIndexType; - var numberIndexType; + var stringIndex; + var numberIndex; if (symbol.flags & 2048) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); - stringIndexType = getIndexTypeOfSymbol(symbol, 0); - numberIndexType = getIndexTypeOfSymbol(symbol, 1); + stringIndex = getIndexTypeOfSymbol(symbol, 0); + numberIndex = getIndexTypeOfSymbol(symbol, 1); } else { members = emptySymbols; @@ -10657,10 +10749,10 @@ var ts; addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(classType.baseTypes[0].symbol))); } } - stringIndexType = undefined; - numberIndexType = (symbol.flags & 384) ? stringType : undefined; + stringIndex = undefined; + numberIndex = (symbol.flags & 384) ? createNumberIndex(stringType) : undefined; } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function resolveObjectOrUnionTypeMembers(type) { if (!type.members) { @@ -10725,10 +10817,20 @@ var ts; } } if (type.flags & 258) { - type = globalStringType; + if (type.flags & 2097152) { + type = globalStringSubsetType; + } + else { + type = globalStringType; + } } else if (type.flags & 132) { - type = globalNumberType; + if (type.flags & 2097152) { + type = globalNumberSubsetType; + } + else { + type = globalNumberType; + } } else if (type.flags & 8) { type = globalBooleanType; @@ -10826,15 +10928,35 @@ var ts; } return false; } - function getIndexTypeOfObjectOrUnionType(type, kind) { + function resolveObjectOrUnionType(type) { + if (type.flags & (48128 | 16384)) { + return resolveObjectOrUnionTypeMembers(type); + } + } + function getIndexOfObjectOrUnionType(type) { if (type.flags & (48128 | 16384)) { var resolved = resolveObjectOrUnionTypeMembers(type); - return kind === 0 ? resolved.stringIndexType : resolved.numberIndexType; + return [ + resolved.stringIndex, + resolved.numberIndex + ]; } } - function getIndexTypeOfType(type, kind) { + function getIndexTypeOfObjectOrUnionType(type, kind) { + var indexMap = getIndexOfObjectOrUnionType(type); + return indexMap ? indexMap[kind] : undefined; + } + function getIndexValueOfObjectOrUnionType(type, kind) { + var indexType = getIndexTypeOfObjectOrUnionType(type, kind); + return indexType ? indexType.typeOfValue : undefined; + } + function getIndexOfType(type, kind) { return getIndexTypeOfObjectOrUnionType(getApparentType(type), kind); } + function getIndexValueOfType(type, kind) { + var indexType = getIndexOfType(type, kind); + return indexType ? indexType.typeOfValue : undefined; + } function getTypeParametersFromDeclaration(typeParameterDeclarations) { var result = []; ts.forEach(typeParameterDeclarations, function (node) { @@ -11000,29 +11122,44 @@ var ts; function getIndexSymbol(symbol) { return symbol.members["__index"]; } - function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 119 : 121; + function getDeclaredIndexTypesOfSymbol(symbol) { + var indexMap = []; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { - var len = indexSymbol.declarations.length; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var node = decl; - if (node.parameters.length === 1) { - var parameter = node.parameters[0]; - if (parameter && parameter.type && parameter.type.kind === syntaxKind) { - return node; + if (decl.parameters.length === 1) { + var type = getTypeFromIndexSignatureParameter(decl.parameters[0]); + if (!type) { + continue; + } + var kind = (type.flags & 132) ? 1 : (type.flags & 2) ? 0 : null; + if (kind !== null) { + if (indexMap[kind]) { + indexMap[kind].declaredCount++; + } + else { + indexMap[kind] = { + kind: kind, + typeOfIndex: type, + typeOfValue: decl.type ? getTypeFromTypeNodeOrHeritageClauseElement(decl.type) : anyType, + declaredNode: decl, + declaredCount: 1 + }; + } } } } } - return undefined; + return indexMap; } function getIndexTypeOfSymbol(symbol, kind) { - var declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration - ? declaration.type ? getTypeFromTypeNodeOrHeritageClauseElement(declaration.type) : anyType - : undefined; + var indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + return indexTypes[kind]; + } + function getIndexValueOfSymbol(symbol, kind) { + var info = getIndexTypeOfSymbol(symbol, kind); + return info ? info.typeOfValue : undefined; } function getConstraintOfTypeParameter(type) { if (!type.constraint) { @@ -11499,14 +11636,17 @@ var ts; result.members = createSymbolTable(result.properties); result.callSignatures = instantiateList(getSignaturesOfType(type, 0), mapper, instantiateSignature); result.constructSignatures = instantiateList(getSignaturesOfType(type, 1), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + var stringIndex = getIndexOfType(type, 0); + var numberIndex = getIndexOfType(type, 1); + if (stringIndex) + result.stringIndex = instantiateIndexType(stringIndex, mapper); + if (numberIndex) + result.numberIndex = instantiateIndexType(numberIndex, mapper); return result; } + function instantiateIndexType(index, mapper) { + return createIndexType(index.kind, instantiateType(index.typeOfValue, mapper), index.typeOfIndex); + } function instantiateType(type, mapper) { if (mapper !== identityMapper) { if (type.flags & 512) { @@ -11687,6 +11827,8 @@ var ts; } } else { + if ((source.flags & 2097152) && (target.flags & 2097152)) { + } var saveErrorInfo = errorInfo; if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { @@ -11834,10 +11976,7 @@ var ts; if (result) { result &= signaturesRelatedTo(source, target, 1, reportErrors); if (result) { - result &= stringIndexTypesRelatedTo(source, target, reportErrors); - if (result) { - result &= numberIndexTypesRelatedTo(source, target, reportErrors); - } + result &= indexRelatedTo(source, target, reportErrors); } } } @@ -12061,71 +12200,82 @@ var ts; } return result; } - function stringIndexTypesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(0, source, target); - } - var targetType = getIndexTypeOfType(target, 0); - if (targetType) { - var sourceType = getIndexTypeOfType(source, 0); - if (!sourceType) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0; + function indexRelatedTo(source, target, reportErrors) { + var sourceIndex = getIndexOfObjectOrUnionType(source); + var targetIndex = getIndexOfObjectOrUnionType(target); + var sourceType = source; + var targetType = target; + return stringIndexRelatedTo(sourceIndex[0], targetIndex[0]) && + numberIndexRelatedTo(sourceIndex, targetIndex[1]); + function stringIndexRelatedTo(source, target) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(source, target, stringType); } - var related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); + if (target) { + if (!source) { + if (reportErrors) { + reportError(ts.Diagnostics.Missing_0_index_signature_in_type_1, "[string]", typeToString(sourceType)); + } + return 0; } - return 0; - } - return related; - } - return -1; - } - function numberIndexTypesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(1, source, target); - } - var targetType = getIndexTypeOfType(target, 1); - if (targetType) { - var sourceStringType = getIndexTypeOfType(source, 0); - var sourceNumberType = getIndexTypeOfType(source, 1); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + var related = indexTypesRelatedTo(source, target, stringType); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_0_and_1_are_incompatible, indexTypeToString(source), indexTypeToString(target)); + } + return 0; } - return 0; - } - var related; - if (sourceStringType && sourceNumberType) { - related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); + return related; } - else { - related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); + return -1; + } + function numberIndexRelatedTo(source, targetNumberIndex) { + var sourceNumberIndex = source[1]; + if (relation === identityRelation) { + return indexTypesIdenticalTo(sourceNumberIndex, targetNumberIndex, numberType); } - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); + if (targetNumberIndex) { + var sourceStringIndex = source[0]; + if (!sourceStringIndex && !sourceNumberIndex) { + if (reportErrors) { + reportError(ts.Diagnostics.Missing_0_index_signature_in_type_1, "[string] or [number]", typeToString(sourceType)); + } + return 0; } - return 0; + var related; + var sourceError = sourceNumberIndex; + if (sourceStringIndex && sourceNumberIndex) { + related = isRelatedTo(sourceStringIndex.typeOfValue, targetNumberIndex.typeOfValue, false) || indexTypesRelatedTo(sourceNumberIndex, targetNumberIndex, numberType); + } + else if (sourceStringIndex) { + related = isRelatedTo(sourceStringIndex.typeOfValue, targetNumberIndex.typeOfValue); + sourceError = sourceStringIndex; + } + else if (sourceNumberIndex) { + related = indexTypesRelatedTo(sourceNumberIndex, targetNumberIndex, numberType); + } + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_0_and_1_are_incompatible, indexTypeToString(sourceError), indexTypeToString(targetNumberIndex)); + } + return 0; + } + return related; } - return related; - } - return -1; - } - function indexTypesIdenticalTo(indexKind, source, target) { - var targetType = getIndexTypeOfType(target, indexKind); - var sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { return -1; } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); + function indexTypesRelatedTo(sourceIndex, targetIndex, defaultIndex) { + return isRelatedTo(sourceIndex.typeOfIndex || defaultIndex, targetIndex.typeOfIndex || defaultIndex, reportErrors) && isRelatedTo(sourceIndex.typeOfValue, targetIndex.typeOfValue, reportErrors); + } + function indexTypesIdenticalTo(sourceIndex, targetIndex, defaultIndex) { + if (!sourceIndex && !targetIndex) { + return -1; + } + if (sourceIndex && targetIndex) { + return indexTypesRelatedTo(sourceIndex, targetIndex, defaultIndex); + } + return 0; } - return 0; } } function isPropertyIdenticalTo(sourceProp, targetProp) { @@ -12261,13 +12411,13 @@ var ts; } members[p.name] = p; }); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + var stringIndex = getIndexOfType(type, 0); + var numberIndex = getIndexOfType(type, 1); + if (stringIndex) + stringIndex = createStringIndex(getWidenedType(stringIndex.typeOfValue)); + if (numberIndex) + numberIndex = createNumberIndex(getWidenedType(numberIndex.typeOfValue)); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndex, numberIndex); } function getWidenedType(type) { if (type.flags & 786432) { @@ -12519,9 +12669,9 @@ var ts; inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } function inferFromIndexTypes(source, target, sourceKind, targetKind) { - var targetIndexType = getIndexTypeOfType(target, targetKind); + var targetIndexType = getIndexValueOfType(target, targetKind); if (targetIndexType) { - var sourceIndexType = getIndexTypeOfType(source, sourceKind); + var sourceIndexType = getIndexValueOfType(source, sourceKind); if (sourceIndexType) { inferFromTypes(sourceIndexType, targetIndexType); } @@ -13150,13 +13300,13 @@ var ts; }); } function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }); + return applyToContextualType(type, function (t) { return getIndexValueOfObjectOrUnionType(t, kind); }); } function contextualTypeIsTupleLikeType(type) { return !!(type.flags & 16384 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }) : getIndexTypeOfObjectOrUnionType(type, kind)); + return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexValueOfObjectOrUnionType(t, kind); }) : getIndexValueOfObjectOrUnionType(type, kind)); } function getContextualTypeForObjectLiteralMethod(node) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); @@ -13400,7 +13550,7 @@ var ts; } var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType ? createStringIndex(stringIndexType) : undefined, numberIndexType ? createNumberIndex(numberIndexType) : undefined); result.flags |= 131072 | 524288 | (typeFlags & 262144); return result; function getIndexType(kind) { @@ -13552,12 +13702,12 @@ var ts; } if (allConstituentTypesHaveKind(indexType, 1 | 258 | 132 | 1048576)) { if (allConstituentTypesHaveKind(indexType, 1 | 132)) { - var numberIndexType = getIndexTypeOfType(objectType, 1); + var numberIndexType = getIndexValueOfType(objectType, 1); if (numberIndexType) { return numberIndexType; } } - var stringIndexType = getIndexTypeOfType(objectType, 0); + var stringIndexType = getIndexValueOfType(objectType, 0); if (stringIndexType) { return stringIndexType; } @@ -13718,7 +13868,7 @@ var ts; if (type.flags & 48128) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { + resolved.properties.length === 0 && !resolved.stringIndex && !resolved.numberIndex) { return resolved.callSignatures[0]; } } @@ -14170,7 +14320,7 @@ var ts; } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); - var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); if (!hasGrammarError && node.kind === 162) { checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); } @@ -14207,7 +14357,7 @@ var ts; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); - if (node.type) { + if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type)); } if (node.body) { @@ -14399,8 +14549,8 @@ var ts; var name_8 = p.name; var type = sourceType.flags & 1 ? sourceType : getTypeOfPropertyOfType(sourceType, name_8.text) || - isNumericLiteralName(name_8.text) && getIndexTypeOfType(sourceType, 1) || - getIndexTypeOfType(sourceType, 0); + isNumericLiteralName(name_8.text) && getIndexValueOfType(sourceType, 1) || + getIndexValueOfType(sourceType, 0); if (type) { checkDestructuringAssignment(p.initializer || name_8, type); } @@ -14678,6 +14828,7 @@ var ts; return type; } function checkExpression(node, contextualMapper) { + checkGrammarIdentifierInStrictMode(node); return checkExpressionOrQualifiedName(node, contextualMapper); } function checkExpressionOrQualifiedName(node, contextualMapper) { @@ -14772,6 +14923,7 @@ var ts; return unknownType; } function checkTypeParameter(node) { + checkGrammarDeclarationNameInStrictMode(node); if (node.expression) { grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } @@ -14842,32 +14994,29 @@ var ts; return; } } - var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { - var seenNumericIndexer = false; - var seenStringIndexer = false; + var symbol = getSymbolOfNode(node); + var indexMap = getDeclaredIndexTypesOfSymbol(symbol); + var stringIndex = indexMap[0]; + var numberIndex = indexMap[1]; + if (stringIndex && stringIndex.declaredCount > 1) { + errorDuplicateIndex(getIndexSymbol(symbol), stringIndex); + } + if (numberIndex && numberIndex.declaredCount > 1) { + errorDuplicateIndex(getIndexSymbol(symbol), numberIndex); + } + function errorDuplicateIndex(indexSymbol, indexType) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var declaration = decl; - if (declaration.parameters.length === 1 && declaration.parameters[0].type) { - switch (declaration.parameters[0].type.kind) { - case 121: - if (!seenStringIndexer) { - seenStringIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_string_index_signature); - } - break; - case 119: - if (!seenNumericIndexer) { - seenNumericIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_number_index_signature); - } - break; - } + if (declaration.parameters.length !== 1 || declaration === indexType.declaredNode) { + continue; + } + var type = getTypeFromIndexSignatureParameter(declaration.parameters[0]); + if (type.flags & 2 && indexType.kind === 0) { + error(declaration, ts.Diagnostics.Duplicate_string_index_signature); + } + else if (type.flags & 132 && indexType.kind === 1) { + error(declaration, ts.Diagnostics.Duplicate_number_index_signature); } } } @@ -14974,9 +15123,11 @@ var ts; checkDecorators(node); } function checkTypeReferenceNode(node) { + checkGrammarTypeReferenceInStrictMode(node.typeName); return checkTypeReferenceOrHeritageClauseElement(node); } function checkHeritageClauseElement(node) { + checkGrammarHeritageClauseElementInStrictMode(node.expression); return checkTypeReferenceOrHeritageClauseElement(node); } function checkTypeReferenceOrHeritageClauseElement(node) { @@ -15379,6 +15530,7 @@ var ts; } } function checkFunctionLikeDeclaration(node) { + checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); if (node.name && node.name.kind === 127) { @@ -15398,7 +15550,7 @@ var ts; } } checkSourceElement(node.body); - if (node.type && !isAccessor(node.kind)) { + if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type)); } if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !node.type && !isPrivateWithinAmbient(node)) { @@ -15564,6 +15716,7 @@ var ts; } } function checkVariableLikeDeclaration(node) { + checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); if (node.name.kind === 127) { @@ -15748,7 +15901,7 @@ var ts; return checkElementTypeOfArrayOrString(inputType, errorNode); } if (isArrayLikeType(inputType)) { - return getIndexTypeOfType(inputType, 1); + return getIndexValueOfType(inputType, 1); } error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); return unknownType; @@ -15855,7 +16008,7 @@ var ts; } return hasStringConstituent ? stringType : unknownType; } - var arrayElementType = getIndexTypeOfType(arrayType, 1) || unknownType; + var arrayElementType = getIndexValueOfType(arrayType, 1) || unknownType; if (hasStringConstituent) { if (arrayElementType.flags & 258) { return stringType; @@ -15996,62 +16149,77 @@ var ts; } } function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType || numberIndexType) { - ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); - checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); - checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); - }); - if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 201) { - var classDeclaration = type.symbol.valueDeclaration; - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (!(member.flags & 128) && ts.hasDynamicName(member)) { - var propType = getTypeOfSymbol(member.symbol); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); - } - } - } + var resolved = resolveObjectOrUnionType(type); + if (!resolved) { + return; } - var errorNode; - if (stringIndexType && numberIndexType) { - errorNode = declaredNumberIndexer || declaredStringIndexer; - if (!errorNode && (type.flags & 2048)) { - var someBaseTypeHasBothIndexers = ts.forEach(type.baseTypes, function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + var stringIndex = resolved.stringIndex || createStringIndex(null); + var numberIndex = resolved.numberIndex || createNumberIndex(null); + var alphaNumeric = resolved.alphaNumericIndex; + if (!stringIndex.typeOfValue && !numberIndex.typeOfValue) { + return; + } + var containingNode = type.symbol.declarations[type.symbol.declarations.length - 1]; + var errorNode = containingNode; + var checkIndexNodes = [numberIndex.declaredNode, stringIndex.declaredNode]; + for (var _i = 0; _i < checkIndexNodes.length; _i++) { + var node = checkIndexNodes[_i]; + if (node && node.parent === containingNode) { + errorNode = node; + break; } } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { - error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); + var checkNumberIndex = numberIndex; + if (alphaNumeric === ts.IndexAlphaNumeric.YES && !isTypeAssignableTo(numberIndex.typeOfValue, stringIndex.typeOfValue)) { + error(errorNode, ts.Diagnostics.Numeric_index_0_is_not_assignable_to_string_index_1, indexTypeToString(numberIndex), indexTypeToString(stringIndex)); + checkNumberIndex = null; } - function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { - if (!indexType) { + ts.forEach(getPropertiesOfObjectType(type), function (prop) { + var propType = getTypeOfSymbol(prop); + checkIndexConstraintForProperty(prop, propType, type, stringIndex, alphaNumeric); + if (checkNumberIndex) { + checkIndexConstraintForProperty(prop, propType, type, numberIndex, alphaNumeric); + } + }); + if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 201) { + var classDeclaration = type.symbol.valueDeclaration; + for (var _a = 0, _b = classDeclaration.members; _a < _b.length; _a++) { + var member = _b[_a]; + if (!(member.flags & 128) && ts.hasDynamicName(member)) { + var propType = getTypeOfSymbol(member.symbol); + checkIndexConstraintForProperty(member.symbol, propType, type, stringIndex, alphaNumeric); + if (checkNumberIndex) { + checkIndexConstraintForProperty(member.symbol, propType, type, numberIndex, alphaNumeric); + } + } + } + } + function checkIndexConstraintForProperty(prop, propertyType, containingType, indexType, alphaNumeric) { + if (!indexType.typeOfValue) { return; } - if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { + if (indexType.kind === 1 && !isNumericName(prop.valueDeclaration.name)) { return; } var errorNode; if (prop.valueDeclaration.name.kind === 127 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } - else if (indexDeclaration) { - errorNode = indexDeclaration; - } - else if (containingType.flags & 2048) { - var someBaseClassHasBothPropertyAndIndexer = ts.forEach(containingType.baseTypes, function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + else if (indexType.declaredNode) { + errorNode = indexType.declaredNode; + var containingNode_1 = containingType.symbol.declarations[containingType.symbol.declarations.length - 1]; + if (errorNode.parent !== containingNode_1) { + errorNode = containingNode_1; + } + if (alphaNumeric === ts.IndexAlphaNumeric.INHERITED) { + errorNode = undefined; + } } - if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { - var errorMessage = indexKind === 0 - ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 - : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); + if (errorNode && !isTypeAssignableTo(propertyType, indexType.typeOfValue)) { + var errorMessage = indexType.kind === 0 + ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_2 + : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_2; + error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), indexTypeToString(indexType)); } } } @@ -16087,6 +16255,7 @@ var ts; return unknownType; } function checkClassDeclaration(node) { + checkGrammarDeclarationNameInStrictMode(node); if (node.parent.kind !== 206 && node.parent.kind !== 227) { grammarErrorOnNode(node, ts.Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration); } @@ -16275,7 +16444,7 @@ var ts; return ok; } function checkInterfaceDeclaration(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); @@ -16461,7 +16630,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -16514,7 +16683,7 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -16603,7 +16772,7 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -16624,7 +16793,7 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1) { @@ -16925,6 +17094,8 @@ var ts; if (!(links.flags & 1)) { checkGrammarSourceFile(node); emitExtends = false; + emitDecorate = false; + emitParam = false; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); checkFunctionExpressionBodies(node); @@ -17711,7 +17882,9 @@ var ts; globalObjectType = getGlobalType("Object"); globalFunctionType = getGlobalType("Function"); globalStringType = getGlobalType("String"); + globalStringSubsetType = cloneInterfaceType(globalStringType, 2097152); globalNumberType = getGlobalType("Number"); + globalNumberSubsetType = cloneInterfaceType(globalNumberType, 2097152); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); @@ -17732,6 +17905,105 @@ var ts; } anyArrayType = createArrayType(anyType); } + function isReservedwordInStrictMode(node) { + return (node.parserContextFlags & 1) && + (node.originalKeywordKind >= 103 && node.originalKeywordKind <= 111); + } + function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { + if (ts.getAncestor(identifier, 201) || ts.getAncestor(identifier, 174)) { + return grammarErrorOnNode(identifier, message, arg0); + } + return false; + } + function checkGrammarImportDeclarationNameInStrictMode(node) { + if (node.importClause) { + var impotClause = node.importClause; + if (impotClause.namedBindings) { + var nameBindings = impotClause.namedBindings; + if (nameBindings.kind === 211) { + var name_11 = nameBindings.name; + if (name_11.originalKeywordKind) { + var nameText = ts.declarationNameToString(name_11); + return grammarErrorOnNode(name_11, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + } + } + else if (nameBindings.kind === 212) { + var reportError = false; + for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { + var element = _a[_i]; + var name_12 = element.name; + if (name_12.originalKeywordKind) { + var nameText = ts.declarationNameToString(name_12); + reportError = reportError || grammarErrorOnNode(name_12, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + } + } + return reportError; + } + } + } + return false; + } + function checkGrammarDeclarationNameInStrictMode(node) { + var name = node.name; + if (name && name.kind === 65 && isReservedwordInStrictMode(name)) { + var nameText = ts.declarationNameToString(name); + switch (node.kind) { + case 129: + case 198: + case 200: + case 128: + case 152: + case 202: + case 203: + case 204: + return checkGrammarIdentifierInStrictMode(name); + case 201: + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); + case 205: + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + case 208: + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + } + } + return false; + } + function checkGrammarTypeReferenceInStrictMode(typeName) { + if (typeName.kind === 65) { + checkGrammarTypeNameInStrictMode(typeName); + } + else if (typeName.kind === 126) { + checkGrammarTypeNameInStrictMode(typeName.right); + checkGrammarTypeReferenceInStrictMode(typeName.left); + } + } + function checkGrammarHeritageClauseElementInStrictMode(expression) { + if (expression && expression.kind === 65) { + return checkGrammarIdentifierInStrictMode(expression); + } + else if (expression && expression.kind === 155) { + checkGrammarHeritageClauseElementInStrictMode(expression.expression); + } + } + function checkGrammarIdentifierInStrictMode(node, nameText) { + if (node && node.kind === 65 && isReservedwordInStrictMode(node)) { + if (!nameText) { + nameText = ts.declarationNameToString(node); + } + var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || + grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + return errorReport; + } + return false; + } + function checkGrammarTypeNameInStrictMode(node) { + if (node && node.kind === 65 && isReservedwordInStrictMode(node)) { + var nameText = ts.declarationNameToString(node); + var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || + grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText); + return errorReport; + } + return false; + } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -17943,6 +18215,23 @@ var ts; } return false; } + function getTypeFromIndexSignatureParameter(parameter) { + if (parameter.type) { + if (parameter.type.kind === 121) { + return stringType; + } + if (parameter.type.kind === 119) { + return numberType; + } + if (parameter.type.kind === 141) { + var type = getTypeFromTypeReference((parameter.type)); + if ((type.flags & 132) || (type.flags & 2)) { + return type; + } + } + } + return undefined; + } function checkGrammarIndexSignatureParameters(node) { var parameter = node.parameters[0]; if (node.parameters.length !== 1) { @@ -17968,8 +18257,8 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 121 && parameter.type.kind !== 119) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + if (!getTypeFromIndexSignatureParameter(parameter)) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_number_or_an_enum_type); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); @@ -18101,17 +18390,17 @@ var ts; var inStrictMode = (node.parserContextFlags & 1) !== 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_11 = prop.name; + var name_13 = prop.name; if (prop.kind === 175 || - name_11.kind === 127) { - checkGrammarComputedPropertyName(name_11); + name_13.kind === 127) { + checkGrammarComputedPropertyName(name_13); continue; } var currentKind = void 0; if (prop.kind === 224 || prop.kind === 225) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_11.kind === 7) { - checkGrammarNumbericLiteral(name_11); + if (name_13.kind === 7) { + checkGrammarNumbericLiteral(name_13); } currentKind = Property; } @@ -18127,26 +18416,26 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_11.text)) { - seen[name_11.text] = currentKind; + if (!ts.hasProperty(seen, name_13.text)) { + seen[name_13.text] = currentKind; } else { - var existingKind = seen[name_11.text]; + var existingKind = seen[name_13.text]; if (currentKind === Property && existingKind === Property) { if (inStrictMode) { - grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); + grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); } } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_11.text] = currentKind | existingKind; + seen[name_13.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -18465,12 +18754,11 @@ var ts; var identifier = name; if (contextNode && (contextNode.parserContextFlags & 1) && ts.isEvalOrArgumentsIdentifier(identifier)) { var nameText = ts.declarationNameToString(identifier); - if (ts.getAncestor(name, 201) || ts.getAncestor(name, 174)) { - return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); - } - else { + var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); + if (!reportErrorInClassDeclaration) { return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); } + return reportErrorInClassDeclaration; } } } @@ -18919,9 +19207,9 @@ var ts; } var count = 0; while (true) { - var name_12 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_12)) { - return name_12; + var name_14 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_14)) { + return name_14; } } } @@ -20003,9 +20291,9 @@ var ts; var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_13 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_13)) { - return name_13; + var name_15 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_15)) { + return name_15; } } } @@ -20033,8 +20321,8 @@ var ts; } function generateNameForModuleOrEnum(node) { if (node.name.kind === 65) { - var name_14 = node.name.text; - assignGeneratedName(node, isUniqueLocalName(name_14, node) ? name_14 : makeUniqueName(name_14)); + var name_16 = node.name.text; + assignGeneratedName(node, isUniqueLocalName(name_16, node) ? name_16 : makeUniqueName(name_16)); } } function generateNameForImportOrExportDeclaration(node) { @@ -20214,8 +20502,8 @@ var ts; if (scopeName) { var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { - var name_15 = node.name; - if (!name_15 || name_15.kind !== 127) { + var name_17 = node.name; + if (!name_17 || name_17.kind !== 127) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -20242,9 +20530,9 @@ var ts; node.kind === 201 || node.kind === 204) { if (node.name) { - var name_16 = node.name; - scopeName = name_16.kind === 127 - ? ts.getTextOfNode(name_16) + var name_18 = node.name; + scopeName = name_18.kind === 127 + ? ts.getTextOfNode(name_18) : node.name.text; } recordScopeNameStart(scopeName); @@ -20657,6 +20945,7 @@ var ts; default: return -1; } + case 172: case 170: return -1; default: @@ -20828,6 +21117,16 @@ var ts; write("..."); emit(node.expression); } + function emitYieldExpression(node) { + write(ts.tokenToString(111)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65: @@ -21069,6 +21368,9 @@ var ts; write("]"); } function emitMethod(node) { + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } emit(node.name, false); if (languageVersion < 2) { write(": function "); @@ -22054,12 +22356,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var name_17 = createTempVariable(0); + var name_19 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_17); - emit(name_17); + tempParameters.push(name_19); + emit(name_19); } else { emit(node.name); @@ -22178,7 +22480,11 @@ var ts; write("default "); } } - write("function "); + write("function"); + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + write(" "); } if (shouldEmitFunctionName(node)) { emitDeclarationName(node); @@ -22510,6 +22816,9 @@ var ts; else if (member.kind === 137) { write("set "); } + if (member.asteriskToken) { + write("*"); + } emit(member.name); emitSignatureAndBody(member); emitEnd(member); @@ -23475,8 +23784,8 @@ var ts; else { for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_18 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_18] || (exportSpecifiers[name_18] = [])).push(specifier); + var name_20 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_20] || (exportSpecifiers[name_20] = [])).push(specifier); } } break; @@ -23787,6 +24096,8 @@ var ts; return emitConditionalExpression(node); case 173: return emitSpreadElementExpression(node); + case 172: + return emitYieldExpression(node); case 175: return; case 179: diff --git a/bin/tsserver.js b/bin/tsserver.js index ba3c349c046d9..121bbfc32e967 100644 --- a/bin/tsserver.js +++ b/bin/tsserver.js @@ -21,6 +21,12 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ts.ExitStatus || (ts.ExitStatus = {})); var ExitStatus = ts.ExitStatus; + (function (IndexAlphaNumeric) { + IndexAlphaNumeric[IndexAlphaNumeric["NO"] = 0] = "NO"; + IndexAlphaNumeric[IndexAlphaNumeric["YES"] = 1] = "YES"; + IndexAlphaNumeric[IndexAlphaNumeric["INHERITED"] = 2] = "INHERITED"; + })(ts.IndexAlphaNumeric || (ts.IndexAlphaNumeric = {})); + var IndexAlphaNumeric = ts.IndexAlphaNumeric; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; @@ -926,7 +932,7 @@ var ts; An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, + An_index_signature_parameter_type_must_be_string_number_or_an_enum_type: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string', 'number', or an enum type." }, A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: ts.DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: ts.DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, A_class_can_only_extend_a_single_class: { code: 1026, category: ts.DiagnosticCategory.Error, key: "A class can only extend a single class." }, @@ -1076,6 +1082,12 @@ var ts; Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." }, + Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, + Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -1104,8 +1116,8 @@ var ts; Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible." }, Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, + Missing_0_index_signature_in_type_1: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Missing {0} index signature in type '{1}'." }, + Index_signatures_0_and_1_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures '{0}' and '{1}' are incompatible." }, this_cannot_be_referenced_in_a_module_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module body." }, this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, @@ -1180,9 +1192,9 @@ var ts; Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" }, All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, + Property_0_of_type_1_is_not_assignable_to_string_index_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index '{2}'." }, + Property_0_of_type_1_is_not_assignable_to_numeric_index_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index '{2}'." }, + Numeric_index_0_is_not_assignable_to_string_index_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index '{0}' is not assignable to string index '{1}'." }, Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class name cannot be '{0}'" }, Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly extends base class '{1}'." }, Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, @@ -5326,7 +5338,7 @@ var ts; if (token === 111 && inYieldContext()) { return false; } - return inStrictModeContext() ? token > 111 : token > 101; + return token > 101; } function parseExpected(kind, diagnosticMessage) { if (token === kind) { @@ -5420,6 +5432,9 @@ var ts; identifierCount++; if (isIdentifier) { var node = createNode(65); + if (token !== 65) { + node.originalKeywordKind = token; + } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); @@ -7550,6 +7565,17 @@ var ts; node.body = parseFunctionBlockOrSemicolon(false); return finishNode(node); } + function isClassMemberModifier(idToken) { + switch (idToken) { + case 109: + case 107: + case 108: + case 110: + return true; + default: + return false; + } + } function isClassMemberStart() { var idToken; if (token === 52) { @@ -7557,6 +7583,9 @@ var ts; } while (ts.isModifier(token)) { idToken = token; + if (isClassMemberModifier(idToken)) { + return true; + } nextToken(); } if (token === 35) { @@ -8729,7 +8758,7 @@ var ts; getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: getIndexTypeOfType, + getIndexTypeOfType: getIndexValueOfType, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, @@ -8775,7 +8804,9 @@ var ts; var globalFunctionType; var globalArrayType; var globalStringType; + var globalStringSubsetType; var globalNumberType; + var globalNumberSubsetType; var globalBooleanType; var globalRegExpType; var globalTemplateStringsArrayType; @@ -9513,6 +9544,19 @@ var ts; type.symbol = symbol; return type; } + function cloneInterfaceType(type, flags) { + var cloneType = createType(type.flags); + cloneType.symbol = type.symbol; + cloneType.flags |= flags; + cloneType.baseTypes = type.baseTypes; + cloneType.declaredCallSignatures = type.declaredCallSignatures; + cloneType.declaredConstructSignatures = type.declaredCallSignatures; + cloneType.declaredNumberIndex = type.declaredNumberIndex; + cloneType.declaredStringIndex = type.declaredStringIndex; + cloneType.declaredProperties = type.declaredProperties; + cloneType.typeParameters = type.typeParameters; + return cloneType; + } function isReservedMemberName(name) { return name.charCodeAt(0) === 95 && name.charCodeAt(1) === 95 && @@ -9535,19 +9579,27 @@ var ts; } return result || emptyArray; } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex) { type.members = members; type.properties = getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexType) - type.stringIndexType = stringIndexType; - if (numberIndexType) - type.numberIndexType = numberIndexType; + if (stringIndex) + type.stringIndex = stringIndex; + if (numberIndex) + type.numberIndex = numberIndex; + if (stringIndex && numberIndex) { + if (numberIndex.inherited && (numberIndex.inherited === stringIndex.inherited)) { + type.alphaNumericIndex = ts.IndexAlphaNumeric.INHERITED; + } + else { + type.alphaNumericIndex = ts.IndexAlphaNumeric.YES; + } + } return type; } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(32768, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndex, numberIndex) { + return setObjectTypeMembers(createObjectType(32768, symbol), members, callSignatures, constructSignatures, stringIndex, numberIndex); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -9761,6 +9813,10 @@ var ts; } return result; } + function indexTypeToString(type) { + var index = type.typeOfIndex || ((type.kind === 0) ? stringType : numberType); + return '[' + typeToString(index) + ']: ' + typeToString(type.typeOfValue); + } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; @@ -9954,7 +10010,8 @@ var ts; buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } function getIndexerParameterName(type, indexKind, fallbackName) { - var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + var indexMap = getDeclaredIndexTypesOfSymbol(type.symbol); + var declaration = indexMap[indexKind] ? indexMap[indexKind].declaredNode : null; if (!declaration) { return fallbackName; } @@ -9963,7 +10020,7 @@ var ts; } function writeLiteralType(type, flags) { var resolved = resolveObjectOrUnionTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.properties.length && !resolved.stringIndex && !resolved.numberIndex) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, 14); writePunctuation(writer, 15); @@ -10009,32 +10066,30 @@ var ts; writePunctuation(writer, 22); writer.writeLine(); } - if (resolved.stringIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 51); - writeSpace(writer); - writeKeyword(writer, 121); - writePunctuation(writer, 19); - writePunctuation(writer, 51); - writeSpace(writer); - writeType(resolved.stringIndexType, 0); - writePunctuation(writer, 22); - writer.writeLine(); - } - if (resolved.numberIndexType) { + function writeIndexType(indexType) { + if (!indexType) { + return; + } writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); + writer.writeParameter(getIndexerParameterName(resolved, indexType.kind, "x")); writePunctuation(writer, 51); writeSpace(writer); - writeKeyword(writer, 119); + if (indexType.typeOfIndex && (indexType.typeOfIndex.flags & 2097152)) { + writeType(indexType.typeOfIndex, 0); + writer.writeStringLiteral(indexType.kind === 0 ? " < string" : " < number"); + } + else { + writeKeyword(writer, indexType.kind === 0 ? 121 : 119); + } writePunctuation(writer, 19); writePunctuation(writer, 51); writeSpace(writer); - writeType(resolved.numberIndexType, 0); + writeType(indexType.typeOfValue, 0); writePunctuation(writer, 22); writer.writeLine(); } + writeIndexType(resolved.stringIndex); + writeIndexType(resolved.numberIndex); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -10347,8 +10402,8 @@ var ts; if (pattern.kind === 150) { var name_5 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_5.text) || - isNumericLiteralName(name_5.text) && getIndexTypeOfType(parentType, 1) || - getIndexTypeOfType(parentType, 0); + isNumericLiteralName(name_5.text) && getIndexValueOfType(parentType, 1) || + getIndexValueOfType(parentType, 0); if (!type) { error(name_5, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_5)); return unknownType; @@ -10688,8 +10743,9 @@ var ts; type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = emptyArray; type.declaredConstructSignatures = emptyArray; - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); + var indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + type.declaredStringIndex = indexTypes[0]; + type.declaredNumberIndex = indexTypes[1]; } return links.declaredType; } @@ -10730,8 +10786,9 @@ var ts; type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); + var indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + type.declaredStringIndex = indexTypes[0]; + type.declaredNumberIndex = indexTypes[1]; } return links.declaredType; } @@ -10755,7 +10812,7 @@ var ts; function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(128); + var type = createType(128 | 2097152); type.symbol = symbol; links.declaredType = type; } @@ -10834,23 +10891,55 @@ var ts; } } } + function createNumberIndex(value, index) { + return createIndexType(1, value, index); + } + function createStringIndex(value, index) { + return createIndexType(0, value, index); + } + function createIndexType(kind, value, index) { + var indexType = { + kind: kind, + typeOfValue: value + }; + if (index) { + indexType.typeOfIndex = index; + } + return indexType; + } + function getInheritedIndexFrom(baseType) { + var resolved = resolveObjectOrUnionType(baseType); + var index = [ + resolved.stringIndex, + resolved.numberIndex + ]; + for (var i in index) { + if (index[i]) { + index[i].inherited = baseType.symbol; + } + } + return index; + } function resolveClassOrInterfaceMembers(type) { var members = type.symbol.members; var callSignatures = type.declaredCallSignatures; var constructSignatures = type.declaredConstructSignatures; - var stringIndexType = type.declaredStringIndexType; - var numberIndexType = type.declaredNumberIndexType; - if (type.baseTypes.length) { + var stringIndex = type.declaredStringIndex; + var numberIndex = type.declaredNumberIndex; + if (type.baseTypes && type.baseTypes.length) { members = createSymbolTable(type.declaredProperties); ts.forEach(type.baseTypes, function (baseType) { addInheritedMembers(members, getPropertiesOfObjectType(baseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1); + if (!stringIndex || !numberIndex) { + var index = getInheritedIndexFrom(baseType); + stringIndex = stringIndex || index[0]; + numberIndex = numberIndex || index[1]; + } }); } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function resolveTypeReferenceMembers(type) { var target = type.target; @@ -10858,17 +10947,20 @@ var ts; var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; + var stringIndex = target.declaredStringIndex ? instantiateIndexType(target.declaredStringIndex, mapper) : undefined; + var numberIndex = target.declaredNumberIndex ? instantiateIndexType(target.declaredNumberIndex, mapper) : undefined; ts.forEach(target.baseTypes, function (baseType) { var instantiatedBaseType = instantiateType(baseType, mapper); addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); + if (!stringIndex || !numberIndex) { + var index = getInheritedIndexFrom(instantiatedBaseType); + stringIndex = stringIndex || index[0]; + numberIndex = numberIndex || index[1]; + } }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -10911,7 +11003,7 @@ var ts; var arrayType = resolveObjectOrUnionTypeMembers(createArrayType(getUnionType(type.elementTypes))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); + setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndex, arrayType.numberIndex); } function signatureListsIdentical(s, t) { if (s.length !== t.length) { @@ -10950,7 +11042,7 @@ var ts; var indexTypes = []; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - var indexType = getIndexTypeOfType(type, kind); + var indexType = getIndexValueOfType(type, kind); if (!indexType) { return undefined; } @@ -10963,21 +11055,21 @@ var ts; var constructSignatures = getUnionSignatures(type.types, 1); var stringIndexType = getUnionIndexType(type.types, 0); var numberIndexType = getUnionIndexType(type.types, 1); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType ? createStringIndex(stringIndexType) : undefined, numberIndexType ? createNumberIndex(numberIndexType) : undefined); } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; var members; var callSignatures; var constructSignatures; - var stringIndexType; - var numberIndexType; + var stringIndex; + var numberIndex; if (symbol.flags & 2048) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); - stringIndexType = getIndexTypeOfSymbol(symbol, 0); - numberIndexType = getIndexTypeOfSymbol(symbol, 1); + stringIndex = getIndexTypeOfSymbol(symbol, 0); + numberIndex = getIndexTypeOfSymbol(symbol, 1); } else { members = emptySymbols; @@ -11000,10 +11092,10 @@ var ts; addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(classType.baseTypes[0].symbol))); } } - stringIndexType = undefined; - numberIndexType = (symbol.flags & 384) ? stringType : undefined; + stringIndex = undefined; + numberIndex = (symbol.flags & 384) ? createNumberIndex(stringType) : undefined; } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function resolveObjectOrUnionTypeMembers(type) { if (!type.members) { @@ -11068,10 +11160,20 @@ var ts; } } if (type.flags & 258) { - type = globalStringType; + if (type.flags & 2097152) { + type = globalStringSubsetType; + } + else { + type = globalStringType; + } } else if (type.flags & 132) { - type = globalNumberType; + if (type.flags & 2097152) { + type = globalNumberSubsetType; + } + else { + type = globalNumberType; + } } else if (type.flags & 8) { type = globalBooleanType; @@ -11169,15 +11271,35 @@ var ts; } return false; } - function getIndexTypeOfObjectOrUnionType(type, kind) { + function resolveObjectOrUnionType(type) { + if (type.flags & (48128 | 16384)) { + return resolveObjectOrUnionTypeMembers(type); + } + } + function getIndexOfObjectOrUnionType(type) { if (type.flags & (48128 | 16384)) { var resolved = resolveObjectOrUnionTypeMembers(type); - return kind === 0 ? resolved.stringIndexType : resolved.numberIndexType; + return [ + resolved.stringIndex, + resolved.numberIndex + ]; } } - function getIndexTypeOfType(type, kind) { + function getIndexTypeOfObjectOrUnionType(type, kind) { + var indexMap = getIndexOfObjectOrUnionType(type); + return indexMap ? indexMap[kind] : undefined; + } + function getIndexValueOfObjectOrUnionType(type, kind) { + var indexType = getIndexTypeOfObjectOrUnionType(type, kind); + return indexType ? indexType.typeOfValue : undefined; + } + function getIndexOfType(type, kind) { return getIndexTypeOfObjectOrUnionType(getApparentType(type), kind); } + function getIndexValueOfType(type, kind) { + var indexType = getIndexOfType(type, kind); + return indexType ? indexType.typeOfValue : undefined; + } function getTypeParametersFromDeclaration(typeParameterDeclarations) { var result = []; ts.forEach(typeParameterDeclarations, function (node) { @@ -11343,29 +11465,44 @@ var ts; function getIndexSymbol(symbol) { return symbol.members["__index"]; } - function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 119 : 121; + function getDeclaredIndexTypesOfSymbol(symbol) { + var indexMap = []; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { - var len = indexSymbol.declarations.length; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var node = decl; - if (node.parameters.length === 1) { - var parameter = node.parameters[0]; - if (parameter && parameter.type && parameter.type.kind === syntaxKind) { - return node; + if (decl.parameters.length === 1) { + var type = getTypeFromIndexSignatureParameter(decl.parameters[0]); + if (!type) { + continue; + } + var kind = (type.flags & 132) ? 1 : (type.flags & 2) ? 0 : null; + if (kind !== null) { + if (indexMap[kind]) { + indexMap[kind].declaredCount++; + } + else { + indexMap[kind] = { + kind: kind, + typeOfIndex: type, + typeOfValue: decl.type ? getTypeFromTypeNodeOrHeritageClauseElement(decl.type) : anyType, + declaredNode: decl, + declaredCount: 1 + }; + } } } } } - return undefined; + return indexMap; } function getIndexTypeOfSymbol(symbol, kind) { - var declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration - ? declaration.type ? getTypeFromTypeNodeOrHeritageClauseElement(declaration.type) : anyType - : undefined; + var indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + return indexTypes[kind]; + } + function getIndexValueOfSymbol(symbol, kind) { + var info = getIndexTypeOfSymbol(symbol, kind); + return info ? info.typeOfValue : undefined; } function getConstraintOfTypeParameter(type) { if (!type.constraint) { @@ -11842,14 +11979,17 @@ var ts; result.members = createSymbolTable(result.properties); result.callSignatures = instantiateList(getSignaturesOfType(type, 0), mapper, instantiateSignature); result.constructSignatures = instantiateList(getSignaturesOfType(type, 1), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + var stringIndex = getIndexOfType(type, 0); + var numberIndex = getIndexOfType(type, 1); + if (stringIndex) + result.stringIndex = instantiateIndexType(stringIndex, mapper); + if (numberIndex) + result.numberIndex = instantiateIndexType(numberIndex, mapper); return result; } + function instantiateIndexType(index, mapper) { + return createIndexType(index.kind, instantiateType(index.typeOfValue, mapper), index.typeOfIndex); + } function instantiateType(type, mapper) { if (mapper !== identityMapper) { if (type.flags & 512) { @@ -12030,6 +12170,8 @@ var ts; } } else { + if ((source.flags & 2097152) && (target.flags & 2097152)) { + } var saveErrorInfo = errorInfo; if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { @@ -12177,10 +12319,7 @@ var ts; if (result) { result &= signaturesRelatedTo(source, target, 1, reportErrors); if (result) { - result &= stringIndexTypesRelatedTo(source, target, reportErrors); - if (result) { - result &= numberIndexTypesRelatedTo(source, target, reportErrors); - } + result &= indexRelatedTo(source, target, reportErrors); } } } @@ -12404,71 +12543,82 @@ var ts; } return result; } - function stringIndexTypesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(0, source, target); - } - var targetType = getIndexTypeOfType(target, 0); - if (targetType) { - var sourceType = getIndexTypeOfType(source, 0); - if (!sourceType) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0; + function indexRelatedTo(source, target, reportErrors) { + var sourceIndex = getIndexOfObjectOrUnionType(source); + var targetIndex = getIndexOfObjectOrUnionType(target); + var sourceType = source; + var targetType = target; + return stringIndexRelatedTo(sourceIndex[0], targetIndex[0]) && + numberIndexRelatedTo(sourceIndex, targetIndex[1]); + function stringIndexRelatedTo(source, target) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(source, target, stringType); } - var related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); + if (target) { + if (!source) { + if (reportErrors) { + reportError(ts.Diagnostics.Missing_0_index_signature_in_type_1, "[string]", typeToString(sourceType)); + } + return 0; } - return 0; - } - return related; - } - return -1; - } - function numberIndexTypesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(1, source, target); - } - var targetType = getIndexTypeOfType(target, 1); - if (targetType) { - var sourceStringType = getIndexTypeOfType(source, 0); - var sourceNumberType = getIndexTypeOfType(source, 1); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + var related = indexTypesRelatedTo(source, target, stringType); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_0_and_1_are_incompatible, indexTypeToString(source), indexTypeToString(target)); + } + return 0; } - return 0; - } - var related; - if (sourceStringType && sourceNumberType) { - related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); + return related; } - else { - related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); + return -1; + } + function numberIndexRelatedTo(source, targetNumberIndex) { + var sourceNumberIndex = source[1]; + if (relation === identityRelation) { + return indexTypesIdenticalTo(sourceNumberIndex, targetNumberIndex, numberType); } - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); + if (targetNumberIndex) { + var sourceStringIndex = source[0]; + if (!sourceStringIndex && !sourceNumberIndex) { + if (reportErrors) { + reportError(ts.Diagnostics.Missing_0_index_signature_in_type_1, "[string] or [number]", typeToString(sourceType)); + } + return 0; } - return 0; + var related; + var sourceError = sourceNumberIndex; + if (sourceStringIndex && sourceNumberIndex) { + related = isRelatedTo(sourceStringIndex.typeOfValue, targetNumberIndex.typeOfValue, false) || indexTypesRelatedTo(sourceNumberIndex, targetNumberIndex, numberType); + } + else if (sourceStringIndex) { + related = isRelatedTo(sourceStringIndex.typeOfValue, targetNumberIndex.typeOfValue); + sourceError = sourceStringIndex; + } + else if (sourceNumberIndex) { + related = indexTypesRelatedTo(sourceNumberIndex, targetNumberIndex, numberType); + } + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_0_and_1_are_incompatible, indexTypeToString(sourceError), indexTypeToString(targetNumberIndex)); + } + return 0; + } + return related; } - return related; - } - return -1; - } - function indexTypesIdenticalTo(indexKind, source, target) { - var targetType = getIndexTypeOfType(target, indexKind); - var sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { return -1; } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); + function indexTypesRelatedTo(sourceIndex, targetIndex, defaultIndex) { + return isRelatedTo(sourceIndex.typeOfIndex || defaultIndex, targetIndex.typeOfIndex || defaultIndex, reportErrors) && isRelatedTo(sourceIndex.typeOfValue, targetIndex.typeOfValue, reportErrors); + } + function indexTypesIdenticalTo(sourceIndex, targetIndex, defaultIndex) { + if (!sourceIndex && !targetIndex) { + return -1; + } + if (sourceIndex && targetIndex) { + return indexTypesRelatedTo(sourceIndex, targetIndex, defaultIndex); + } + return 0; } - return 0; } } function isPropertyIdenticalTo(sourceProp, targetProp) { @@ -12604,13 +12754,13 @@ var ts; } members[p.name] = p; }); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + var stringIndex = getIndexOfType(type, 0); + var numberIndex = getIndexOfType(type, 1); + if (stringIndex) + stringIndex = createStringIndex(getWidenedType(stringIndex.typeOfValue)); + if (numberIndex) + numberIndex = createNumberIndex(getWidenedType(numberIndex.typeOfValue)); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndex, numberIndex); } function getWidenedType(type) { if (type.flags & 786432) { @@ -12862,9 +13012,9 @@ var ts; inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } function inferFromIndexTypes(source, target, sourceKind, targetKind) { - var targetIndexType = getIndexTypeOfType(target, targetKind); + var targetIndexType = getIndexValueOfType(target, targetKind); if (targetIndexType) { - var sourceIndexType = getIndexTypeOfType(source, sourceKind); + var sourceIndexType = getIndexValueOfType(source, sourceKind); if (sourceIndexType) { inferFromTypes(sourceIndexType, targetIndexType); } @@ -13493,13 +13643,13 @@ var ts; }); } function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }); + return applyToContextualType(type, function (t) { return getIndexValueOfObjectOrUnionType(t, kind); }); } function contextualTypeIsTupleLikeType(type) { return !!(type.flags & 16384 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }) : getIndexTypeOfObjectOrUnionType(type, kind)); + return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexValueOfObjectOrUnionType(t, kind); }) : getIndexValueOfObjectOrUnionType(type, kind)); } function getContextualTypeForObjectLiteralMethod(node) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); @@ -13743,7 +13893,7 @@ var ts; } var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType ? createStringIndex(stringIndexType) : undefined, numberIndexType ? createNumberIndex(numberIndexType) : undefined); result.flags |= 131072 | 524288 | (typeFlags & 262144); return result; function getIndexType(kind) { @@ -13895,12 +14045,12 @@ var ts; } if (allConstituentTypesHaveKind(indexType, 1 | 258 | 132 | 1048576)) { if (allConstituentTypesHaveKind(indexType, 1 | 132)) { - var numberIndexType = getIndexTypeOfType(objectType, 1); + var numberIndexType = getIndexValueOfType(objectType, 1); if (numberIndexType) { return numberIndexType; } } - var stringIndexType = getIndexTypeOfType(objectType, 0); + var stringIndexType = getIndexValueOfType(objectType, 0); if (stringIndexType) { return stringIndexType; } @@ -14061,7 +14211,7 @@ var ts; if (type.flags & 48128) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { + resolved.properties.length === 0 && !resolved.stringIndex && !resolved.numberIndex) { return resolved.callSignatures[0]; } } @@ -14513,7 +14663,7 @@ var ts; } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); - var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); if (!hasGrammarError && node.kind === 162) { checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); } @@ -14550,7 +14700,7 @@ var ts; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node)); - if (node.type) { + if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type)); } if (node.body) { @@ -14742,8 +14892,8 @@ var ts; var name_8 = p.name; var type = sourceType.flags & 1 ? sourceType : getTypeOfPropertyOfType(sourceType, name_8.text) || - isNumericLiteralName(name_8.text) && getIndexTypeOfType(sourceType, 1) || - getIndexTypeOfType(sourceType, 0); + isNumericLiteralName(name_8.text) && getIndexValueOfType(sourceType, 1) || + getIndexValueOfType(sourceType, 0); if (type) { checkDestructuringAssignment(p.initializer || name_8, type); } @@ -15021,6 +15171,7 @@ var ts; return type; } function checkExpression(node, contextualMapper) { + checkGrammarIdentifierInStrictMode(node); return checkExpressionOrQualifiedName(node, contextualMapper); } function checkExpressionOrQualifiedName(node, contextualMapper) { @@ -15115,6 +15266,7 @@ var ts; return unknownType; } function checkTypeParameter(node) { + checkGrammarDeclarationNameInStrictMode(node); if (node.expression) { grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } @@ -15185,32 +15337,29 @@ var ts; return; } } - var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { - var seenNumericIndexer = false; - var seenStringIndexer = false; + var symbol = getSymbolOfNode(node); + var indexMap = getDeclaredIndexTypesOfSymbol(symbol); + var stringIndex = indexMap[0]; + var numberIndex = indexMap[1]; + if (stringIndex && stringIndex.declaredCount > 1) { + errorDuplicateIndex(getIndexSymbol(symbol), stringIndex); + } + if (numberIndex && numberIndex.declaredCount > 1) { + errorDuplicateIndex(getIndexSymbol(symbol), numberIndex); + } + function errorDuplicateIndex(indexSymbol, indexType) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var declaration = decl; - if (declaration.parameters.length === 1 && declaration.parameters[0].type) { - switch (declaration.parameters[0].type.kind) { - case 121: - if (!seenStringIndexer) { - seenStringIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_string_index_signature); - } - break; - case 119: - if (!seenNumericIndexer) { - seenNumericIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_number_index_signature); - } - break; - } + if (declaration.parameters.length !== 1 || declaration === indexType.declaredNode) { + continue; + } + var type = getTypeFromIndexSignatureParameter(declaration.parameters[0]); + if (type.flags & 2 && indexType.kind === 0) { + error(declaration, ts.Diagnostics.Duplicate_string_index_signature); + } + else if (type.flags & 132 && indexType.kind === 1) { + error(declaration, ts.Diagnostics.Duplicate_number_index_signature); } } } @@ -15317,9 +15466,11 @@ var ts; checkDecorators(node); } function checkTypeReferenceNode(node) { + checkGrammarTypeReferenceInStrictMode(node.typeName); return checkTypeReferenceOrHeritageClauseElement(node); } function checkHeritageClauseElement(node) { + checkGrammarHeritageClauseElementInStrictMode(node.expression); return checkTypeReferenceOrHeritageClauseElement(node); } function checkTypeReferenceOrHeritageClauseElement(node) { @@ -15722,6 +15873,7 @@ var ts; } } function checkFunctionLikeDeclaration(node) { + checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); if (node.name && node.name.kind === 127) { @@ -15741,7 +15893,7 @@ var ts; } } checkSourceElement(node.body); - if (node.type && !isAccessor(node.kind)) { + if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type)); } if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !node.type && !isPrivateWithinAmbient(node)) { @@ -15907,6 +16059,7 @@ var ts; } } function checkVariableLikeDeclaration(node) { + checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); if (node.name.kind === 127) { @@ -16091,7 +16244,7 @@ var ts; return checkElementTypeOfArrayOrString(inputType, errorNode); } if (isArrayLikeType(inputType)) { - return getIndexTypeOfType(inputType, 1); + return getIndexValueOfType(inputType, 1); } error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); return unknownType; @@ -16198,7 +16351,7 @@ var ts; } return hasStringConstituent ? stringType : unknownType; } - var arrayElementType = getIndexTypeOfType(arrayType, 1) || unknownType; + var arrayElementType = getIndexValueOfType(arrayType, 1) || unknownType; if (hasStringConstituent) { if (arrayElementType.flags & 258) { return stringType; @@ -16339,62 +16492,77 @@ var ts; } } function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType || numberIndexType) { - ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); - checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); - checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); - }); - if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 201) { - var classDeclaration = type.symbol.valueDeclaration; - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (!(member.flags & 128) && ts.hasDynamicName(member)) { - var propType = getTypeOfSymbol(member.symbol); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); - } - } - } + var resolved = resolveObjectOrUnionType(type); + if (!resolved) { + return; } - var errorNode; - if (stringIndexType && numberIndexType) { - errorNode = declaredNumberIndexer || declaredStringIndexer; - if (!errorNode && (type.flags & 2048)) { - var someBaseTypeHasBothIndexers = ts.forEach(type.baseTypes, function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + var stringIndex = resolved.stringIndex || createStringIndex(null); + var numberIndex = resolved.numberIndex || createNumberIndex(null); + var alphaNumeric = resolved.alphaNumericIndex; + if (!stringIndex.typeOfValue && !numberIndex.typeOfValue) { + return; + } + var containingNode = type.symbol.declarations[type.symbol.declarations.length - 1]; + var errorNode = containingNode; + var checkIndexNodes = [numberIndex.declaredNode, stringIndex.declaredNode]; + for (var _i = 0; _i < checkIndexNodes.length; _i++) { + var node = checkIndexNodes[_i]; + if (node && node.parent === containingNode) { + errorNode = node; + break; } } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { - error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); + var checkNumberIndex = numberIndex; + if (alphaNumeric === ts.IndexAlphaNumeric.YES && !isTypeAssignableTo(numberIndex.typeOfValue, stringIndex.typeOfValue)) { + error(errorNode, ts.Diagnostics.Numeric_index_0_is_not_assignable_to_string_index_1, indexTypeToString(numberIndex), indexTypeToString(stringIndex)); + checkNumberIndex = null; } - function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { - if (!indexType) { + ts.forEach(getPropertiesOfObjectType(type), function (prop) { + var propType = getTypeOfSymbol(prop); + checkIndexConstraintForProperty(prop, propType, type, stringIndex, alphaNumeric); + if (checkNumberIndex) { + checkIndexConstraintForProperty(prop, propType, type, numberIndex, alphaNumeric); + } + }); + if (type.flags & 1024 && type.symbol.valueDeclaration.kind === 201) { + var classDeclaration = type.symbol.valueDeclaration; + for (var _a = 0, _b = classDeclaration.members; _a < _b.length; _a++) { + var member = _b[_a]; + if (!(member.flags & 128) && ts.hasDynamicName(member)) { + var propType = getTypeOfSymbol(member.symbol); + checkIndexConstraintForProperty(member.symbol, propType, type, stringIndex, alphaNumeric); + if (checkNumberIndex) { + checkIndexConstraintForProperty(member.symbol, propType, type, numberIndex, alphaNumeric); + } + } + } + } + function checkIndexConstraintForProperty(prop, propertyType, containingType, indexType, alphaNumeric) { + if (!indexType.typeOfValue) { return; } - if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { + if (indexType.kind === 1 && !isNumericName(prop.valueDeclaration.name)) { return; } var errorNode; if (prop.valueDeclaration.name.kind === 127 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } - else if (indexDeclaration) { - errorNode = indexDeclaration; - } - else if (containingType.flags & 2048) { - var someBaseClassHasBothPropertyAndIndexer = ts.forEach(containingType.baseTypes, function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + else if (indexType.declaredNode) { + errorNode = indexType.declaredNode; + var containingNode_1 = containingType.symbol.declarations[containingType.symbol.declarations.length - 1]; + if (errorNode.parent !== containingNode_1) { + errorNode = containingNode_1; + } + if (alphaNumeric === ts.IndexAlphaNumeric.INHERITED) { + errorNode = undefined; + } } - if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { - var errorMessage = indexKind === 0 - ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 - : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); + if (errorNode && !isTypeAssignableTo(propertyType, indexType.typeOfValue)) { + var errorMessage = indexType.kind === 0 + ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_2 + : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_2; + error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), indexTypeToString(indexType)); } } } @@ -16430,6 +16598,7 @@ var ts; return unknownType; } function checkClassDeclaration(node) { + checkGrammarDeclarationNameInStrictMode(node); if (node.parent.kind !== 206 && node.parent.kind !== 227) { grammarErrorOnNode(node, ts.Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration); } @@ -16618,7 +16787,7 @@ var ts; return ok; } function checkInterfaceDeclaration(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); @@ -16804,7 +16973,7 @@ var ts; if (!produceDiagnostics) { return; } - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -16857,7 +17026,7 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -16946,7 +17115,7 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -16967,7 +17136,7 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1) { @@ -17268,6 +17437,8 @@ var ts; if (!(links.flags & 1)) { checkGrammarSourceFile(node); emitExtends = false; + emitDecorate = false; + emitParam = false; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); checkFunctionExpressionBodies(node); @@ -18054,7 +18225,9 @@ var ts; globalObjectType = getGlobalType("Object"); globalFunctionType = getGlobalType("Function"); globalStringType = getGlobalType("String"); + globalStringSubsetType = cloneInterfaceType(globalStringType, 2097152); globalNumberType = getGlobalType("Number"); + globalNumberSubsetType = cloneInterfaceType(globalNumberType, 2097152); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); @@ -18075,6 +18248,105 @@ var ts; } anyArrayType = createArrayType(anyType); } + function isReservedwordInStrictMode(node) { + return (node.parserContextFlags & 1) && + (node.originalKeywordKind >= 103 && node.originalKeywordKind <= 111); + } + function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { + if (ts.getAncestor(identifier, 201) || ts.getAncestor(identifier, 174)) { + return grammarErrorOnNode(identifier, message, arg0); + } + return false; + } + function checkGrammarImportDeclarationNameInStrictMode(node) { + if (node.importClause) { + var impotClause = node.importClause; + if (impotClause.namedBindings) { + var nameBindings = impotClause.namedBindings; + if (nameBindings.kind === 211) { + var name_11 = nameBindings.name; + if (name_11.originalKeywordKind) { + var nameText = ts.declarationNameToString(name_11); + return grammarErrorOnNode(name_11, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + } + } + else if (nameBindings.kind === 212) { + var reportError = false; + for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { + var element = _a[_i]; + var name_12 = element.name; + if (name_12.originalKeywordKind) { + var nameText = ts.declarationNameToString(name_12); + reportError = reportError || grammarErrorOnNode(name_12, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + } + } + return reportError; + } + } + } + return false; + } + function checkGrammarDeclarationNameInStrictMode(node) { + var name = node.name; + if (name && name.kind === 65 && isReservedwordInStrictMode(name)) { + var nameText = ts.declarationNameToString(name); + switch (node.kind) { + case 129: + case 198: + case 200: + case 128: + case 152: + case 202: + case 203: + case 204: + return checkGrammarIdentifierInStrictMode(name); + case 201: + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); + case 205: + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + case 208: + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + } + } + return false; + } + function checkGrammarTypeReferenceInStrictMode(typeName) { + if (typeName.kind === 65) { + checkGrammarTypeNameInStrictMode(typeName); + } + else if (typeName.kind === 126) { + checkGrammarTypeNameInStrictMode(typeName.right); + checkGrammarTypeReferenceInStrictMode(typeName.left); + } + } + function checkGrammarHeritageClauseElementInStrictMode(expression) { + if (expression && expression.kind === 65) { + return checkGrammarIdentifierInStrictMode(expression); + } + else if (expression && expression.kind === 155) { + checkGrammarHeritageClauseElementInStrictMode(expression.expression); + } + } + function checkGrammarIdentifierInStrictMode(node, nameText) { + if (node && node.kind === 65 && isReservedwordInStrictMode(node)) { + if (!nameText) { + nameText = ts.declarationNameToString(node); + } + var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || + grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + return errorReport; + } + return false; + } + function checkGrammarTypeNameInStrictMode(node) { + if (node && node.kind === 65 && isReservedwordInStrictMode(node)) { + var nameText = ts.declarationNameToString(node); + var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || + grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText); + return errorReport; + } + return false; + } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -18286,6 +18558,23 @@ var ts; } return false; } + function getTypeFromIndexSignatureParameter(parameter) { + if (parameter.type) { + if (parameter.type.kind === 121) { + return stringType; + } + if (parameter.type.kind === 119) { + return numberType; + } + if (parameter.type.kind === 141) { + var type = getTypeFromTypeReference((parameter.type)); + if ((type.flags & 132) || (type.flags & 2)) { + return type; + } + } + } + return undefined; + } function checkGrammarIndexSignatureParameters(node) { var parameter = node.parameters[0]; if (node.parameters.length !== 1) { @@ -18311,8 +18600,8 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 121 && parameter.type.kind !== 119) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + if (!getTypeFromIndexSignatureParameter(parameter)) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_number_or_an_enum_type); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); @@ -18444,17 +18733,17 @@ var ts; var inStrictMode = (node.parserContextFlags & 1) !== 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_11 = prop.name; + var name_13 = prop.name; if (prop.kind === 175 || - name_11.kind === 127) { - checkGrammarComputedPropertyName(name_11); + name_13.kind === 127) { + checkGrammarComputedPropertyName(name_13); continue; } var currentKind = void 0; if (prop.kind === 224 || prop.kind === 225) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_11.kind === 7) { - checkGrammarNumbericLiteral(name_11); + if (name_13.kind === 7) { + checkGrammarNumbericLiteral(name_13); } currentKind = Property; } @@ -18470,26 +18759,26 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_11.text)) { - seen[name_11.text] = currentKind; + if (!ts.hasProperty(seen, name_13.text)) { + seen[name_13.text] = currentKind; } else { - var existingKind = seen[name_11.text]; + var existingKind = seen[name_13.text]; if (currentKind === Property && existingKind === Property) { if (inStrictMode) { - grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); + grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); } } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_11.text] = currentKind | existingKind; + seen[name_13.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -18808,12 +19097,11 @@ var ts; var identifier = name; if (contextNode && (contextNode.parserContextFlags & 1) && ts.isEvalOrArgumentsIdentifier(identifier)) { var nameText = ts.declarationNameToString(identifier); - if (ts.getAncestor(name, 201) || ts.getAncestor(name, 174)) { - return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); - } - else { + var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); + if (!reportErrorInClassDeclaration) { return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); } + return reportErrorInClassDeclaration; } } } @@ -19262,9 +19550,9 @@ var ts; } var count = 0; while (true) { - var name_12 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_12)) { - return name_12; + var name_14 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_14)) { + return name_14; } } } @@ -20346,9 +20634,9 @@ var ts; var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_13 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_13)) { - return name_13; + var name_15 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_15)) { + return name_15; } } } @@ -20376,8 +20664,8 @@ var ts; } function generateNameForModuleOrEnum(node) { if (node.name.kind === 65) { - var name_14 = node.name.text; - assignGeneratedName(node, isUniqueLocalName(name_14, node) ? name_14 : makeUniqueName(name_14)); + var name_16 = node.name.text; + assignGeneratedName(node, isUniqueLocalName(name_16, node) ? name_16 : makeUniqueName(name_16)); } } function generateNameForImportOrExportDeclaration(node) { @@ -20557,8 +20845,8 @@ var ts; if (scopeName) { var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { - var name_15 = node.name; - if (!name_15 || name_15.kind !== 127) { + var name_17 = node.name; + if (!name_17 || name_17.kind !== 127) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -20585,9 +20873,9 @@ var ts; node.kind === 201 || node.kind === 204) { if (node.name) { - var name_16 = node.name; - scopeName = name_16.kind === 127 - ? ts.getTextOfNode(name_16) + var name_18 = node.name; + scopeName = name_18.kind === 127 + ? ts.getTextOfNode(name_18) : node.name.text; } recordScopeNameStart(scopeName); @@ -21000,6 +21288,7 @@ var ts; default: return -1; } + case 172: case 170: return -1; default: @@ -21171,6 +21460,16 @@ var ts; write("..."); emit(node.expression); } + function emitYieldExpression(node) { + write(ts.tokenToString(111)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65: @@ -21412,6 +21711,9 @@ var ts; write("]"); } function emitMethod(node) { + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } emit(node.name, false); if (languageVersion < 2) { write(": function "); @@ -22397,12 +22699,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var name_17 = createTempVariable(0); + var name_19 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_17); - emit(name_17); + tempParameters.push(name_19); + emit(name_19); } else { emit(node.name); @@ -22521,7 +22823,11 @@ var ts; write("default "); } } - write("function "); + write("function"); + if (languageVersion >= 2 && node.asteriskToken) { + write("*"); + } + write(" "); } if (shouldEmitFunctionName(node)) { emitDeclarationName(node); @@ -22853,6 +23159,9 @@ var ts; else if (member.kind === 137) { write("set "); } + if (member.asteriskToken) { + write("*"); + } emit(member.name); emitSignatureAndBody(member); emitEnd(member); @@ -23818,8 +24127,8 @@ var ts; else { for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_18 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_18] || (exportSpecifiers[name_18] = [])).push(specifier); + var name_20 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_20] || (exportSpecifiers[name_20] = [])).push(specifier); } } break; @@ -24130,6 +24439,8 @@ var ts; return emitConditionalExpression(node); case 173: return emitSpreadElementExpression(node); + case 172: + return emitYieldExpression(node); case 175: return; case 179: @@ -25670,9 +25981,9 @@ var ts; case 198: case 152: var variableDeclarationNode; - var name_19; + var name_21; if (node.kind === 152) { - name_19 = node.name; + name_21 = node.name; variableDeclarationNode = node; while (variableDeclarationNode && variableDeclarationNode.kind !== 198) { variableDeclarationNode = variableDeclarationNode.parent; @@ -25682,16 +25993,16 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_19 = node.name; + name_21 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.variableElement); } case 135: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); @@ -27639,9 +27950,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_20 in o) { - if (o[name_20] === rule) { - return name_20; + for (var name_22 in o) { + if (o[name_22] === rule) { + return name_22; } } throw new Error("Unknown rule"); @@ -31293,10 +31604,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_21 in nameTable) { - if (!allNames[name_21]) { - allNames[name_21] = name_21; - var displayName = getCompletionEntryDisplayName(name_21, target, true); + for (var name_23 in nameTable) { + if (!allNames[name_23]) { + allNames[name_23] = name_23; + var displayName = getCompletionEntryDisplayName(name_23, target, true); if (displayName) { var entry = { name: displayName, @@ -31770,6 +32081,9 @@ var ts; if (!node) { return undefined; } + if (isLabelName(node)) { + return undefined; + } var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { switch (node.kind) { @@ -32935,17 +33249,17 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeInfoResolver.getContextualType(objectLiteral); - var name_22 = node.text; + var name_24 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(name_22); + var unionProperty = contextualType.getProperty(name_24); if (unionProperty) { return [unionProperty]; } else { var result_3 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_22); + var symbol = t.getProperty(name_24); if (symbol) { result_3.push(symbol); } @@ -32954,7 +33268,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_22); + var symbol_1 = contextualType.getProperty(name_24); if (symbol_1) { return [symbol_1]; } @@ -34230,8 +34544,7 @@ var ts; this.errorTimer = setTimeout(checkOne, ms); } }; - Session.prototype.getDefinition = function (_a) { - var line = _a.line, offset = _a.offset, fileName = _a.file; + Session.prototype.getDefinition = function (line, offset, fileName) { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -34249,8 +34562,7 @@ var ts; end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan)) }); }); }; - Session.prototype.getOccurrences = function (_a) { - var line = _a.line, offset = _a.offset, fileName = _a.file; + Session.prototype.getOccurrences = function (line, offset, fileName) { fileName = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(fileName); if (!project) { @@ -34274,8 +34586,7 @@ var ts; }; }); }; - Session.prototype.getRenameLocations = function (_a) { - var line = _a.line, offset = _a.offset, fileName = _a.file, findInComments = _a.findInComments, findInStrings = _a.findInStrings; + Session.prototype.getRenameLocations = function (line, offset, fileName, findInComments, findInStrings) { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -34336,8 +34647,7 @@ var ts; }, []); return { info: renameInfo, locs: bakedRenameLocs }; }; - Session.prototype.getReferences = function (_a) { - var line = _a.line, offset = _a.offset, fileName = _a.file; + Session.prototype.getReferences = function (line, offset, fileName) { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -34377,13 +34687,11 @@ var ts; symbolDisplayString: displayString }; }; - Session.prototype.openClientFile = function (_a) { - var fileName = _a.file; + Session.prototype.openClientFile = function (fileName) { var file = ts.normalizePath(fileName); this.projectService.openClientFile(file); }; - Session.prototype.getQuickInfo = function (_a) { - var line = _a.line, offset = _a.offset, fileName = _a.file; + Session.prototype.getQuickInfo = function (line, offset, fileName) { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -34406,8 +34714,7 @@ var ts; documentation: docString }; }; - Session.prototype.getFormattingEditsForRange = function (_a) { - var line = _a.line, offset = _a.offset, endLine = _a.endLine, endOffset = _a.endOffset, fileName = _a.file; + Session.prototype.getFormattingEditsForRange = function (line, offset, endLine, endOffset, fileName) { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -34428,8 +34735,7 @@ var ts; }; }); }; - Session.prototype.getFormattingEditsAfterKeystroke = function (_a) { - var line = _a.line, offset = _a.offset, key = _a.key, fileName = _a.file; + Session.prototype.getFormattingEditsAfterKeystroke = function (line, offset, key, fileName) { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -34486,8 +34792,7 @@ var ts; }; }); }; - Session.prototype.getCompletions = function (_a) { - var line = _a.line, offset = _a.offset, prefix = _a.prefix, fileName = _a.file; + Session.prototype.getCompletions = function (line, offset, prefix, fileName) { if (!prefix) { prefix = ""; } @@ -34509,8 +34814,7 @@ var ts; return result; }, []).sort(function (a, b) { return a.name.localeCompare(b.name); }); }; - Session.prototype.getCompletionEntryDetails = function (_a) { - var line = _a.line, offset = _a.offset, entryNames = _a.entryNames, fileName = _a.file; + Session.prototype.getCompletionEntryDetails = function (line, offset, entryNames, fileName) { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -34526,8 +34830,7 @@ var ts; return accum; }, []); }; - Session.prototype.getSignatureHelpItems = function (_a) { - var line = _a.line, offset = _a.offset, fileName = _a.file; + Session.prototype.getSignatureHelpItems = function (line, offset, fileName) { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -34552,9 +34855,8 @@ var ts; }; return result; }; - Session.prototype.getDiagnostics = function (_a) { + Session.prototype.getDiagnostics = function (delay, fileNames) { var _this = this; - var delay = _a.delay, fileNames = _a.files; var checkList = fileNames.reduce(function (accum, fileName) { fileName = ts.normalizePath(fileName); var project = _this.projectService.getProjectForFile(fileName); @@ -34567,9 +34869,8 @@ var ts; this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay); } }; - Session.prototype.change = function (_a) { + Session.prototype.change = function (line, offset, endLine, endOffset, insertString, fileName) { var _this = this; - var line = _a.line, offset = _a.offset, endLine = _a.endLine, endOffset = _a.endOffset, insertString = _a.insertString, fileName = _a.file; var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (project) { @@ -34583,9 +34884,8 @@ var ts; this.updateProjectStructure(this.changeSeq, function (n) { return n == _this.changeSeq; }); } }; - Session.prototype.reload = function (_a, reqSeq) { + Session.prototype.reload = function (fileName, tempFileName, reqSeq) { var _this = this; - var fileName = _a.file, tempFileName = _a.tmpfile; if (reqSeq === void 0) { reqSeq = 0; } var file = ts.normalizePath(fileName); var tmpfile = ts.normalizePath(tempFileName); @@ -34597,8 +34897,7 @@ var ts; }); } }; - Session.prototype.saveToTmp = function (_a) { - var fileName = _a.file, tempFileName = _a.tmpfile; + Session.prototype.saveToTmp = function (fileName, tempFileName) { var file = ts.normalizePath(fileName); var tmpfile = ts.normalizePath(tempFileName); var project = this.projectService.getProjectForFile(file); @@ -34606,8 +34905,7 @@ var ts; project.compilerService.host.saveTo(file, tmpfile); } }; - Session.prototype.closeClientFile = function (_a) { - var fileName = _a.file; + Session.prototype.closeClientFile = function (fileName) { var file = ts.normalizePath(fileName); this.projectService.closeClientFile(file); }; @@ -34628,8 +34926,7 @@ var ts; childItems: _this.decorateNavigationBarItem(project, fileName, item.childItems) }); }); }; - Session.prototype.getNavigationBarItems = function (_a) { - var fileName = _a.file; + Session.prototype.getNavigationBarItems = function (fileName) { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -34642,8 +34939,7 @@ var ts; } return this.decorateNavigationBarItem(project, fileName, items); }; - Session.prototype.getNavigateToItems = function (_a) { - var searchValue = _a.searchValue, fileName = _a.file, maxResultCount = _a.maxResultCount; + Session.prototype.getNavigateToItems = function (searchValue, fileName, maxResultCount) { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -34679,8 +34975,7 @@ var ts; return bakedItem; }); }; - Session.prototype.getBraceMatching = function (_a) { - var line = _a.line, offset = _a.offset, fileName = _a.file; + Session.prototype.getBraceMatching = function (line, offset, fileName) { var file = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(file); if (!project) { @@ -34716,91 +35011,112 @@ var ts; break; } case CommandNames.Definition: { - response = this.getDefinition(request.arguments); + var defArgs = request.arguments; + response = this.getDefinition(defArgs.line, defArgs.offset, defArgs.file); break; } case CommandNames.References: { - response = this.getReferences(request.arguments); + var refArgs = request.arguments; + response = this.getReferences(refArgs.line, refArgs.offset, refArgs.file); break; } case CommandNames.Rename: { - response = this.getRenameLocations(request.arguments); + var renameArgs = request.arguments; + response = this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings); break; } case CommandNames.Open: { - this.openClientFile(request.arguments); + var openArgs = request.arguments; + this.openClientFile(openArgs.file); responseRequired = false; break; } case CommandNames.Quickinfo: { - response = this.getQuickInfo(request.arguments); + var quickinfoArgs = request.arguments; + response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file); break; } case CommandNames.Format: { - response = this.getFormattingEditsForRange(request.arguments); + var formatArgs = request.arguments; + response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file); break; } case CommandNames.Formatonkey: { - response = this.getFormattingEditsAfterKeystroke(request.arguments); + var formatOnKeyArgs = request.arguments; + response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file); break; } case CommandNames.Completions: { - response = this.getCompletions(request.arguments); + var completionsArgs = request.arguments; + response = this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file); break; } case CommandNames.CompletionDetails: { - response = this.getCompletionEntryDetails(request.arguments); + var completionDetailsArgs = request.arguments; + response = + this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file); break; } case CommandNames.SignatureHelp: { - response = this.getSignatureHelpItems(request.arguments); + var signatureHelpArgs = request.arguments; + response = this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file); break; } case CommandNames.Geterr: { - this.getDiagnostics(request.arguments); + var geterrArgs = request.arguments; + response = this.getDiagnostics(geterrArgs.delay, geterrArgs.files); responseRequired = false; break; } case CommandNames.Change: { - this.change(request.arguments); + var changeArgs = request.arguments; + this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, changeArgs.insertString, changeArgs.file); responseRequired = false; break; } case CommandNames.Configure: { - this.projectService.setHostConfiguration(request.arguments); + var configureArgs = request.arguments; + this.projectService.setHostConfiguration(configureArgs); this.output(undefined, CommandNames.Configure, request.seq); responseRequired = false; break; } case CommandNames.Reload: { - this.reload(request.arguments); + var reloadArgs = request.arguments; + this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq); responseRequired = false; break; } case CommandNames.Saveto: { - this.saveToTmp(request.arguments); + var savetoArgs = request.arguments; + this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); responseRequired = false; break; } case CommandNames.Close: { - this.closeClientFile(request.arguments); + var closeArgs = request.arguments; + this.closeClientFile(closeArgs.file); responseRequired = false; break; } case CommandNames.Navto: { - response = this.getNavigateToItems(request.arguments); + var navtoArgs = request.arguments; + response = this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount); break; } case CommandNames.Brace: { - response = this.getBraceMatching(request.arguments); + var braceArguments = request.arguments; + response = this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file); break; } case CommandNames.NavBar: { - response = this.getNavigationBarItems(request.arguments); + var navBarArgs = request.arguments; + response = this.getNavigationBarItems(navBarArgs.file); break; } case CommandNames.Occurrences: { - response = this.getOccurrences(request.arguments); + var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file; + response = this.getOccurrences(line, offset, fileName); break; } default: { diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts index a16bff2a86223..90f07da785e90 100644 --- a/bin/typescript.d.ts +++ b/bin/typescript.d.ts @@ -310,6 +310,7 @@ declare module "typescript" { } interface Identifier extends PrimaryExpression { text: string; + originalKeywordKind?: SyntaxKind; } interface QualifiedName extends Node { left: EntityName; @@ -991,8 +992,10 @@ declare module "typescript" { Anonymous = 32768, ObjectLiteral = 131072, ESSymbol = 1048576, + Subset = 2097152, StringLike = 258, NumberLike = 132, + SubsetMaybe = 4224, ObjectType = 48128, } interface Type { @@ -1010,8 +1013,8 @@ declare module "typescript" { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; - declaredStringIndexType: Type; - declaredNumberIndexType: Type; + declaredStringIndex: IndexType; + declaredNumberIndex: IndexType; } interface TypeReference extends ObjectType { target: GenericType; @@ -1026,6 +1029,19 @@ declare module "typescript" { interface UnionType extends Type { types: Type[]; } + enum IndexAlphaNumeric { + NO = 0, + YES = 1, + INHERITED = 2, + } + interface IndexType { + kind: IndexKind; + typeOfValue: Type; + typeOfIndex?: Type; + declaredNode?: SignatureDeclaration; + declaredCount?: number; + inherited?: Symbol; + } interface TypeParameter extends Type { constraint: Type; } diff --git a/bin/typescript.js b/bin/typescript.js index 1c749f0d94a03..206ee5a31ef31 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -509,17 +509,25 @@ var ts; /* @internal */ TypeFlags[TypeFlags["ContainsObjectLiteral"] = 524288] = "ContainsObjectLiteral"; TypeFlags[TypeFlags["ESSymbol"] = 1048576] = "ESSymbol"; + TypeFlags[TypeFlags["Subset"] = 2097152] = "Subset"; /* @internal */ TypeFlags[TypeFlags["Intrinsic"] = 1048703] = "Intrinsic"; /* @internal */ TypeFlags[TypeFlags["Primitive"] = 1049086] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; + TypeFlags[TypeFlags["SubsetMaybe"] = 4224] = "SubsetMaybe"; TypeFlags[TypeFlags["ObjectType"] = 48128] = "ObjectType"; /* @internal */ TypeFlags[TypeFlags["RequiresWidening"] = 786432] = "RequiresWidening"; })(ts.TypeFlags || (ts.TypeFlags = {})); var TypeFlags = ts.TypeFlags; + (function (IndexAlphaNumeric) { + IndexAlphaNumeric[IndexAlphaNumeric["NO"] = 0] = "NO"; + IndexAlphaNumeric[IndexAlphaNumeric["YES"] = 1] = "YES"; + IndexAlphaNumeric[IndexAlphaNumeric["INHERITED"] = 2] = "INHERITED"; // string & number indexes are both from an inherited type + })(ts.IndexAlphaNumeric || (ts.IndexAlphaNumeric = {})); + var IndexAlphaNumeric = ts.IndexAlphaNumeric; (function (SignatureKind) { SignatureKind[SignatureKind["Call"] = 0] = "Call"; SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; @@ -1659,7 +1667,7 @@ var ts; An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, + An_index_signature_parameter_type_must_be_string_number_or_an_enum_type: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string', 'number', or an enum type." }, A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: ts.DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: ts.DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, A_class_can_only_extend_a_single_class: { code: 1026, category: ts.DiagnosticCategory.Error, key: "A class can only extend a single class." }, @@ -1809,6 +1817,12 @@ var ts; Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." }, + Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, + Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -1837,8 +1851,8 @@ var ts; Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible." }, Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, + Missing_0_index_signature_in_type_1: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Missing {0} index signature in type '{1}'." }, + Index_signatures_0_and_1_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures '{0}' and '{1}' are incompatible." }, this_cannot_be_referenced_in_a_module_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module body." }, this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, @@ -1913,9 +1927,9 @@ var ts; Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" }, All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, + Property_0_of_type_1_is_not_assignable_to_string_index_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index '{2}'." }, + Property_0_of_type_1_is_not_assignable_to_numeric_index_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index '{2}'." }, + Numeric_index_0_is_not_assignable_to_string_index_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index '{0}' is not assignable to string index '{1}'." }, Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class name cannot be '{0}'" }, Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly extends base class '{1}'." }, Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, @@ -6995,6 +7009,7 @@ var ts; function tryParse(callback) { return speculationHelper(callback, false); } + // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { if (token === 65 /* Identifier */) { return true; @@ -7004,7 +7019,7 @@ var ts; if (token === 111 /* YieldKeyword */ && inYieldContext()) { return false; } - return inStrictModeContext() ? token > 111 /* LastFutureReservedWord */ : token > 101 /* LastReservedWord */; + return token > 101 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage) { if (token === kind) { @@ -7108,6 +7123,10 @@ var ts; identifierCount++; if (isIdentifier) { var node = createNode(65 /* Identifier */); + // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker + if (token !== 65 /* Identifier */) { + node.originalKeywordKind = token; + } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); @@ -9823,6 +9842,17 @@ var ts; node.body = parseFunctionBlockOrSemicolon(false); return finishNode(node); } + function isClassMemberModifier(idToken) { + switch (idToken) { + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 110 /* StaticKeyword */: + return true; + default: + return false; + } + } function isClassMemberStart() { var idToken; if (token === 52 /* AtToken */) { @@ -9831,6 +9861,15 @@ var ts; // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. while (ts.isModifier(token)) { idToken = token; + // If the idToken is a class modifier (protected, private, public, and static), it is + // certain that we are starting to parse class member. This allows better error recovery + // Example: + // public foo() ... // true + // public @dec blah ... // true; we will then report an error later + // export public ... // true; we will then report an error later + if (isClassMemberModifier(idToken)) { + return true; + } nextToken(); } if (token === 35 /* AsteriskToken */) { @@ -10528,6 +10567,8 @@ var ts; var nextSymbolId = 1; var nextNodeId = 1; var nextMergeId = 1; + // TODO: LKG and replace [x: IndexKind] + // @internal function getNodeId(node) { if (!node.id) node.id = nextNodeId++; @@ -10568,7 +10609,7 @@ var ts; getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: getIndexTypeOfType, + getIndexTypeOfType: getIndexValueOfType, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, @@ -10614,7 +10655,9 @@ var ts; var globalFunctionType; var globalArrayType; var globalStringType; + var globalStringSubsetType; var globalNumberType; + var globalNumberSubsetType; var globalBooleanType; var globalRegExpType; var globalTemplateStringsArrayType; @@ -11465,6 +11508,19 @@ var ts; type.symbol = symbol; return type; } + function cloneInterfaceType(type, flags) { + var cloneType = createType(type.flags); + cloneType.symbol = type.symbol; + cloneType.flags |= flags; + cloneType.baseTypes = type.baseTypes; + cloneType.declaredCallSignatures = type.declaredCallSignatures; + cloneType.declaredConstructSignatures = type.declaredCallSignatures; + cloneType.declaredNumberIndex = type.declaredNumberIndex; + cloneType.declaredStringIndex = type.declaredStringIndex; + cloneType.declaredProperties = type.declaredProperties; + cloneType.typeParameters = type.typeParameters; + return cloneType; + } // A reserved member name starts with two underscores, but the third character cannot be an underscore // or the @ symbol. A third underscore indicates an escaped form of an identifer that started // with at least two underscores. The @ character indicates that the name is denoted by a well known ES @@ -11491,19 +11547,27 @@ var ts; } return result || emptyArray; } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex) { type.members = members; type.properties = getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexType) - type.stringIndexType = stringIndexType; - if (numberIndexType) - type.numberIndexType = numberIndexType; + if (stringIndex) + type.stringIndex = stringIndex; + if (numberIndex) + type.numberIndex = numberIndex; + if (stringIndex && numberIndex) { + if (numberIndex.inherited && (numberIndex.inherited === stringIndex.inherited)) { + type.alphaNumericIndex = ts.IndexAlphaNumeric.INHERITED; + } + else { + type.alphaNumericIndex = ts.IndexAlphaNumeric.YES; + } + } return type; } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(32768 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndex, numberIndex) { + return setObjectTypeMembers(createObjectType(32768 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndex, numberIndex); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -11761,6 +11825,10 @@ var ts; } return result; } + function indexTypeToString(type) { + var index = type.typeOfIndex || ((type.kind === 0 /* String */) ? stringType : numberType); + return '[' + typeToString(index) + ']: ' + typeToString(type.typeOfValue); + } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; @@ -11987,7 +12055,8 @@ var ts; buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } function getIndexerParameterName(type, indexKind, fallbackName) { - var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + var indexMap = getDeclaredIndexTypesOfSymbol(type.symbol); + var declaration = indexMap[indexKind] ? indexMap[indexKind].declaredNode : null; if (!declaration) { // declaration might not be found if indexer was added from the contextual type. // in this case use fallback name @@ -11998,7 +12067,7 @@ var ts; } function writeLiteralType(type, flags) { var resolved = resolveObjectOrUnionTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.properties.length && !resolved.stringIndex && !resolved.numberIndex) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, 14 /* OpenBraceToken */); writePunctuation(writer, 15 /* CloseBraceToken */); @@ -12044,34 +12113,30 @@ var ts; writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } - if (resolved.stringIndexType) { - // [x: string]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); - writePunctuation(writer, 51 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, 121 /* StringKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 51 /* ColonToken */); - writeSpace(writer); - writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); - writer.writeLine(); - } - if (resolved.numberIndexType) { - // [x: number]: + function writeIndexType(indexType) { + if (!indexType) { + return; + } writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); + writer.writeParameter(getIndexerParameterName(resolved, indexType.kind, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 119 /* NumberKeyword */); + if (indexType.typeOfIndex && (indexType.typeOfIndex.flags & 2097152 /* Subset */)) { + writeType(indexType.typeOfIndex, 0 /* None */); + writer.writeStringLiteral(indexType.kind === 0 /* String */ ? " < string" : " < number"); + } + else { + writeKeyword(writer, indexType.kind === 0 /* String */ ? 121 /* StringKeyword */ : 119 /* NumberKeyword */); + } writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeType(resolved.numberIndexType, 0 /* None */); + writeType(indexType.typeOfValue, 0 /* None */); writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } + writeIndexType(resolved.stringIndex); + writeIndexType(resolved.numberIndex); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -12419,8 +12484,8 @@ var ts; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. type = getTypeOfPropertyOfType(parentType, name_5.text) || - isNumericLiteralName(name_5.text) && getIndexTypeOfType(parentType, 1 /* Number */) || - getIndexTypeOfType(parentType, 0 /* String */); + isNumericLiteralName(name_5.text) && getIndexValueOfType(parentType, 1 /* Number */) || + getIndexValueOfType(parentType, 0 /* String */); if (!type) { error(name_5, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_5)); return unknownType; @@ -12826,8 +12891,9 @@ var ts; type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = emptyArray; type.declaredConstructSignatures = emptyArray; - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + var indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + type.declaredStringIndex = indexTypes[0 /* String */]; + type.declaredNumberIndex = indexTypes[1 /* Number */]; } return links.declaredType; } @@ -12868,8 +12934,9 @@ var ts; type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + var indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + type.declaredStringIndex = indexTypes[0 /* String */]; + type.declaredNumberIndex = indexTypes[1 /* Number */]; } return links.declaredType; } @@ -12893,7 +12960,7 @@ var ts; function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(128 /* Enum */); + var type = createType(128 /* Enum */ | 2097152 /* Subset */); type.symbol = symbol; links.declaredType = type; } @@ -12972,23 +13039,55 @@ var ts; } } } + function createNumberIndex(value, index) { + return createIndexType(1 /* Number */, value, index); + } + function createStringIndex(value, index) { + return createIndexType(0 /* String */, value, index); + } + function createIndexType(kind, value, index) { + var indexType = { + kind: kind, + typeOfValue: value + }; + if (index) { + indexType.typeOfIndex = index; + } + return indexType; + } + function getInheritedIndexFrom(baseType) { + var resolved = resolveObjectOrUnionType(baseType); + var index = [ + resolved.stringIndex, + resolved.numberIndex + ]; + for (var i in index) { + if (index[i]) { + index[i].inherited = baseType.symbol; + } + } + return index; + } function resolveClassOrInterfaceMembers(type) { var members = type.symbol.members; var callSignatures = type.declaredCallSignatures; var constructSignatures = type.declaredConstructSignatures; - var stringIndexType = type.declaredStringIndexType; - var numberIndexType = type.declaredNumberIndexType; - if (type.baseTypes.length) { + var stringIndex = type.declaredStringIndex; + var numberIndex = type.declaredNumberIndex; + if (type.baseTypes && type.baseTypes.length) { members = createSymbolTable(type.declaredProperties); ts.forEach(type.baseTypes, function (baseType) { addInheritedMembers(members, getPropertiesOfObjectType(baseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1 /* Number */); + if (!stringIndex || !numberIndex) { + var index = getInheritedIndexFrom(baseType); + stringIndex = stringIndex || index[0 /* String */]; + numberIndex = numberIndex || index[1 /* Number */]; + } }); } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function resolveTypeReferenceMembers(type) { var target = type.target; @@ -12996,17 +13095,20 @@ var ts; var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; + var stringIndex = target.declaredStringIndex ? instantiateIndexType(target.declaredStringIndex, mapper) : undefined; + var numberIndex = target.declaredNumberIndex ? instantiateIndexType(target.declaredNumberIndex, mapper) : undefined; ts.forEach(target.baseTypes, function (baseType) { var instantiatedBaseType = instantiateType(baseType, mapper); addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); + if (!stringIndex || !numberIndex) { + var index = getInheritedIndexFrom(instantiatedBaseType); + stringIndex = stringIndex || index[0 /* String */]; + numberIndex = numberIndex || index[1 /* Number */]; + } }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -13049,7 +13151,7 @@ var ts; var arrayType = resolveObjectOrUnionTypeMembers(createArrayType(getUnionType(type.elementTypes))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); + setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndex, arrayType.numberIndex); } function signatureListsIdentical(s, t) { if (s.length !== t.length) { @@ -13092,7 +13194,7 @@ var ts; var indexTypes = []; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - var indexType = getIndexTypeOfType(type, kind); + var indexType = getIndexValueOfType(type, kind); if (!indexType) { return undefined; } @@ -13107,21 +13209,21 @@ var ts; var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); var stringIndexType = getUnionIndexType(type.types, 0 /* String */); var numberIndexType = getUnionIndexType(type.types, 1 /* Number */); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType ? createStringIndex(stringIndexType) : undefined, numberIndexType ? createNumberIndex(numberIndexType) : undefined); } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; var members; var callSignatures; var constructSignatures; - var stringIndexType; - var numberIndexType; + var stringIndex; + var numberIndex; if (symbol.flags & 2048 /* TypeLiteral */) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); - stringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - numberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + stringIndex = getIndexTypeOfSymbol(symbol, 0 /* String */); + numberIndex = getIndexTypeOfSymbol(symbol, 1 /* Number */); } else { // Combinations of function, class, enum and module @@ -13145,10 +13247,11 @@ var ts; addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(classType.baseTypes[0].symbol))); } } - stringIndexType = undefined; - numberIndexType = (symbol.flags & 384 /* Enum */) ? stringType : undefined; + stringIndex = undefined; + // { kind: SymbolDisplayPartKind[kind] }, ideally typed to SetOf_Names + numberIndex = (symbol.flags & 384 /* Enum */) ? createNumberIndex(stringType) : undefined; } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function resolveObjectOrUnionTypeMembers(type) { if (!type.members) { @@ -13219,10 +13322,20 @@ var ts; } } if (type.flags & 258 /* StringLike */) { - type = globalStringType; + if (type.flags & 2097152 /* Subset */) { + type = globalStringSubsetType; + } + else { + type = globalStringType; + } } else if (type.flags & 132 /* NumberLike */) { - type = globalNumberType; + if (type.flags & 2097152 /* Subset */) { + type = globalNumberSubsetType; + } + else { + type = globalNumberType; + } } else if (type.flags & 8 /* Boolean */) { type = globalBooleanType; @@ -13325,17 +13438,37 @@ var ts; } return false; } - function getIndexTypeOfObjectOrUnionType(type, kind) { + function resolveObjectOrUnionType(type) { + if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { + return resolveObjectOrUnionTypeMembers(type); + } + } + function getIndexOfObjectOrUnionType(type) { if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { var resolved = resolveObjectOrUnionTypeMembers(type); - return kind === 0 /* String */ ? resolved.stringIndexType : resolved.numberIndexType; + return [ + resolved.stringIndex, + resolved.numberIndex + ]; } } + function getIndexTypeOfObjectOrUnionType(type, kind) { + var indexMap = getIndexOfObjectOrUnionType(type); + return indexMap ? indexMap[kind] : undefined; + } + function getIndexValueOfObjectOrUnionType(type, kind) { + var indexType = getIndexTypeOfObjectOrUnionType(type, kind); + return indexType ? indexType.typeOfValue : undefined; + } // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. - function getIndexTypeOfType(type, kind) { + function getIndexOfType(type, kind) { return getIndexTypeOfObjectOrUnionType(getApparentType(type), kind); } + function getIndexValueOfType(type, kind) { + var indexType = getIndexOfType(type, kind); + return indexType ? indexType.typeOfValue : undefined; + } // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). function getTypeParametersFromDeclaration(typeParameterDeclarations) { @@ -13512,29 +13645,44 @@ var ts; function getIndexSymbol(symbol) { return symbol.members["__index"]; } - function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 119 /* NumberKeyword */ : 121 /* StringKeyword */; + function getDeclaredIndexTypesOfSymbol(symbol) { + var indexMap = []; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { - var len = indexSymbol.declarations.length; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var node = decl; - if (node.parameters.length === 1) { - var parameter = node.parameters[0]; - if (parameter && parameter.type && parameter.type.kind === syntaxKind) { - return node; + if (decl.parameters.length === 1) { + var type = getTypeFromIndexSignatureParameter(decl.parameters[0]); + if (!type) { + continue; + } + var kind = (type.flags & 132 /* NumberLike */) ? 1 /* Number */ : (type.flags & 2 /* String */) ? 0 /* String */ : null; + if (kind !== null) { + if (indexMap[kind]) { + indexMap[kind].declaredCount++; + } + else { + indexMap[kind] = { + kind: kind, + typeOfIndex: type, + typeOfValue: decl.type ? getTypeFromTypeNodeOrHeritageClauseElement(decl.type) : anyType, + declaredNode: decl, + declaredCount: 1 + }; + } } } } } - return undefined; + return indexMap; } function getIndexTypeOfSymbol(symbol, kind) { - var declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration - ? declaration.type ? getTypeFromTypeNodeOrHeritageClauseElement(declaration.type) : anyType - : undefined; + var indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + return indexTypes[kind]; + } + function getIndexValueOfSymbol(symbol, kind) { + var info = getIndexTypeOfSymbol(symbol, kind); + return info ? info.typeOfValue : undefined; } function getConstraintOfTypeParameter(type) { if (!type.constraint) { @@ -14045,14 +14193,17 @@ var ts; result.members = createSymbolTable(result.properties); result.callSignatures = instantiateList(getSignaturesOfType(type, 0 /* Call */), mapper, instantiateSignature); result.constructSignatures = instantiateList(getSignaturesOfType(type, 1 /* Construct */), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + var stringIndex = getIndexOfType(type, 0 /* String */); + var numberIndex = getIndexOfType(type, 1 /* Number */); + if (stringIndex) + result.stringIndex = instantiateIndexType(stringIndex, mapper); + if (numberIndex) + result.numberIndex = instantiateIndexType(numberIndex, mapper); return result; } + function instantiateIndexType(index, mapper) { + return createIndexType(index.kind, instantiateType(index.typeOfValue, mapper), index.typeOfIndex); + } function instantiateType(type, mapper) { if (mapper !== identityMapper) { if (type.flags & 512 /* TypeParameter */) { @@ -14245,6 +14396,8 @@ var ts; } } else { + if ((source.flags & 2097152 /* Subset */) && (target.flags & 2097152 /* Subset */)) { + } var saveErrorInfo = errorInfo; if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if relationship holds for all type arguments @@ -14406,10 +14559,7 @@ var ts; if (result) { result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportErrors); if (result) { - result &= stringIndexTypesRelatedTo(source, target, reportErrors); - if (result) { - result &= numberIndexTypesRelatedTo(source, target, reportErrors); - } + result &= indexRelatedTo(source, target, reportErrors); } } } @@ -14651,72 +14801,83 @@ var ts; } return result; } - function stringIndexTypesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(0 /* String */, source, target); - } - var targetType = getIndexTypeOfType(target, 0 /* String */); - if (targetType) { - var sourceType = getIndexTypeOfType(source, 0 /* String */); - if (!sourceType) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0 /* False */; + function indexRelatedTo(source, target, reportErrors) { + var sourceIndex = getIndexOfObjectOrUnionType(source); + var targetIndex = getIndexOfObjectOrUnionType(target); + var sourceType = source; + var targetType = target; + return stringIndexRelatedTo(sourceIndex[0 /* String */], targetIndex[0 /* String */]) && + numberIndexRelatedTo(sourceIndex, targetIndex[1 /* Number */]); + function stringIndexRelatedTo(source, target) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(source, target, stringType); } - var related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); + if (target) { + if (!source) { + if (reportErrors) { + reportError(ts.Diagnostics.Missing_0_index_signature_in_type_1, "[string]", typeToString(sourceType)); + } + return 0 /* False */; } - return 0 /* False */; - } - return related; - } - return -1 /* True */; - } - function numberIndexTypesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(1 /* Number */, source, target); - } - var targetType = getIndexTypeOfType(target, 1 /* Number */); - if (targetType) { - var sourceStringType = getIndexTypeOfType(source, 0 /* String */); - var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + var related = indexTypesRelatedTo(source, target, stringType); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_0_and_1_are_incompatible, indexTypeToString(source), indexTypeToString(target)); + } + return 0 /* False */; } - return 0 /* False */; - } - var related; - if (sourceStringType && sourceNumberType) { - // If we know for sure we're testing both string and numeric index types then only report errors from the second one - related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); + return related; } - else { - related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); + return -1 /* True */; + } + function numberIndexRelatedTo(source, targetNumberIndex) { + var sourceNumberIndex = source[1 /* Number */]; + if (relation === identityRelation) { + return indexTypesIdenticalTo(sourceNumberIndex, targetNumberIndex, numberType); } - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); + if (targetNumberIndex) { + var sourceStringIndex = source[0 /* String */]; + if (!sourceStringIndex && !sourceNumberIndex) { + if (reportErrors) { + reportError(ts.Diagnostics.Missing_0_index_signature_in_type_1, "[string] or [number]", typeToString(sourceType)); + } + return 0 /* False */; } - return 0 /* False */; + var related; + var sourceError = sourceNumberIndex; + if (sourceStringIndex && sourceNumberIndex) { + // If we know for sure we're testing both string and numeric index types then only report errors from the second one + related = isRelatedTo(sourceStringIndex.typeOfValue, targetNumberIndex.typeOfValue, false) || indexTypesRelatedTo(sourceNumberIndex, targetNumberIndex, numberType); + } + else if (sourceStringIndex) { + related = isRelatedTo(sourceStringIndex.typeOfValue, targetNumberIndex.typeOfValue); + sourceError = sourceStringIndex; + } + else if (sourceNumberIndex) { + related = indexTypesRelatedTo(sourceNumberIndex, targetNumberIndex, numberType); + } + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_0_and_1_are_incompatible, indexTypeToString(sourceError), indexTypeToString(targetNumberIndex)); + } + return 0 /* False */; + } + return related; } - return related; - } - return -1 /* True */; - } - function indexTypesIdenticalTo(indexKind, source, target) { - var targetType = getIndexTypeOfType(target, indexKind); - var sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { return -1 /* True */; } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); + function indexTypesRelatedTo(sourceIndex, targetIndex, defaultIndex) { + return isRelatedTo(sourceIndex.typeOfIndex || defaultIndex, targetIndex.typeOfIndex || defaultIndex, reportErrors) && isRelatedTo(sourceIndex.typeOfValue, targetIndex.typeOfValue, reportErrors); + } + function indexTypesIdenticalTo(sourceIndex, targetIndex, defaultIndex) { + if (!sourceIndex && !targetIndex) { + return -1 /* True */; + } + if (sourceIndex && targetIndex) { + return indexTypesRelatedTo(sourceIndex, targetIndex, defaultIndex); + } + return 0 /* False */; } - return 0 /* False */; } } function isPropertyIdenticalTo(sourceProp, targetProp) { @@ -14868,13 +15029,13 @@ var ts; } members[p.name] = p; }); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + var stringIndex = getIndexOfType(type, 0 /* String */); + var numberIndex = getIndexOfType(type, 1 /* Number */); + if (stringIndex) + stringIndex = createStringIndex(getWidenedType(stringIndex.typeOfValue)); + if (numberIndex) + numberIndex = createNumberIndex(getWidenedType(numberIndex.typeOfValue)); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndex, numberIndex); } function getWidenedType(type) { if (type.flags & 786432 /* RequiresWidening */) { @@ -15139,9 +15300,9 @@ var ts; inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } function inferFromIndexTypes(source, target, sourceKind, targetKind) { - var targetIndexType = getIndexTypeOfType(target, targetKind); + var targetIndexType = getIndexValueOfType(target, targetKind); if (targetIndexType) { - var sourceIndexType = getIndexTypeOfType(source, sourceKind); + var sourceIndexType = getIndexValueOfType(source, sourceKind); if (sourceIndexType) { inferFromTypes(sourceIndexType, targetIndexType); } @@ -15881,7 +16042,7 @@ var ts; }); } function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }); + return applyToContextualType(type, function (t) { return getIndexValueOfObjectOrUnionType(t, kind); }); } // Return true if the given contextual type is a tuple-like type function contextualTypeIsTupleLikeType(type) { @@ -15889,7 +16050,7 @@ var ts; } // Return true if the given contextual type provides an index signature of the given kind function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }) : getIndexTypeOfObjectOrUnionType(type, kind)); + return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexValueOfObjectOrUnionType(t, kind); }) : getIndexValueOfObjectOrUnionType(type, kind)); } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one @@ -16205,7 +16366,7 @@ var ts; } var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType ? createStringIndex(stringIndexType) : undefined, numberIndexType ? createNumberIndex(numberIndexType) : undefined); result.flags |= 131072 /* ObjectLiteral */ | 524288 /* ContainsObjectLiteral */ | (typeFlags & 262144 /* ContainsUndefinedOrNull */); return result; function getIndexType(kind) { @@ -16393,13 +16554,13 @@ var ts; if (allConstituentTypesHaveKind(indexType, 1 /* Any */ | 258 /* StringLike */ | 132 /* NumberLike */ | 1048576 /* ESSymbol */)) { // Try to use a number indexer. if (allConstituentTypesHaveKind(indexType, 1 /* Any */ | 132 /* NumberLike */)) { - var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); + var numberIndexType = getIndexValueOfType(objectType, 1 /* Number */); if (numberIndexType) { return numberIndexType; } } // Try to use string indexing. - var stringIndexType = getIndexTypeOfType(objectType, 0 /* String */); + var stringIndexType = getIndexValueOfType(objectType, 0 /* String */); if (stringIndexType) { return stringIndexType; } @@ -16612,7 +16773,7 @@ var ts; if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { + resolved.properties.length === 0 && !resolved.stringIndex && !resolved.numberIndex) { return resolved.callSignatures[0]; } } @@ -17230,7 +17391,7 @@ var ts; function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { ts.Debug.assert(node.kind !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking - var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); if (!hasGrammarError && node.kind === 162 /* FunctionExpression */) { checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); } @@ -17272,7 +17433,7 @@ var ts; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { ts.Debug.assert(node.kind !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - if (node.type) { + if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type)); } if (node.body) { @@ -17507,8 +17668,8 @@ var ts; var name_8 = p.name; var type = sourceType.flags & 1 /* Any */ ? sourceType : getTypeOfPropertyOfType(sourceType, name_8.text) || - isNumericLiteralName(name_8.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || - getIndexTypeOfType(sourceType, 0 /* String */); + isNumericLiteralName(name_8.text) && getIndexValueOfType(sourceType, 1 /* Number */) || + getIndexValueOfType(sourceType, 0 /* String */); if (type) { checkDestructuringAssignment(p.initializer || name_8, type); } @@ -17834,6 +17995,7 @@ var ts; return type; } function checkExpression(node, contextualMapper) { + checkGrammarIdentifierInStrictMode(node); return checkExpressionOrQualifiedName(node, contextualMapper); } // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When @@ -17941,6 +18103,7 @@ var ts; } // DECLARATION AND STATEMENT TYPE CHECKING function checkTypeParameter(node) { + checkGrammarDeclarationNameInStrictMode(node); // Grammar Checking if (node.expression) { grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); @@ -18020,32 +18183,29 @@ var ts; // TypeScript 1.0 spec (April 2014) // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration - var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { - var seenNumericIndexer = false; - var seenStringIndexer = false; + var symbol = getSymbolOfNode(node); + var indexMap = getDeclaredIndexTypesOfSymbol(symbol); + var stringIndex = indexMap[0 /* String */]; + var numberIndex = indexMap[1 /* Number */]; + if (stringIndex && stringIndex.declaredCount > 1) { + errorDuplicateIndex(getIndexSymbol(symbol), stringIndex); + } + if (numberIndex && numberIndex.declaredCount > 1) { + errorDuplicateIndex(getIndexSymbol(symbol), numberIndex); + } + function errorDuplicateIndex(indexSymbol, indexType) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var declaration = decl; - if (declaration.parameters.length === 1 && declaration.parameters[0].type) { - switch (declaration.parameters[0].type.kind) { - case 121 /* StringKeyword */: - if (!seenStringIndexer) { - seenStringIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_string_index_signature); - } - break; - case 119 /* NumberKeyword */: - if (!seenNumericIndexer) { - seenNumericIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_number_index_signature); - } - break; - } + if (declaration.parameters.length !== 1 || declaration === indexType.declaredNode) { + continue; + } + var type = getTypeFromIndexSignatureParameter(declaration.parameters[0]); + if (type.flags & 2 /* String */ && indexType.kind === 0 /* String */) { + error(declaration, ts.Diagnostics.Duplicate_string_index_signature); + } + else if (type.flags & 132 /* NumberLike */ && indexType.kind === 1 /* Number */) { + error(declaration, ts.Diagnostics.Duplicate_number_index_signature); } } } @@ -18172,9 +18332,11 @@ var ts; checkDecorators(node); } function checkTypeReferenceNode(node) { + checkGrammarTypeReferenceInStrictMode(node.typeName); return checkTypeReferenceOrHeritageClauseElement(node); } function checkHeritageClauseElement(node) { + checkGrammarHeritageClauseElementInStrictMode(node.expression); return checkTypeReferenceOrHeritageClauseElement(node); } function checkTypeReferenceOrHeritageClauseElement(node) { @@ -18648,6 +18810,7 @@ var ts; } } function checkFunctionLikeDeclaration(node) { + checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); // Do not use hasDynamicName here, because that returns false for well known symbols. @@ -18678,7 +18841,7 @@ var ts; } } checkSourceElement(node.body); - if (node.type && !isAccessor(node.kind)) { + if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type)); } // Report an implicit any error if there is no body, no explicit return type, and node is not a private method @@ -18891,6 +19054,7 @@ var ts; } // Check variable, parameter, or property declaration function checkVariableLikeDeclaration(node) { + checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); // For a computed property, just check the initializer and exit @@ -19120,7 +19284,7 @@ var ts; return checkElementTypeOfArrayOrString(inputType, errorNode); } if (isArrayLikeType(inputType)) { - return getIndexTypeOfType(inputType, 1 /* Number */); + return getIndexValueOfType(inputType, 1 /* Number */); } error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); return unknownType; @@ -19259,7 +19423,7 @@ var ts; } return hasStringConstituent ? stringType : unknownType; } - var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */) || unknownType; + var arrayElementType = getIndexValueOfType(arrayType, 1 /* Number */) || unknownType; if (hasStringConstituent) { // This is just an optimization for the case where arrayOrStringType is string | string[] if (arrayElementType.flags & 258 /* StringLike */) { @@ -19417,49 +19581,62 @@ var ts; } } function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType || numberIndexType) { - ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); - checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); - checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); - }); - if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 201 /* ClassDeclaration */) { - var classDeclaration = type.symbol.valueDeclaration; - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; - // Only process instance properties with computed names here. - // Static properties cannot be in conflict with indexers, - // and properties with literal names were already checked. - if (!(member.flags & 128 /* Static */) && ts.hasDynamicName(member)) { - var propType = getTypeOfSymbol(member.symbol); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); - } - } - } + var resolved = resolveObjectOrUnionType(type); + if (!resolved) { + return; } - var errorNode; - if (stringIndexType && numberIndexType) { - errorNode = declaredNumberIndexer || declaredStringIndexer; - // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer - if (!errorNode && (type.flags & 2048 /* Interface */)) { - var someBaseTypeHasBothIndexers = ts.forEach(type.baseTypes, function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + var stringIndex = resolved.stringIndex || createStringIndex(null); + var numberIndex = resolved.numberIndex || createNumberIndex(null); + var alphaNumeric = resolved.alphaNumericIndex; + if (!stringIndex.typeOfValue && !numberIndex.typeOfValue) { + return; + } + var containingNode = type.symbol.declarations[type.symbol.declarations.length - 1]; + var errorNode = containingNode; + var checkIndexNodes = [numberIndex.declaredNode, stringIndex.declaredNode]; + for (var _i = 0; _i < checkIndexNodes.length; _i++) { + var node = checkIndexNodes[_i]; + // Use index declaration as error node if contained in the class/interface + if (node && node.parent === containingNode) { + errorNode = node; + break; } } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { - error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); + // Don't check number index if not assignable + var checkNumberIndex = numberIndex; + if (alphaNumeric === ts.IndexAlphaNumeric.YES && !isTypeAssignableTo(numberIndex.typeOfValue, stringIndex.typeOfValue)) { + error(errorNode, ts.Diagnostics.Numeric_index_0_is_not_assignable_to_string_index_1, indexTypeToString(numberIndex), indexTypeToString(stringIndex)); + checkNumberIndex = null; } - function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { - if (!indexType) { + ts.forEach(getPropertiesOfObjectType(type), function (prop) { + var propType = getTypeOfSymbol(prop); + checkIndexConstraintForProperty(prop, propType, type, stringIndex, alphaNumeric); + if (checkNumberIndex) { + checkIndexConstraintForProperty(prop, propType, type, numberIndex, alphaNumeric); + } + }); + if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 201 /* ClassDeclaration */) { + var classDeclaration = type.symbol.valueDeclaration; + for (var _a = 0, _b = classDeclaration.members; _a < _b.length; _a++) { + var member = _b[_a]; + // Only process instance properties with computed names here. + // Static properties cannot be in conflict with indexers, + // and properties with literal names were already checked. + if (!(member.flags & 128 /* Static */) && ts.hasDynamicName(member)) { + var propType = getTypeOfSymbol(member.symbol); + checkIndexConstraintForProperty(member.symbol, propType, type, stringIndex, alphaNumeric); + if (checkNumberIndex) { + checkIndexConstraintForProperty(member.symbol, propType, type, numberIndex, alphaNumeric); + } + } + } + } + function checkIndexConstraintForProperty(prop, propertyType, containingType, indexType, alphaNumeric) { + if (!indexType.typeOfValue) { return; } // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !isNumericName(prop.valueDeclaration.name)) { + if (indexType.kind === 1 /* Number */ && !isNumericName(prop.valueDeclaration.name)) { return; } // perform property check if property or indexer is declared in 'type' @@ -19468,21 +19645,22 @@ var ts; if (prop.valueDeclaration.name.kind === 127 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } - else if (indexDeclaration) { - errorNode = indexDeclaration; - } - else if (containingType.flags & 2048 /* Interface */) { - // for interfaces property and indexer might be inherited from different bases - // check if any base class already has both property and indexer. - // check should be performed only if 'type' is the first type that brings property\indexer together - var someBaseClassHasBothPropertyAndIndexer = ts.forEach(containingType.baseTypes, function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + else if (indexType.declaredNode) { + errorNode = indexType.declaredNode; + var containingNode_1 = containingType.symbol.declarations[containingType.symbol.declarations.length - 1]; + if (errorNode.parent !== containingNode_1) { + errorNode = containingNode_1; + } + if (alphaNumeric === ts.IndexAlphaNumeric.INHERITED) { + // inherited node will report error instead + errorNode = undefined; + } } - if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { - var errorMessage = indexKind === 0 /* String */ - ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 - : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); + if (errorNode && !isTypeAssignableTo(propertyType, indexType.typeOfValue)) { + var errorMessage = indexType.kind === 0 /* String */ + ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_2 + : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_2; + error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), indexTypeToString(indexType)); } } } @@ -19521,6 +19699,7 @@ var ts; return unknownType; } function checkClassDeclaration(node) { + checkGrammarDeclarationNameInStrictMode(node); // Grammar checking if (node.parent.kind !== 206 /* ModuleBlock */ && node.parent.kind !== 227 /* SourceFile */) { grammarErrorOnNode(node, ts.Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration); @@ -19721,7 +19900,7 @@ var ts; } function checkInterfaceDeclaration(node) { // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); @@ -19921,7 +20100,7 @@ var ts; return; } // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -19983,7 +20162,7 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -20078,7 +20257,7 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { + if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -20099,7 +20278,7 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1 /* Export */) { @@ -20418,6 +20597,8 @@ var ts; // Grammar checking checkGrammarSourceFile(node); emitExtends = false; + emitDecorate = false; + emitParam = false; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); checkFunctionExpressionBodies(node); @@ -21319,7 +21500,9 @@ var ts; globalObjectType = getGlobalType("Object"); globalFunctionType = getGlobalType("Function"); globalStringType = getGlobalType("String"); + globalStringSubsetType = cloneInterfaceType(globalStringType, 2097152 /* Subset */); globalNumberType = getGlobalType("Number"); + globalNumberSubsetType = cloneInterfaceType(globalNumberType, 2097152 /* Subset */); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); @@ -21346,6 +21529,137 @@ var ts; anyArrayType = createArrayType(anyType); } // GRAMMAR CHECKING + function isReservedwordInStrictMode(node) { + // Check that originalKeywordKind is less than LastFurtureReservedWord to see if an Identifier is a strict-mode reserved word + return (node.parserContextFlags & 1 /* StrictMode */) && + (node.originalKeywordKind >= 103 /* FirstFutureReservedWord */ && node.originalKeywordKind <= 111 /* LastFutureReservedWord */); + } + function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { + // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.) + // if so, we would like to give more explicit invalid usage error. + if (ts.getAncestor(identifier, 201 /* ClassDeclaration */) || ts.getAncestor(identifier, 174 /* ClassExpression */)) { + return grammarErrorOnNode(identifier, message, arg0); + } + return false; + } + function checkGrammarImportDeclarationNameInStrictMode(node) { + // Check if the import declaration used strict-mode reserved word in its names bindings + if (node.importClause) { + var impotClause = node.importClause; + if (impotClause.namedBindings) { + var nameBindings = impotClause.namedBindings; + if (nameBindings.kind === 211 /* NamespaceImport */) { + var name_11 = nameBindings.name; + if (name_11.originalKeywordKind) { + var nameText = ts.declarationNameToString(name_11); + return grammarErrorOnNode(name_11, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + } + } + else if (nameBindings.kind === 212 /* NamedImports */) { + var reportError = false; + for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { + var element = _a[_i]; + var name_12 = element.name; + if (name_12.originalKeywordKind) { + var nameText = ts.declarationNameToString(name_12); + reportError = reportError || grammarErrorOnNode(name_12, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + } + } + return reportError; + } + } + } + return false; + } + function checkGrammarDeclarationNameInStrictMode(node) { + var name = node.name; + if (name && name.kind === 65 /* Identifier */ && isReservedwordInStrictMode(name)) { + var nameText = ts.declarationNameToString(name); + switch (node.kind) { + case 129 /* Parameter */: + case 198 /* VariableDeclaration */: + case 200 /* FunctionDeclaration */: + case 128 /* TypeParameter */: + case 152 /* BindingElement */: + case 202 /* InterfaceDeclaration */: + case 203 /* TypeAliasDeclaration */: + case 204 /* EnumDeclaration */: + return checkGrammarIdentifierInStrictMode(name); + case 201 /* ClassDeclaration */: + // Report an error if the class declaration uses strict-mode reserved word. + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); + case 205 /* ModuleDeclaration */: + // Report an error if the module declaration uses strict-mode reserved word. + // TODO(yuisu): fix this when having external module in strict mode + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + case 208 /* ImportEqualsDeclaration */: + // TODO(yuisu): fix this when having external module in strict mode + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + } + } + return false; + } + function checkGrammarTypeReferenceInStrictMode(typeName) { + // Check if the type reference is using strict mode keyword + // Example: + // class C { + // foo(x: public){} // Error. + // } + if (typeName.kind === 65 /* Identifier */) { + checkGrammarTypeNameInStrictMode(typeName); + } + else if (typeName.kind === 126 /* QualifiedName */) { + // Walk from right to left and report a possible error at each Identifier in QualifiedName + // Example: + // x1: public.private.package // error at public and private + checkGrammarTypeNameInStrictMode(typeName.right); + checkGrammarTypeReferenceInStrictMode(typeName.left); + } + } + // This function will report an error for every identifier in property access expression + // whether it violates strict mode reserved words. + // Example: + // public // error at public + // public.private.package // error at public + // B.private.B // no error + function checkGrammarHeritageClauseElementInStrictMode(expression) { + // Example: + // class C extends public // error at public + if (expression && expression.kind === 65 /* Identifier */) { + return checkGrammarIdentifierInStrictMode(expression); + } + else if (expression && expression.kind === 155 /* PropertyAccessExpression */) { + // Walk from left to right in PropertyAccessExpression until we are at the left most expression + // in PropertyAccessExpression. According to grammar production of MemberExpression, + // the left component expression is a PrimaryExpression (i.e. Identifier) while the other + // component after dots can be IdentifierName. + checkGrammarHeritageClauseElementInStrictMode(expression.expression); + } + } + // The function takes an identifier itself or an expression which has SyntaxKind.Identifier. + function checkGrammarIdentifierInStrictMode(node, nameText) { + if (node && node.kind === 65 /* Identifier */ && isReservedwordInStrictMode(node)) { + if (!nameText) { + nameText = ts.declarationNameToString(node); + } + // TODO (yuisu): Fix when module is a strict mode + var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || + grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + return errorReport; + } + return false; + } + // The function takes an identifier when uses as a typeName in TypeReferenceNode + function checkGrammarTypeNameInStrictMode(node) { + if (node && node.kind === 65 /* Identifier */ && isReservedwordInStrictMode(node)) { + var nameText = ts.declarationNameToString(node); + // TODO (yuisu): Fix when module is a strict mode + var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || + grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText); + return errorReport; + } + return false; + } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -21558,6 +21872,23 @@ var ts; } return false; } + function getTypeFromIndexSignatureParameter(parameter) { + if (parameter.type) { + if (parameter.type.kind === 121 /* StringKeyword */) { + return stringType; + } + if (parameter.type.kind === 119 /* NumberKeyword */) { + return numberType; + } + if (parameter.type.kind === 141 /* TypeReference */) { + var type = getTypeFromTypeReference((parameter.type)); + if ((type.flags & 132 /* NumberLike */) || (type.flags & 2 /* String */)) { + return type; + } + } + } + return undefined; + } function checkGrammarIndexSignatureParameters(node) { var parameter = node.parameters[0]; if (node.parameters.length !== 1) { @@ -21583,8 +21914,8 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 121 /* StringKeyword */ && parameter.type.kind !== 119 /* NumberKeyword */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + if (!getTypeFromIndexSignatureParameter(parameter)) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_number_or_an_enum_type); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); @@ -21721,11 +22052,11 @@ var ts; var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_11 = prop.name; + var name_13 = prop.name; if (prop.kind === 175 /* OmittedExpression */ || - name_11.kind === 127 /* ComputedPropertyName */) { + name_13.kind === 127 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_11); + checkGrammarComputedPropertyName(name_13); continue; } // ECMA-262 11.1.5 Object Initialiser @@ -21740,8 +22071,8 @@ var ts; if (prop.kind === 224 /* PropertyAssignment */ || prop.kind === 225 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_11.kind === 7 /* NumericLiteral */) { - checkGrammarNumbericLiteral(name_11); + if (name_13.kind === 7 /* NumericLiteral */) { + checkGrammarNumbericLiteral(name_13); } currentKind = Property; } @@ -21757,26 +22088,26 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_11.text)) { - seen[name_11.text] = currentKind; + if (!ts.hasProperty(seen, name_13.text)) { + seen[name_13.text] = currentKind; } else { - var existingKind = seen[name_11.text]; + var existingKind = seen[name_13.text]; if (currentKind === Property && existingKind === Property) { if (inStrictMode) { - grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); + grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); } } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_11.text] = currentKind | existingKind; + seen[name_13.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -22124,15 +22455,14 @@ var ts; var identifier = name; if (contextNode && (contextNode.parserContextFlags & 1 /* StrictMode */) && ts.isEvalOrArgumentsIdentifier(identifier)) { var nameText = ts.declarationNameToString(identifier); - // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.) - // if so, we would like to give more explicit invalid usage error. - // This will be particularly helpful in the case of "arguments" as such case is very common mistake. - if (ts.getAncestor(name, 201 /* ClassDeclaration */) || ts.getAncestor(name, 174 /* ClassExpression */)) { - return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); - } - else { + // We check first if the name is inside class declaration or class expression; if so give explicit message + // otherwise report generic error message. + // reportGrammarErrorInClassDeclaration only return true if grammar error is successfully reported and false otherwise + var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); + if (!reportErrorInClassDeclaration) { return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); } + return reportErrorInClassDeclaration; } } } @@ -22631,9 +22961,9 @@ var ts; } var count = 0; while (true) { - var name_12 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_12)) { - return name_12; + var name_14 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_14)) { + return name_14; } } } @@ -23835,9 +24165,9 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_13 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_13)) { - return name_13; + var name_15 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_15)) { + return name_15; } } } @@ -23870,9 +24200,9 @@ var ts; } function generateNameForModuleOrEnum(node) { if (node.name.kind === 65 /* Identifier */) { - var name_14 = node.name.text; + var name_16 = node.name.text; // Use module/enum name itself if it is unique, otherwise make a unique variation - assignGeneratedName(node, isUniqueLocalName(name_14, node) ? name_14 : makeUniqueName(name_14)); + assignGeneratedName(node, isUniqueLocalName(name_16, node) ? name_16 : makeUniqueName(name_16)); } } function generateNameForImportOrExportDeclaration(node) { @@ -24085,8 +24415,8 @@ var ts; // Child scopes are always shown with a dot (even if they have no name), // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. - var name_15 = node.name; - if (!name_15 || name_15.kind !== 127 /* ComputedPropertyName */) { + var name_17 = node.name; + if (!name_17 || name_17.kind !== 127 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -24115,10 +24445,10 @@ var ts; node.kind === 204 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { - var name_16 = node.name; + var name_18 = node.name; // For computed property names, the text will include the brackets - scopeName = name_16.kind === 127 /* ComputedPropertyName */ - ? ts.getTextOfNode(name_16) + scopeName = name_18.kind === 127 /* ComputedPropertyName */ + ? ts.getTextOfNode(name_18) : node.name.text; } recordScopeNameStart(scopeName); @@ -24592,6 +24922,7 @@ var ts; default: return -1 /* LessThan */; } + case 172 /* YieldExpression */: case 170 /* ConditionalExpression */: return -1 /* LessThan */; default: @@ -24779,6 +25110,16 @@ var ts; write("..."); emit(node.expression); } + function emitYieldExpression(node) { + write(ts.tokenToString(111 /* YieldKeyword */)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65 /* Identifier */: @@ -25037,6 +25378,9 @@ var ts; write("]"); } function emitMethod(node) { + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } emit(node.name, false); if (languageVersion < 2 /* ES6 */) { write(": function "); @@ -26140,12 +26484,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2 /* ES6 */) { if (ts.isBindingPattern(node.name)) { - var name_17 = createTempVariable(0 /* Auto */); + var name_19 = createTempVariable(0 /* Auto */); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_17); - emit(name_17); + tempParameters.push(name_19); + emit(name_19); } else { emit(node.name); @@ -26269,7 +26613,11 @@ var ts; write("default "); } } - write("function "); + write("function"); + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } + write(" "); } if (shouldEmitFunctionName(node)) { emitDeclarationName(node); @@ -26616,6 +26964,9 @@ var ts; else if (member.kind === 137 /* SetAccessor */) { write("set "); } + if (member.asteriskToken) { + write("*"); + } emit(member.name); emitSignatureAndBody(member); emitEnd(member); @@ -27761,8 +28112,8 @@ var ts; // export { x, y } for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_18 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_18] || (exportSpecifiers[name_18] = [])).push(specifier); + var name_20 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_20] || (exportSpecifiers[name_20] = [])).push(specifier); } } break; @@ -28094,6 +28445,8 @@ var ts; return emitConditionalExpression(node); case 173 /* SpreadElementExpression */: return emitSpreadElementExpression(node); + case 172 /* YieldExpression */: + return emitYieldExpression(node); case 175 /* OmittedExpression */: return; case 179 /* Block */: @@ -29753,9 +30106,9 @@ var ts; case 198 /* VariableDeclaration */: case 152 /* BindingElement */: var variableDeclarationNode; - var name_19; + var name_21; if (node.kind === 152 /* BindingElement */) { - name_19 = node.name; + name_21 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration @@ -29767,16 +30120,16 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_19 = node.name; + name_21 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.variableElement); } case 135 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); @@ -32316,9 +32669,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_20 in o) { - if (o[name_20] === rule) { - return name_20; + for (var name_22 in o) { + if (o[name_22] === rule) { + return name_22; } } throw new Error("Unknown rule"); @@ -36528,10 +36881,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_21 in nameTable) { - if (!allNames[name_21]) { - allNames[name_21] = name_21; - var displayName = getCompletionEntryDisplayName(name_21, target, true); + for (var name_23 in nameTable) { + if (!allNames[name_23]) { + allNames[name_23] = name_23; + var displayName = getCompletionEntryDisplayName(name_23, target, true); if (displayName) { var entry = { name: displayName, @@ -37033,6 +37386,9 @@ var ts; if (!node) { return undefined; } + if (isLabelName(node)) { + return undefined; + } var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { // Try getting just type at this position and show @@ -38363,19 +38719,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeInfoResolver.getContextualType(objectLiteral); - var name_22 = node.text; + var name_24 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_22); + var unionProperty = contextualType.getProperty(name_24); if (unionProperty) { return [unionProperty]; } else { var result_3 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_22); + var symbol = t.getProperty(name_24); if (symbol) { result_3.push(symbol); } @@ -38384,7 +38740,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_22); + var symbol_1 = contextualType.getProperty(name_24); if (symbol_1) { return [symbol_1]; } diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts index d988810fd3b9f..42c15992f72c0 100644 --- a/bin/typescriptServices.d.ts +++ b/bin/typescriptServices.d.ts @@ -310,6 +310,7 @@ declare module ts { } interface Identifier extends PrimaryExpression { text: string; + originalKeywordKind?: SyntaxKind; } interface QualifiedName extends Node { left: EntityName; @@ -991,8 +992,10 @@ declare module ts { Anonymous = 32768, ObjectLiteral = 131072, ESSymbol = 1048576, + Subset = 2097152, StringLike = 258, NumberLike = 132, + SubsetMaybe = 4224, ObjectType = 48128, } interface Type { @@ -1010,8 +1013,8 @@ declare module ts { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; - declaredStringIndexType: Type; - declaredNumberIndexType: Type; + declaredStringIndex: IndexType; + declaredNumberIndex: IndexType; } interface TypeReference extends ObjectType { target: GenericType; @@ -1026,6 +1029,19 @@ declare module ts { interface UnionType extends Type { types: Type[]; } + enum IndexAlphaNumeric { + NO = 0, + YES = 1, + INHERITED = 2, + } + interface IndexType { + kind: IndexKind; + typeOfValue: Type; + typeOfIndex?: Type; + declaredNode?: SignatureDeclaration; + declaredCount?: number; + inherited?: Symbol; + } interface TypeParameter extends Type { constraint: Type; } diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 1c749f0d94a03..206ee5a31ef31 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -509,17 +509,25 @@ var ts; /* @internal */ TypeFlags[TypeFlags["ContainsObjectLiteral"] = 524288] = "ContainsObjectLiteral"; TypeFlags[TypeFlags["ESSymbol"] = 1048576] = "ESSymbol"; + TypeFlags[TypeFlags["Subset"] = 2097152] = "Subset"; /* @internal */ TypeFlags[TypeFlags["Intrinsic"] = 1048703] = "Intrinsic"; /* @internal */ TypeFlags[TypeFlags["Primitive"] = 1049086] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; + TypeFlags[TypeFlags["SubsetMaybe"] = 4224] = "SubsetMaybe"; TypeFlags[TypeFlags["ObjectType"] = 48128] = "ObjectType"; /* @internal */ TypeFlags[TypeFlags["RequiresWidening"] = 786432] = "RequiresWidening"; })(ts.TypeFlags || (ts.TypeFlags = {})); var TypeFlags = ts.TypeFlags; + (function (IndexAlphaNumeric) { + IndexAlphaNumeric[IndexAlphaNumeric["NO"] = 0] = "NO"; + IndexAlphaNumeric[IndexAlphaNumeric["YES"] = 1] = "YES"; + IndexAlphaNumeric[IndexAlphaNumeric["INHERITED"] = 2] = "INHERITED"; // string & number indexes are both from an inherited type + })(ts.IndexAlphaNumeric || (ts.IndexAlphaNumeric = {})); + var IndexAlphaNumeric = ts.IndexAlphaNumeric; (function (SignatureKind) { SignatureKind[SignatureKind["Call"] = 0] = "Call"; SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; @@ -1659,7 +1667,7 @@ var ts; An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, + An_index_signature_parameter_type_must_be_string_number_or_an_enum_type: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string', 'number', or an enum type." }, A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: ts.DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: ts.DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, A_class_can_only_extend_a_single_class: { code: 1026, category: ts.DiagnosticCategory.Error, key: "A class can only extend a single class." }, @@ -1809,6 +1817,12 @@ var ts; Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." }, + Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, + Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -1837,8 +1851,8 @@ var ts; Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible." }, Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures are incompatible." }, + Missing_0_index_signature_in_type_1: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Missing {0} index signature in type '{1}'." }, + Index_signatures_0_and_1_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index signatures '{0}' and '{1}' are incompatible." }, this_cannot_be_referenced_in_a_module_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a module body." }, this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, @@ -1913,9 +1927,9 @@ var ts; Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" }, All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, + Property_0_of_type_1_is_not_assignable_to_string_index_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index '{2}'." }, + Property_0_of_type_1_is_not_assignable_to_numeric_index_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index '{2}'." }, + Numeric_index_0_is_not_assignable_to_string_index_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric index '{0}' is not assignable to string index '{1}'." }, Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class name cannot be '{0}'" }, Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class '{0}' incorrectly extends base class '{1}'." }, Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, @@ -6995,6 +7009,7 @@ var ts; function tryParse(callback) { return speculationHelper(callback, false); } + // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { if (token === 65 /* Identifier */) { return true; @@ -7004,7 +7019,7 @@ var ts; if (token === 111 /* YieldKeyword */ && inYieldContext()) { return false; } - return inStrictModeContext() ? token > 111 /* LastFutureReservedWord */ : token > 101 /* LastReservedWord */; + return token > 101 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage) { if (token === kind) { @@ -7108,6 +7123,10 @@ var ts; identifierCount++; if (isIdentifier) { var node = createNode(65 /* Identifier */); + // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker + if (token !== 65 /* Identifier */) { + node.originalKeywordKind = token; + } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); @@ -9823,6 +9842,17 @@ var ts; node.body = parseFunctionBlockOrSemicolon(false); return finishNode(node); } + function isClassMemberModifier(idToken) { + switch (idToken) { + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 110 /* StaticKeyword */: + return true; + default: + return false; + } + } function isClassMemberStart() { var idToken; if (token === 52 /* AtToken */) { @@ -9831,6 +9861,15 @@ var ts; // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. while (ts.isModifier(token)) { idToken = token; + // If the idToken is a class modifier (protected, private, public, and static), it is + // certain that we are starting to parse class member. This allows better error recovery + // Example: + // public foo() ... // true + // public @dec blah ... // true; we will then report an error later + // export public ... // true; we will then report an error later + if (isClassMemberModifier(idToken)) { + return true; + } nextToken(); } if (token === 35 /* AsteriskToken */) { @@ -10528,6 +10567,8 @@ var ts; var nextSymbolId = 1; var nextNodeId = 1; var nextMergeId = 1; + // TODO: LKG and replace [x: IndexKind] + // @internal function getNodeId(node) { if (!node.id) node.id = nextNodeId++; @@ -10568,7 +10609,7 @@ var ts; getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: getIndexTypeOfType, + getIndexTypeOfType: getIndexValueOfType, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, @@ -10614,7 +10655,9 @@ var ts; var globalFunctionType; var globalArrayType; var globalStringType; + var globalStringSubsetType; var globalNumberType; + var globalNumberSubsetType; var globalBooleanType; var globalRegExpType; var globalTemplateStringsArrayType; @@ -11465,6 +11508,19 @@ var ts; type.symbol = symbol; return type; } + function cloneInterfaceType(type, flags) { + var cloneType = createType(type.flags); + cloneType.symbol = type.symbol; + cloneType.flags |= flags; + cloneType.baseTypes = type.baseTypes; + cloneType.declaredCallSignatures = type.declaredCallSignatures; + cloneType.declaredConstructSignatures = type.declaredCallSignatures; + cloneType.declaredNumberIndex = type.declaredNumberIndex; + cloneType.declaredStringIndex = type.declaredStringIndex; + cloneType.declaredProperties = type.declaredProperties; + cloneType.typeParameters = type.typeParameters; + return cloneType; + } // A reserved member name starts with two underscores, but the third character cannot be an underscore // or the @ symbol. A third underscore indicates an escaped form of an identifer that started // with at least two underscores. The @ character indicates that the name is denoted by a well known ES @@ -11491,19 +11547,27 @@ var ts; } return result || emptyArray; } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex) { type.members = members; type.properties = getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexType) - type.stringIndexType = stringIndexType; - if (numberIndexType) - type.numberIndexType = numberIndexType; + if (stringIndex) + type.stringIndex = stringIndex; + if (numberIndex) + type.numberIndex = numberIndex; + if (stringIndex && numberIndex) { + if (numberIndex.inherited && (numberIndex.inherited === stringIndex.inherited)) { + type.alphaNumericIndex = ts.IndexAlphaNumeric.INHERITED; + } + else { + type.alphaNumericIndex = ts.IndexAlphaNumeric.YES; + } + } return type; } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(32768 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndex, numberIndex) { + return setObjectTypeMembers(createObjectType(32768 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndex, numberIndex); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -11761,6 +11825,10 @@ var ts; } return result; } + function indexTypeToString(type) { + var index = type.typeOfIndex || ((type.kind === 0 /* String */) ? stringType : numberType); + return '[' + typeToString(index) + ']: ' + typeToString(type.typeOfValue); + } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; @@ -11987,7 +12055,8 @@ var ts; buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } function getIndexerParameterName(type, indexKind, fallbackName) { - var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + var indexMap = getDeclaredIndexTypesOfSymbol(type.symbol); + var declaration = indexMap[indexKind] ? indexMap[indexKind].declaredNode : null; if (!declaration) { // declaration might not be found if indexer was added from the contextual type. // in this case use fallback name @@ -11998,7 +12067,7 @@ var ts; } function writeLiteralType(type, flags) { var resolved = resolveObjectOrUnionTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.properties.length && !resolved.stringIndex && !resolved.numberIndex) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, 14 /* OpenBraceToken */); writePunctuation(writer, 15 /* CloseBraceToken */); @@ -12044,34 +12113,30 @@ var ts; writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } - if (resolved.stringIndexType) { - // [x: string]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); - writePunctuation(writer, 51 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, 121 /* StringKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 51 /* ColonToken */); - writeSpace(writer); - writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); - writer.writeLine(); - } - if (resolved.numberIndexType) { - // [x: number]: + function writeIndexType(indexType) { + if (!indexType) { + return; + } writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); + writer.writeParameter(getIndexerParameterName(resolved, indexType.kind, "x")); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 119 /* NumberKeyword */); + if (indexType.typeOfIndex && (indexType.typeOfIndex.flags & 2097152 /* Subset */)) { + writeType(indexType.typeOfIndex, 0 /* None */); + writer.writeStringLiteral(indexType.kind === 0 /* String */ ? " < string" : " < number"); + } + else { + writeKeyword(writer, indexType.kind === 0 /* String */ ? 121 /* StringKeyword */ : 119 /* NumberKeyword */); + } writePunctuation(writer, 19 /* CloseBracketToken */); writePunctuation(writer, 51 /* ColonToken */); writeSpace(writer); - writeType(resolved.numberIndexType, 0 /* None */); + writeType(indexType.typeOfValue, 0 /* None */); writePunctuation(writer, 22 /* SemicolonToken */); writer.writeLine(); } + writeIndexType(resolved.stringIndex); + writeIndexType(resolved.numberIndex); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -12419,8 +12484,8 @@ var ts; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. type = getTypeOfPropertyOfType(parentType, name_5.text) || - isNumericLiteralName(name_5.text) && getIndexTypeOfType(parentType, 1 /* Number */) || - getIndexTypeOfType(parentType, 0 /* String */); + isNumericLiteralName(name_5.text) && getIndexValueOfType(parentType, 1 /* Number */) || + getIndexValueOfType(parentType, 0 /* String */); if (!type) { error(name_5, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_5)); return unknownType; @@ -12826,8 +12891,9 @@ var ts; type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = emptyArray; type.declaredConstructSignatures = emptyArray; - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + var indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + type.declaredStringIndex = indexTypes[0 /* String */]; + type.declaredNumberIndex = indexTypes[1 /* Number */]; } return links.declaredType; } @@ -12868,8 +12934,9 @@ var ts; type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + var indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + type.declaredStringIndex = indexTypes[0 /* String */]; + type.declaredNumberIndex = indexTypes[1 /* Number */]; } return links.declaredType; } @@ -12893,7 +12960,7 @@ var ts; function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(128 /* Enum */); + var type = createType(128 /* Enum */ | 2097152 /* Subset */); type.symbol = symbol; links.declaredType = type; } @@ -12972,23 +13039,55 @@ var ts; } } } + function createNumberIndex(value, index) { + return createIndexType(1 /* Number */, value, index); + } + function createStringIndex(value, index) { + return createIndexType(0 /* String */, value, index); + } + function createIndexType(kind, value, index) { + var indexType = { + kind: kind, + typeOfValue: value + }; + if (index) { + indexType.typeOfIndex = index; + } + return indexType; + } + function getInheritedIndexFrom(baseType) { + var resolved = resolveObjectOrUnionType(baseType); + var index = [ + resolved.stringIndex, + resolved.numberIndex + ]; + for (var i in index) { + if (index[i]) { + index[i].inherited = baseType.symbol; + } + } + return index; + } function resolveClassOrInterfaceMembers(type) { var members = type.symbol.members; var callSignatures = type.declaredCallSignatures; var constructSignatures = type.declaredConstructSignatures; - var stringIndexType = type.declaredStringIndexType; - var numberIndexType = type.declaredNumberIndexType; - if (type.baseTypes.length) { + var stringIndex = type.declaredStringIndex; + var numberIndex = type.declaredNumberIndex; + if (type.baseTypes && type.baseTypes.length) { members = createSymbolTable(type.declaredProperties); ts.forEach(type.baseTypes, function (baseType) { addInheritedMembers(members, getPropertiesOfObjectType(baseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1 /* Number */); + if (!stringIndex || !numberIndex) { + var index = getInheritedIndexFrom(baseType); + stringIndex = stringIndex || index[0 /* String */]; + numberIndex = numberIndex || index[1 /* Number */]; + } }); } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function resolveTypeReferenceMembers(type) { var target = type.target; @@ -12996,17 +13095,20 @@ var ts; var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; + var stringIndex = target.declaredStringIndex ? instantiateIndexType(target.declaredStringIndex, mapper) : undefined; + var numberIndex = target.declaredNumberIndex ? instantiateIndexType(target.declaredNumberIndex, mapper) : undefined; ts.forEach(target.baseTypes, function (baseType) { var instantiatedBaseType = instantiateType(baseType, mapper); addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); + if (!stringIndex || !numberIndex) { + var index = getInheritedIndexFrom(instantiatedBaseType); + stringIndex = stringIndex || index[0 /* String */]; + numberIndex = numberIndex || index[1 /* Number */]; + } }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); @@ -13049,7 +13151,7 @@ var ts; var arrayType = resolveObjectOrUnionTypeMembers(createArrayType(getUnionType(type.elementTypes))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); + setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndex, arrayType.numberIndex); } function signatureListsIdentical(s, t) { if (s.length !== t.length) { @@ -13092,7 +13194,7 @@ var ts; var indexTypes = []; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - var indexType = getIndexTypeOfType(type, kind); + var indexType = getIndexValueOfType(type, kind); if (!indexType) { return undefined; } @@ -13107,21 +13209,21 @@ var ts; var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); var stringIndexType = getUnionIndexType(type.types, 0 /* String */); var numberIndexType = getUnionIndexType(type.types, 1 /* Number */); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType ? createStringIndex(stringIndexType) : undefined, numberIndexType ? createNumberIndex(numberIndexType) : undefined); } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; var members; var callSignatures; var constructSignatures; - var stringIndexType; - var numberIndexType; + var stringIndex; + var numberIndex; if (symbol.flags & 2048 /* TypeLiteral */) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); - stringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - numberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + stringIndex = getIndexTypeOfSymbol(symbol, 0 /* String */); + numberIndex = getIndexTypeOfSymbol(symbol, 1 /* Number */); } else { // Combinations of function, class, enum and module @@ -13145,10 +13247,11 @@ var ts; addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(classType.baseTypes[0].symbol))); } } - stringIndexType = undefined; - numberIndexType = (symbol.flags & 384 /* Enum */) ? stringType : undefined; + stringIndex = undefined; + // { kind: SymbolDisplayPartKind[kind] }, ideally typed to SetOf_Names + numberIndex = (symbol.flags & 384 /* Enum */) ? createNumberIndex(stringType) : undefined; } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function resolveObjectOrUnionTypeMembers(type) { if (!type.members) { @@ -13219,10 +13322,20 @@ var ts; } } if (type.flags & 258 /* StringLike */) { - type = globalStringType; + if (type.flags & 2097152 /* Subset */) { + type = globalStringSubsetType; + } + else { + type = globalStringType; + } } else if (type.flags & 132 /* NumberLike */) { - type = globalNumberType; + if (type.flags & 2097152 /* Subset */) { + type = globalNumberSubsetType; + } + else { + type = globalNumberType; + } } else if (type.flags & 8 /* Boolean */) { type = globalBooleanType; @@ -13325,17 +13438,37 @@ var ts; } return false; } - function getIndexTypeOfObjectOrUnionType(type, kind) { + function resolveObjectOrUnionType(type) { + if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { + return resolveObjectOrUnionTypeMembers(type); + } + } + function getIndexOfObjectOrUnionType(type) { if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { var resolved = resolveObjectOrUnionTypeMembers(type); - return kind === 0 /* String */ ? resolved.stringIndexType : resolved.numberIndexType; + return [ + resolved.stringIndex, + resolved.numberIndex + ]; } } + function getIndexTypeOfObjectOrUnionType(type, kind) { + var indexMap = getIndexOfObjectOrUnionType(type); + return indexMap ? indexMap[kind] : undefined; + } + function getIndexValueOfObjectOrUnionType(type, kind) { + var indexType = getIndexTypeOfObjectOrUnionType(type, kind); + return indexType ? indexType.typeOfValue : undefined; + } // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. - function getIndexTypeOfType(type, kind) { + function getIndexOfType(type, kind) { return getIndexTypeOfObjectOrUnionType(getApparentType(type), kind); } + function getIndexValueOfType(type, kind) { + var indexType = getIndexOfType(type, kind); + return indexType ? indexType.typeOfValue : undefined; + } // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). function getTypeParametersFromDeclaration(typeParameterDeclarations) { @@ -13512,29 +13645,44 @@ var ts; function getIndexSymbol(symbol) { return symbol.members["__index"]; } - function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 119 /* NumberKeyword */ : 121 /* StringKeyword */; + function getDeclaredIndexTypesOfSymbol(symbol) { + var indexMap = []; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { - var len = indexSymbol.declarations.length; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var node = decl; - if (node.parameters.length === 1) { - var parameter = node.parameters[0]; - if (parameter && parameter.type && parameter.type.kind === syntaxKind) { - return node; + if (decl.parameters.length === 1) { + var type = getTypeFromIndexSignatureParameter(decl.parameters[0]); + if (!type) { + continue; + } + var kind = (type.flags & 132 /* NumberLike */) ? 1 /* Number */ : (type.flags & 2 /* String */) ? 0 /* String */ : null; + if (kind !== null) { + if (indexMap[kind]) { + indexMap[kind].declaredCount++; + } + else { + indexMap[kind] = { + kind: kind, + typeOfIndex: type, + typeOfValue: decl.type ? getTypeFromTypeNodeOrHeritageClauseElement(decl.type) : anyType, + declaredNode: decl, + declaredCount: 1 + }; + } } } } } - return undefined; + return indexMap; } function getIndexTypeOfSymbol(symbol, kind) { - var declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration - ? declaration.type ? getTypeFromTypeNodeOrHeritageClauseElement(declaration.type) : anyType - : undefined; + var indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + return indexTypes[kind]; + } + function getIndexValueOfSymbol(symbol, kind) { + var info = getIndexTypeOfSymbol(symbol, kind); + return info ? info.typeOfValue : undefined; } function getConstraintOfTypeParameter(type) { if (!type.constraint) { @@ -14045,14 +14193,17 @@ var ts; result.members = createSymbolTable(result.properties); result.callSignatures = instantiateList(getSignaturesOfType(type, 0 /* Call */), mapper, instantiateSignature); result.constructSignatures = instantiateList(getSignaturesOfType(type, 1 /* Construct */), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); + var stringIndex = getIndexOfType(type, 0 /* String */); + var numberIndex = getIndexOfType(type, 1 /* Number */); + if (stringIndex) + result.stringIndex = instantiateIndexType(stringIndex, mapper); + if (numberIndex) + result.numberIndex = instantiateIndexType(numberIndex, mapper); return result; } + function instantiateIndexType(index, mapper) { + return createIndexType(index.kind, instantiateType(index.typeOfValue, mapper), index.typeOfIndex); + } function instantiateType(type, mapper) { if (mapper !== identityMapper) { if (type.flags & 512 /* TypeParameter */) { @@ -14245,6 +14396,8 @@ var ts; } } else { + if ((source.flags & 2097152 /* Subset */) && (target.flags & 2097152 /* Subset */)) { + } var saveErrorInfo = errorInfo; if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if relationship holds for all type arguments @@ -14406,10 +14559,7 @@ var ts; if (result) { result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportErrors); if (result) { - result &= stringIndexTypesRelatedTo(source, target, reportErrors); - if (result) { - result &= numberIndexTypesRelatedTo(source, target, reportErrors); - } + result &= indexRelatedTo(source, target, reportErrors); } } } @@ -14651,72 +14801,83 @@ var ts; } return result; } - function stringIndexTypesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(0 /* String */, source, target); - } - var targetType = getIndexTypeOfType(target, 0 /* String */); - if (targetType) { - var sourceType = getIndexTypeOfType(source, 0 /* String */); - if (!sourceType) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0 /* False */; + function indexRelatedTo(source, target, reportErrors) { + var sourceIndex = getIndexOfObjectOrUnionType(source); + var targetIndex = getIndexOfObjectOrUnionType(target); + var sourceType = source; + var targetType = target; + return stringIndexRelatedTo(sourceIndex[0 /* String */], targetIndex[0 /* String */]) && + numberIndexRelatedTo(sourceIndex, targetIndex[1 /* Number */]); + function stringIndexRelatedTo(source, target) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(source, target, stringType); } - var related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); + if (target) { + if (!source) { + if (reportErrors) { + reportError(ts.Diagnostics.Missing_0_index_signature_in_type_1, "[string]", typeToString(sourceType)); + } + return 0 /* False */; } - return 0 /* False */; - } - return related; - } - return -1 /* True */; - } - function numberIndexTypesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(1 /* Number */, source, target); - } - var targetType = getIndexTypeOfType(target, 1 /* Number */); - if (targetType) { - var sourceStringType = getIndexTypeOfType(source, 0 /* String */); - var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + var related = indexTypesRelatedTo(source, target, stringType); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_0_and_1_are_incompatible, indexTypeToString(source), indexTypeToString(target)); + } + return 0 /* False */; } - return 0 /* False */; - } - var related; - if (sourceStringType && sourceNumberType) { - // If we know for sure we're testing both string and numeric index types then only report errors from the second one - related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); + return related; } - else { - related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); + return -1 /* True */; + } + function numberIndexRelatedTo(source, targetNumberIndex) { + var sourceNumberIndex = source[1 /* Number */]; + if (relation === identityRelation) { + return indexTypesIdenticalTo(sourceNumberIndex, targetNumberIndex, numberType); } - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); + if (targetNumberIndex) { + var sourceStringIndex = source[0 /* String */]; + if (!sourceStringIndex && !sourceNumberIndex) { + if (reportErrors) { + reportError(ts.Diagnostics.Missing_0_index_signature_in_type_1, "[string] or [number]", typeToString(sourceType)); + } + return 0 /* False */; } - return 0 /* False */; + var related; + var sourceError = sourceNumberIndex; + if (sourceStringIndex && sourceNumberIndex) { + // If we know for sure we're testing both string and numeric index types then only report errors from the second one + related = isRelatedTo(sourceStringIndex.typeOfValue, targetNumberIndex.typeOfValue, false) || indexTypesRelatedTo(sourceNumberIndex, targetNumberIndex, numberType); + } + else if (sourceStringIndex) { + related = isRelatedTo(sourceStringIndex.typeOfValue, targetNumberIndex.typeOfValue); + sourceError = sourceStringIndex; + } + else if (sourceNumberIndex) { + related = indexTypesRelatedTo(sourceNumberIndex, targetNumberIndex, numberType); + } + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Index_signatures_0_and_1_are_incompatible, indexTypeToString(sourceError), indexTypeToString(targetNumberIndex)); + } + return 0 /* False */; + } + return related; } - return related; - } - return -1 /* True */; - } - function indexTypesIdenticalTo(indexKind, source, target) { - var targetType = getIndexTypeOfType(target, indexKind); - var sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { return -1 /* True */; } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); + function indexTypesRelatedTo(sourceIndex, targetIndex, defaultIndex) { + return isRelatedTo(sourceIndex.typeOfIndex || defaultIndex, targetIndex.typeOfIndex || defaultIndex, reportErrors) && isRelatedTo(sourceIndex.typeOfValue, targetIndex.typeOfValue, reportErrors); + } + function indexTypesIdenticalTo(sourceIndex, targetIndex, defaultIndex) { + if (!sourceIndex && !targetIndex) { + return -1 /* True */; + } + if (sourceIndex && targetIndex) { + return indexTypesRelatedTo(sourceIndex, targetIndex, defaultIndex); + } + return 0 /* False */; } - return 0 /* False */; } } function isPropertyIdenticalTo(sourceProp, targetProp) { @@ -14868,13 +15029,13 @@ var ts; } members[p.name] = p; }); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + var stringIndex = getIndexOfType(type, 0 /* String */); + var numberIndex = getIndexOfType(type, 1 /* Number */); + if (stringIndex) + stringIndex = createStringIndex(getWidenedType(stringIndex.typeOfValue)); + if (numberIndex) + numberIndex = createNumberIndex(getWidenedType(numberIndex.typeOfValue)); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndex, numberIndex); } function getWidenedType(type) { if (type.flags & 786432 /* RequiresWidening */) { @@ -15139,9 +15300,9 @@ var ts; inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } function inferFromIndexTypes(source, target, sourceKind, targetKind) { - var targetIndexType = getIndexTypeOfType(target, targetKind); + var targetIndexType = getIndexValueOfType(target, targetKind); if (targetIndexType) { - var sourceIndexType = getIndexTypeOfType(source, sourceKind); + var sourceIndexType = getIndexValueOfType(source, sourceKind); if (sourceIndexType) { inferFromTypes(sourceIndexType, targetIndexType); } @@ -15881,7 +16042,7 @@ var ts; }); } function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }); + return applyToContextualType(type, function (t) { return getIndexValueOfObjectOrUnionType(t, kind); }); } // Return true if the given contextual type is a tuple-like type function contextualTypeIsTupleLikeType(type) { @@ -15889,7 +16050,7 @@ var ts; } // Return true if the given contextual type provides an index signature of the given kind function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }) : getIndexTypeOfObjectOrUnionType(type, kind)); + return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexValueOfObjectOrUnionType(t, kind); }) : getIndexValueOfObjectOrUnionType(type, kind)); } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one @@ -16205,7 +16366,7 @@ var ts; } var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType ? createStringIndex(stringIndexType) : undefined, numberIndexType ? createNumberIndex(numberIndexType) : undefined); result.flags |= 131072 /* ObjectLiteral */ | 524288 /* ContainsObjectLiteral */ | (typeFlags & 262144 /* ContainsUndefinedOrNull */); return result; function getIndexType(kind) { @@ -16393,13 +16554,13 @@ var ts; if (allConstituentTypesHaveKind(indexType, 1 /* Any */ | 258 /* StringLike */ | 132 /* NumberLike */ | 1048576 /* ESSymbol */)) { // Try to use a number indexer. if (allConstituentTypesHaveKind(indexType, 1 /* Any */ | 132 /* NumberLike */)) { - var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); + var numberIndexType = getIndexValueOfType(objectType, 1 /* Number */); if (numberIndexType) { return numberIndexType; } } // Try to use string indexing. - var stringIndexType = getIndexTypeOfType(objectType, 0 /* String */); + var stringIndexType = getIndexValueOfType(objectType, 0 /* String */); if (stringIndexType) { return stringIndexType; } @@ -16612,7 +16773,7 @@ var ts; if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { + resolved.properties.length === 0 && !resolved.stringIndex && !resolved.numberIndex) { return resolved.callSignatures[0]; } } @@ -17230,7 +17391,7 @@ var ts; function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { ts.Debug.assert(node.kind !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking - var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node); if (!hasGrammarError && node.kind === 162 /* FunctionExpression */) { checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); } @@ -17272,7 +17433,7 @@ var ts; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { ts.Debug.assert(node.kind !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - if (node.type) { + if (node.type && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type)); } if (node.body) { @@ -17507,8 +17668,8 @@ var ts; var name_8 = p.name; var type = sourceType.flags & 1 /* Any */ ? sourceType : getTypeOfPropertyOfType(sourceType, name_8.text) || - isNumericLiteralName(name_8.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || - getIndexTypeOfType(sourceType, 0 /* String */); + isNumericLiteralName(name_8.text) && getIndexValueOfType(sourceType, 1 /* Number */) || + getIndexValueOfType(sourceType, 0 /* String */); if (type) { checkDestructuringAssignment(p.initializer || name_8, type); } @@ -17834,6 +17995,7 @@ var ts; return type; } function checkExpression(node, contextualMapper) { + checkGrammarIdentifierInStrictMode(node); return checkExpressionOrQualifiedName(node, contextualMapper); } // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When @@ -17941,6 +18103,7 @@ var ts; } // DECLARATION AND STATEMENT TYPE CHECKING function checkTypeParameter(node) { + checkGrammarDeclarationNameInStrictMode(node); // Grammar Checking if (node.expression) { grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); @@ -18020,32 +18183,29 @@ var ts; // TypeScript 1.0 spec (April 2014) // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration - var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { - var seenNumericIndexer = false; - var seenStringIndexer = false; + var symbol = getSymbolOfNode(node); + var indexMap = getDeclaredIndexTypesOfSymbol(symbol); + var stringIndex = indexMap[0 /* String */]; + var numberIndex = indexMap[1 /* Number */]; + if (stringIndex && stringIndex.declaredCount > 1) { + errorDuplicateIndex(getIndexSymbol(symbol), stringIndex); + } + if (numberIndex && numberIndex.declaredCount > 1) { + errorDuplicateIndex(getIndexSymbol(symbol), numberIndex); + } + function errorDuplicateIndex(indexSymbol, indexType) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var declaration = decl; - if (declaration.parameters.length === 1 && declaration.parameters[0].type) { - switch (declaration.parameters[0].type.kind) { - case 121 /* StringKeyword */: - if (!seenStringIndexer) { - seenStringIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_string_index_signature); - } - break; - case 119 /* NumberKeyword */: - if (!seenNumericIndexer) { - seenNumericIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_number_index_signature); - } - break; - } + if (declaration.parameters.length !== 1 || declaration === indexType.declaredNode) { + continue; + } + var type = getTypeFromIndexSignatureParameter(declaration.parameters[0]); + if (type.flags & 2 /* String */ && indexType.kind === 0 /* String */) { + error(declaration, ts.Diagnostics.Duplicate_string_index_signature); + } + else if (type.flags & 132 /* NumberLike */ && indexType.kind === 1 /* Number */) { + error(declaration, ts.Diagnostics.Duplicate_number_index_signature); } } } @@ -18172,9 +18332,11 @@ var ts; checkDecorators(node); } function checkTypeReferenceNode(node) { + checkGrammarTypeReferenceInStrictMode(node.typeName); return checkTypeReferenceOrHeritageClauseElement(node); } function checkHeritageClauseElement(node) { + checkGrammarHeritageClauseElementInStrictMode(node.expression); return checkTypeReferenceOrHeritageClauseElement(node); } function checkTypeReferenceOrHeritageClauseElement(node) { @@ -18648,6 +18810,7 @@ var ts; } } function checkFunctionLikeDeclaration(node) { + checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSignatureDeclaration(node); // Do not use hasDynamicName here, because that returns false for well known symbols. @@ -18678,7 +18841,7 @@ var ts; } } checkSourceElement(node.body); - if (node.type && !isAccessor(node.kind)) { + if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type)); } // Report an implicit any error if there is no body, no explicit return type, and node is not a private method @@ -18891,6 +19054,7 @@ var ts; } // Check variable, parameter, or property declaration function checkVariableLikeDeclaration(node) { + checkGrammarDeclarationNameInStrictMode(node); checkDecorators(node); checkSourceElement(node.type); // For a computed property, just check the initializer and exit @@ -19120,7 +19284,7 @@ var ts; return checkElementTypeOfArrayOrString(inputType, errorNode); } if (isArrayLikeType(inputType)) { - return getIndexTypeOfType(inputType, 1 /* Number */); + return getIndexValueOfType(inputType, 1 /* Number */); } error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); return unknownType; @@ -19259,7 +19423,7 @@ var ts; } return hasStringConstituent ? stringType : unknownType; } - var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */) || unknownType; + var arrayElementType = getIndexValueOfType(arrayType, 1 /* Number */) || unknownType; if (hasStringConstituent) { // This is just an optimization for the case where arrayOrStringType is string | string[] if (arrayElementType.flags & 258 /* StringLike */) { @@ -19417,49 +19581,62 @@ var ts; } } function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType || numberIndexType) { - ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); - checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); - checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); - }); - if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 201 /* ClassDeclaration */) { - var classDeclaration = type.symbol.valueDeclaration; - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; - // Only process instance properties with computed names here. - // Static properties cannot be in conflict with indexers, - // and properties with literal names were already checked. - if (!(member.flags & 128 /* Static */) && ts.hasDynamicName(member)) { - var propType = getTypeOfSymbol(member.symbol); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); - } - } - } + var resolved = resolveObjectOrUnionType(type); + if (!resolved) { + return; } - var errorNode; - if (stringIndexType && numberIndexType) { - errorNode = declaredNumberIndexer || declaredStringIndexer; - // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer - if (!errorNode && (type.flags & 2048 /* Interface */)) { - var someBaseTypeHasBothIndexers = ts.forEach(type.baseTypes, function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + var stringIndex = resolved.stringIndex || createStringIndex(null); + var numberIndex = resolved.numberIndex || createNumberIndex(null); + var alphaNumeric = resolved.alphaNumericIndex; + if (!stringIndex.typeOfValue && !numberIndex.typeOfValue) { + return; + } + var containingNode = type.symbol.declarations[type.symbol.declarations.length - 1]; + var errorNode = containingNode; + var checkIndexNodes = [numberIndex.declaredNode, stringIndex.declaredNode]; + for (var _i = 0; _i < checkIndexNodes.length; _i++) { + var node = checkIndexNodes[_i]; + // Use index declaration as error node if contained in the class/interface + if (node && node.parent === containingNode) { + errorNode = node; + break; } } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { - error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); + // Don't check number index if not assignable + var checkNumberIndex = numberIndex; + if (alphaNumeric === ts.IndexAlphaNumeric.YES && !isTypeAssignableTo(numberIndex.typeOfValue, stringIndex.typeOfValue)) { + error(errorNode, ts.Diagnostics.Numeric_index_0_is_not_assignable_to_string_index_1, indexTypeToString(numberIndex), indexTypeToString(stringIndex)); + checkNumberIndex = null; } - function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { - if (!indexType) { + ts.forEach(getPropertiesOfObjectType(type), function (prop) { + var propType = getTypeOfSymbol(prop); + checkIndexConstraintForProperty(prop, propType, type, stringIndex, alphaNumeric); + if (checkNumberIndex) { + checkIndexConstraintForProperty(prop, propType, type, numberIndex, alphaNumeric); + } + }); + if (type.flags & 1024 /* Class */ && type.symbol.valueDeclaration.kind === 201 /* ClassDeclaration */) { + var classDeclaration = type.symbol.valueDeclaration; + for (var _a = 0, _b = classDeclaration.members; _a < _b.length; _a++) { + var member = _b[_a]; + // Only process instance properties with computed names here. + // Static properties cannot be in conflict with indexers, + // and properties with literal names were already checked. + if (!(member.flags & 128 /* Static */) && ts.hasDynamicName(member)) { + var propType = getTypeOfSymbol(member.symbol); + checkIndexConstraintForProperty(member.symbol, propType, type, stringIndex, alphaNumeric); + if (checkNumberIndex) { + checkIndexConstraintForProperty(member.symbol, propType, type, numberIndex, alphaNumeric); + } + } + } + } + function checkIndexConstraintForProperty(prop, propertyType, containingType, indexType, alphaNumeric) { + if (!indexType.typeOfValue) { return; } // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !isNumericName(prop.valueDeclaration.name)) { + if (indexType.kind === 1 /* Number */ && !isNumericName(prop.valueDeclaration.name)) { return; } // perform property check if property or indexer is declared in 'type' @@ -19468,21 +19645,22 @@ var ts; if (prop.valueDeclaration.name.kind === 127 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } - else if (indexDeclaration) { - errorNode = indexDeclaration; - } - else if (containingType.flags & 2048 /* Interface */) { - // for interfaces property and indexer might be inherited from different bases - // check if any base class already has both property and indexer. - // check should be performed only if 'type' is the first type that brings property\indexer together - var someBaseClassHasBothPropertyAndIndexer = ts.forEach(containingType.baseTypes, function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + else if (indexType.declaredNode) { + errorNode = indexType.declaredNode; + var containingNode_1 = containingType.symbol.declarations[containingType.symbol.declarations.length - 1]; + if (errorNode.parent !== containingNode_1) { + errorNode = containingNode_1; + } + if (alphaNumeric === ts.IndexAlphaNumeric.INHERITED) { + // inherited node will report error instead + errorNode = undefined; + } } - if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { - var errorMessage = indexKind === 0 /* String */ - ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 - : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); + if (errorNode && !isTypeAssignableTo(propertyType, indexType.typeOfValue)) { + var errorMessage = indexType.kind === 0 /* String */ + ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_2 + : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_2; + error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), indexTypeToString(indexType)); } } } @@ -19521,6 +19699,7 @@ var ts; return unknownType; } function checkClassDeclaration(node) { + checkGrammarDeclarationNameInStrictMode(node); // Grammar checking if (node.parent.kind !== 206 /* ModuleBlock */ && node.parent.kind !== 227 /* SourceFile */) { grammarErrorOnNode(node, ts.Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration); @@ -19721,7 +19900,7 @@ var ts; } function checkInterfaceDeclaration(node) { // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); + checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); @@ -19921,7 +20100,7 @@ var ts; return; } // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -19983,7 +20162,7 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { + if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } @@ -20078,7 +20257,7 @@ var ts; checkAliasSymbol(node); } function checkImportDeclaration(node) { - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { + if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -20099,7 +20278,7 @@ var ts; } } function checkImportEqualsDeclaration(node) { - checkGrammarDecorators(node) || checkGrammarModifiers(node); + checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); if (node.flags & 1 /* Export */) { @@ -20418,6 +20597,8 @@ var ts; // Grammar checking checkGrammarSourceFile(node); emitExtends = false; + emitDecorate = false; + emitParam = false; potentialThisCollisions.length = 0; ts.forEach(node.statements, checkSourceElement); checkFunctionExpressionBodies(node); @@ -21319,7 +21500,9 @@ var ts; globalObjectType = getGlobalType("Object"); globalFunctionType = getGlobalType("Function"); globalStringType = getGlobalType("String"); + globalStringSubsetType = cloneInterfaceType(globalStringType, 2097152 /* Subset */); globalNumberType = getGlobalType("Number"); + globalNumberSubsetType = cloneInterfaceType(globalNumberType, 2097152 /* Subset */); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); @@ -21346,6 +21529,137 @@ var ts; anyArrayType = createArrayType(anyType); } // GRAMMAR CHECKING + function isReservedwordInStrictMode(node) { + // Check that originalKeywordKind is less than LastFurtureReservedWord to see if an Identifier is a strict-mode reserved word + return (node.parserContextFlags & 1 /* StrictMode */) && + (node.originalKeywordKind >= 103 /* FirstFutureReservedWord */ && node.originalKeywordKind <= 111 /* LastFutureReservedWord */); + } + function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) { + // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.) + // if so, we would like to give more explicit invalid usage error. + if (ts.getAncestor(identifier, 201 /* ClassDeclaration */) || ts.getAncestor(identifier, 174 /* ClassExpression */)) { + return grammarErrorOnNode(identifier, message, arg0); + } + return false; + } + function checkGrammarImportDeclarationNameInStrictMode(node) { + // Check if the import declaration used strict-mode reserved word in its names bindings + if (node.importClause) { + var impotClause = node.importClause; + if (impotClause.namedBindings) { + var nameBindings = impotClause.namedBindings; + if (nameBindings.kind === 211 /* NamespaceImport */) { + var name_11 = nameBindings.name; + if (name_11.originalKeywordKind) { + var nameText = ts.declarationNameToString(name_11); + return grammarErrorOnNode(name_11, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + } + } + else if (nameBindings.kind === 212 /* NamedImports */) { + var reportError = false; + for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) { + var element = _a[_i]; + var name_12 = element.name; + if (name_12.originalKeywordKind) { + var nameText = ts.declarationNameToString(name_12); + reportError = reportError || grammarErrorOnNode(name_12, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + } + } + return reportError; + } + } + } + return false; + } + function checkGrammarDeclarationNameInStrictMode(node) { + var name = node.name; + if (name && name.kind === 65 /* Identifier */ && isReservedwordInStrictMode(name)) { + var nameText = ts.declarationNameToString(name); + switch (node.kind) { + case 129 /* Parameter */: + case 198 /* VariableDeclaration */: + case 200 /* FunctionDeclaration */: + case 128 /* TypeParameter */: + case 152 /* BindingElement */: + case 202 /* InterfaceDeclaration */: + case 203 /* TypeAliasDeclaration */: + case 204 /* EnumDeclaration */: + return checkGrammarIdentifierInStrictMode(name); + case 201 /* ClassDeclaration */: + // Report an error if the class declaration uses strict-mode reserved word. + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText); + case 205 /* ModuleDeclaration */: + // Report an error if the module declaration uses strict-mode reserved word. + // TODO(yuisu): fix this when having external module in strict mode + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + case 208 /* ImportEqualsDeclaration */: + // TODO(yuisu): fix this when having external module in strict mode + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + } + } + return false; + } + function checkGrammarTypeReferenceInStrictMode(typeName) { + // Check if the type reference is using strict mode keyword + // Example: + // class C { + // foo(x: public){} // Error. + // } + if (typeName.kind === 65 /* Identifier */) { + checkGrammarTypeNameInStrictMode(typeName); + } + else if (typeName.kind === 126 /* QualifiedName */) { + // Walk from right to left and report a possible error at each Identifier in QualifiedName + // Example: + // x1: public.private.package // error at public and private + checkGrammarTypeNameInStrictMode(typeName.right); + checkGrammarTypeReferenceInStrictMode(typeName.left); + } + } + // This function will report an error for every identifier in property access expression + // whether it violates strict mode reserved words. + // Example: + // public // error at public + // public.private.package // error at public + // B.private.B // no error + function checkGrammarHeritageClauseElementInStrictMode(expression) { + // Example: + // class C extends public // error at public + if (expression && expression.kind === 65 /* Identifier */) { + return checkGrammarIdentifierInStrictMode(expression); + } + else if (expression && expression.kind === 155 /* PropertyAccessExpression */) { + // Walk from left to right in PropertyAccessExpression until we are at the left most expression + // in PropertyAccessExpression. According to grammar production of MemberExpression, + // the left component expression is a PrimaryExpression (i.e. Identifier) while the other + // component after dots can be IdentifierName. + checkGrammarHeritageClauseElementInStrictMode(expression.expression); + } + } + // The function takes an identifier itself or an expression which has SyntaxKind.Identifier. + function checkGrammarIdentifierInStrictMode(node, nameText) { + if (node && node.kind === 65 /* Identifier */ && isReservedwordInStrictMode(node)) { + if (!nameText) { + nameText = ts.declarationNameToString(node); + } + // TODO (yuisu): Fix when module is a strict mode + var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || + grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); + return errorReport; + } + return false; + } + // The function takes an identifier when uses as a typeName in TypeReferenceNode + function checkGrammarTypeNameInStrictMode(node) { + if (node && node.kind === 65 /* Identifier */ && isReservedwordInStrictMode(node)) { + var nameText = ts.declarationNameToString(node); + // TODO (yuisu): Fix when module is a strict mode + var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) || + grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText); + return errorReport; + } + return false; + } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -21558,6 +21872,23 @@ var ts; } return false; } + function getTypeFromIndexSignatureParameter(parameter) { + if (parameter.type) { + if (parameter.type.kind === 121 /* StringKeyword */) { + return stringType; + } + if (parameter.type.kind === 119 /* NumberKeyword */) { + return numberType; + } + if (parameter.type.kind === 141 /* TypeReference */) { + var type = getTypeFromTypeReference((parameter.type)); + if ((type.flags & 132 /* NumberLike */) || (type.flags & 2 /* String */)) { + return type; + } + } + } + return undefined; + } function checkGrammarIndexSignatureParameters(node) { var parameter = node.parameters[0]; if (node.parameters.length !== 1) { @@ -21583,8 +21914,8 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 121 /* StringKeyword */ && parameter.type.kind !== 119 /* NumberKeyword */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + if (!getTypeFromIndexSignatureParameter(parameter)) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_number_or_an_enum_type); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); @@ -21721,11 +22052,11 @@ var ts; var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_11 = prop.name; + var name_13 = prop.name; if (prop.kind === 175 /* OmittedExpression */ || - name_11.kind === 127 /* ComputedPropertyName */) { + name_13.kind === 127 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_11); + checkGrammarComputedPropertyName(name_13); continue; } // ECMA-262 11.1.5 Object Initialiser @@ -21740,8 +22071,8 @@ var ts; if (prop.kind === 224 /* PropertyAssignment */ || prop.kind === 225 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_11.kind === 7 /* NumericLiteral */) { - checkGrammarNumbericLiteral(name_11); + if (name_13.kind === 7 /* NumericLiteral */) { + checkGrammarNumbericLiteral(name_13); } currentKind = Property; } @@ -21757,26 +22088,26 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_11.text)) { - seen[name_11.text] = currentKind; + if (!ts.hasProperty(seen, name_13.text)) { + seen[name_13.text] = currentKind; } else { - var existingKind = seen[name_11.text]; + var existingKind = seen[name_13.text]; if (currentKind === Property && existingKind === Property) { if (inStrictMode) { - grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); + grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); } } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_11.text] = currentKind | existingKind; + seen[name_13.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -22124,15 +22455,14 @@ var ts; var identifier = name; if (contextNode && (contextNode.parserContextFlags & 1 /* StrictMode */) && ts.isEvalOrArgumentsIdentifier(identifier)) { var nameText = ts.declarationNameToString(identifier); - // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.) - // if so, we would like to give more explicit invalid usage error. - // This will be particularly helpful in the case of "arguments" as such case is very common mistake. - if (ts.getAncestor(name, 201 /* ClassDeclaration */) || ts.getAncestor(name, 174 /* ClassExpression */)) { - return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); - } - else { + // We check first if the name is inside class declaration or class expression; if so give explicit message + // otherwise report generic error message. + // reportGrammarErrorInClassDeclaration only return true if grammar error is successfully reported and false otherwise + var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText); + if (!reportErrorInClassDeclaration) { return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); } + return reportErrorInClassDeclaration; } } } @@ -22631,9 +22961,9 @@ var ts; } var count = 0; while (true) { - var name_12 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_12)) { - return name_12; + var name_14 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_14)) { + return name_14; } } } @@ -23835,9 +24165,9 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_13 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_13)) { - return name_13; + var name_15 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_15)) { + return name_15; } } } @@ -23870,9 +24200,9 @@ var ts; } function generateNameForModuleOrEnum(node) { if (node.name.kind === 65 /* Identifier */) { - var name_14 = node.name.text; + var name_16 = node.name.text; // Use module/enum name itself if it is unique, otherwise make a unique variation - assignGeneratedName(node, isUniqueLocalName(name_14, node) ? name_14 : makeUniqueName(name_14)); + assignGeneratedName(node, isUniqueLocalName(name_16, node) ? name_16 : makeUniqueName(name_16)); } } function generateNameForImportOrExportDeclaration(node) { @@ -24085,8 +24415,8 @@ var ts; // Child scopes are always shown with a dot (even if they have no name), // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. - var name_15 = node.name; - if (!name_15 || name_15.kind !== 127 /* ComputedPropertyName */) { + var name_17 = node.name; + if (!name_17 || name_17.kind !== 127 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -24115,10 +24445,10 @@ var ts; node.kind === 204 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { - var name_16 = node.name; + var name_18 = node.name; // For computed property names, the text will include the brackets - scopeName = name_16.kind === 127 /* ComputedPropertyName */ - ? ts.getTextOfNode(name_16) + scopeName = name_18.kind === 127 /* ComputedPropertyName */ + ? ts.getTextOfNode(name_18) : node.name.text; } recordScopeNameStart(scopeName); @@ -24592,6 +24922,7 @@ var ts; default: return -1 /* LessThan */; } + case 172 /* YieldExpression */: case 170 /* ConditionalExpression */: return -1 /* LessThan */; default: @@ -24779,6 +25110,16 @@ var ts; write("..."); emit(node.expression); } + function emitYieldExpression(node) { + write(ts.tokenToString(111 /* YieldKeyword */)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 65 /* Identifier */: @@ -25037,6 +25378,9 @@ var ts; write("]"); } function emitMethod(node) { + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } emit(node.name, false); if (languageVersion < 2 /* ES6 */) { write(": function "); @@ -26140,12 +26484,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2 /* ES6 */) { if (ts.isBindingPattern(node.name)) { - var name_17 = createTempVariable(0 /* Auto */); + var name_19 = createTempVariable(0 /* Auto */); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_17); - emit(name_17); + tempParameters.push(name_19); + emit(name_19); } else { emit(node.name); @@ -26269,7 +26613,11 @@ var ts; write("default "); } } - write("function "); + write("function"); + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } + write(" "); } if (shouldEmitFunctionName(node)) { emitDeclarationName(node); @@ -26616,6 +26964,9 @@ var ts; else if (member.kind === 137 /* SetAccessor */) { write("set "); } + if (member.asteriskToken) { + write("*"); + } emit(member.name); emitSignatureAndBody(member); emitEnd(member); @@ -27761,8 +28112,8 @@ var ts; // export { x, y } for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_18 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_18] || (exportSpecifiers[name_18] = [])).push(specifier); + var name_20 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_20] || (exportSpecifiers[name_20] = [])).push(specifier); } } break; @@ -28094,6 +28445,8 @@ var ts; return emitConditionalExpression(node); case 173 /* SpreadElementExpression */: return emitSpreadElementExpression(node); + case 172 /* YieldExpression */: + return emitYieldExpression(node); case 175 /* OmittedExpression */: return; case 179 /* Block */: @@ -29753,9 +30106,9 @@ var ts; case 198 /* VariableDeclaration */: case 152 /* BindingElement */: var variableDeclarationNode; - var name_19; + var name_21; if (node.kind === 152 /* BindingElement */) { - name_19 = node.name; + name_21 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration @@ -29767,16 +30120,16 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_19 = node.name; + name_21 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.variableElement); } case 135 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); @@ -32316,9 +32669,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_20 in o) { - if (o[name_20] === rule) { - return name_20; + for (var name_22 in o) { + if (o[name_22] === rule) { + return name_22; } } throw new Error("Unknown rule"); @@ -36528,10 +36881,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameTable = getNameTable(sourceFile); - for (var name_21 in nameTable) { - if (!allNames[name_21]) { - allNames[name_21] = name_21; - var displayName = getCompletionEntryDisplayName(name_21, target, true); + for (var name_23 in nameTable) { + if (!allNames[name_23]) { + allNames[name_23] = name_23; + var displayName = getCompletionEntryDisplayName(name_23, target, true); if (displayName) { var entry = { name: displayName, @@ -37033,6 +37386,9 @@ var ts; if (!node) { return undefined; } + if (isLabelName(node)) { + return undefined; + } var symbol = typeInfoResolver.getSymbolAtLocation(node); if (!symbol) { // Try getting just type at this position and show @@ -38363,19 +38719,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeInfoResolver.getContextualType(objectLiteral); - var name_22 = node.text; + var name_24 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_22); + var unionProperty = contextualType.getProperty(name_24); if (unionProperty) { return [unionProperty]; } else { var result_3 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_22); + var symbol = t.getProperty(name_24); if (symbol) { result_3.push(symbol); } @@ -38384,7 +38740,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_22); + var symbol_1 = contextualType.getProperty(name_24); if (symbol_1) { return [symbol_1]; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bff0c137e24ec..e7c799b5d5c3e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6,6 +6,11 @@ module ts { let nextNodeId = 1; let nextMergeId = 1; + interface IndexTypeMap { + [x: IndexKind]: IndexType + } + + // @internal export function getNodeId(node: Node): number { if (!node.id) node.id = nextNodeId++; return node.id; @@ -53,7 +58,7 @@ module ts { getPropertiesOfType, getPropertyOfType, getSignaturesOfType, - getIndexTypeOfType, + getIndexTypeOfType: getIndexValueOfType, getReturnTypeOfSignature, getSymbolsInScope, getSymbolAtLocation, @@ -106,7 +111,9 @@ module ts { let globalFunctionType: ObjectType; let globalArrayType: ObjectType; let globalStringType: ObjectType; + let globalStringSubsetType: ObjectType; let globalNumberType: ObjectType; + let globalNumberSubsetType: ObjectType; let globalBooleanType: ObjectType; let globalRegExpType: ObjectType; let globalTemplateStringsArrayType: ObjectType; @@ -1013,6 +1020,20 @@ module ts { return type; } + function cloneInterfaceType(type: InterfaceType, flags: TypeFlags): InterfaceType { + let cloneType = createType(type.flags); + cloneType.symbol = type.symbol; + cloneType.flags |= flags; + cloneType.baseTypes = type.baseTypes; + cloneType.declaredCallSignatures = type.declaredCallSignatures; + cloneType.declaredConstructSignatures = type.declaredCallSignatures; + cloneType.declaredNumberIndex = type.declaredNumberIndex; + cloneType.declaredStringIndex = type.declaredStringIndex; + cloneType.declaredProperties = type.declaredProperties; + cloneType.typeParameters = type.typeParameters; + return cloneType; + } + // A reserved member name starts with two underscores, but the third character cannot be an underscore // or the @ symbol. A third underscore indicates an escaped form of an identifer that started // with at least two underscores. The @ character indicates that the name is denoted by a well known ES @@ -1040,19 +1061,28 @@ module ts { return result || emptyArray; } - function setObjectTypeMembers(type: ObjectType, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndexType: Type, numberIndexType: Type): ResolvedType { + function setObjectTypeMembers(type: ObjectType, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndex: IndexType, numberIndex: IndexType): ResolvedType { (type).members = members; (type).properties = getNamedMembers(members); (type).callSignatures = callSignatures; (type).constructSignatures = constructSignatures; - if (stringIndexType) (type).stringIndexType = stringIndexType; - if (numberIndexType) (type).numberIndexType = numberIndexType; + if (stringIndex) (type).stringIndex = stringIndex; + if (numberIndex) (type).numberIndex = numberIndex; + + if (stringIndex && numberIndex) { + if (numberIndex.inherited && (numberIndex.inherited === stringIndex.inherited)) { + (type).alphaNumericIndex = IndexAlphaNumeric.INHERITED; + } else { + (type).alphaNumericIndex = IndexAlphaNumeric.YES; + } + } + return type; } - function createAnonymousType(symbol: Symbol, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndexType: Type, numberIndexType: Type): ResolvedType { + function createAnonymousType(symbol: Symbol, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndex: IndexType, numberIndex: IndexType): ResolvedType { return setObjectTypeMembers(createObjectType(TypeFlags.Anonymous, symbol), - members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + members, callSignatures, constructSignatures, stringIndex, numberIndex); } function forEachSymbolTableInScope(enclosingDeclaration: Node, callback: (symbolTable: SymbolTable) => T): T { @@ -1351,6 +1381,11 @@ module ts { return result; } + function indexTypeToString(type: IndexType): string { + let index = type.typeOfIndex || ((type.kind === IndexKind.String) ? stringType : numberType); + return '[' + typeToString(index) + ']: ' + typeToString(type.typeOfValue); + } + function getTypeAliasForTypeLiteral(type: Type): Symbol { if (type.symbol && type.symbol.flags & SymbolFlags.TypeLiteral) { let node = type.symbol.declarations[0].parent; @@ -1601,7 +1636,8 @@ module ts { } function getIndexerParameterName(type: ObjectType, indexKind: IndexKind, fallbackName: string): string { - let declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); + let indexMap = getDeclaredIndexTypesOfSymbol(type.symbol); + let declaration = indexMap[indexKind] ? indexMap[indexKind].declaredNode : null; if (!declaration) { // declaration might not be found if indexer was added from the contextual type. // in this case use fallback name @@ -1613,7 +1649,7 @@ module ts { function writeLiteralType(type: ObjectType, flags: TypeFormatFlags) { let resolved = resolveObjectOrUnionTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.properties.length && !resolved.stringIndex && !resolved.numberIndex) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, SyntaxKind.OpenBraceToken); writePunctuation(writer, SyntaxKind.CloseBraceToken); @@ -1660,34 +1696,33 @@ module ts { writePunctuation(writer, SyntaxKind.SemicolonToken); writer.writeLine(); } - if (resolved.stringIndexType) { - // [x: string]: - writePunctuation(writer, SyntaxKind.OpenBracketToken); - writer.writeParameter(getIndexerParameterName(resolved, IndexKind.String, /*fallbackName*/"x")); - writePunctuation(writer, SyntaxKind.ColonToken); - writeSpace(writer); - writeKeyword(writer, SyntaxKind.StringKeyword); - writePunctuation(writer, SyntaxKind.CloseBracketToken); - writePunctuation(writer, SyntaxKind.ColonToken); - writeSpace(writer); - writeType(resolved.stringIndexType, TypeFormatFlags.None); - writePunctuation(writer, SyntaxKind.SemicolonToken); - writer.writeLine(); - } - if (resolved.numberIndexType) { - // [x: number]: + function writeIndexType(indexType: IndexType) { + if (!indexType) { + return; + } writePunctuation(writer, SyntaxKind.OpenBracketToken); - writer.writeParameter(getIndexerParameterName(resolved, IndexKind.Number, /*fallbackName*/"x")); + writer.writeParameter(getIndexerParameterName(resolved, indexType.kind, /*fallbackName*/"x")); writePunctuation(writer, SyntaxKind.ColonToken); writeSpace(writer); - writeKeyword(writer, SyntaxKind.NumberKeyword); + + if (indexType.typeOfIndex && (indexType.typeOfIndex.flags & TypeFlags.Subset)) { + writeType(indexType.typeOfIndex, TypeFormatFlags.None); + writer.writeStringLiteral(indexType.kind === IndexKind.String ? " < string" : " < number"); + } + else { + writeKeyword(writer, indexType.kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); + } + writePunctuation(writer, SyntaxKind.CloseBracketToken); writePunctuation(writer, SyntaxKind.ColonToken); writeSpace(writer); - writeType(resolved.numberIndexType, TypeFormatFlags.None); + writeType(indexType.typeOfValue, TypeFormatFlags.None); writePunctuation(writer, SyntaxKind.SemicolonToken); writer.writeLine(); } + writeIndexType(resolved.stringIndex) + writeIndexType(resolved.numberIndex) + for (let p of resolved.properties) { let t = getTypeOfSymbol(p); if (p.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(t).length) { @@ -2069,8 +2104,8 @@ module ts { // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. type = getTypeOfPropertyOfType(parentType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || - getIndexTypeOfType(parentType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexValueOfType(parentType, IndexKind.Number) || + getIndexValueOfType(parentType, IndexKind.String); if (!type) { error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name)); return unknownType; @@ -2504,8 +2539,11 @@ module ts { type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = emptyArray; type.declaredConstructSignatures = emptyArray; - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, IndexKind.String); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, IndexKind.Number); + + let indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + + type.declaredStringIndex = indexTypes[IndexKind.String]; + type.declaredNumberIndex = indexTypes[IndexKind.Number]; } return links.declaredType; } @@ -2548,8 +2586,11 @@ module ts { type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, IndexKind.String); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, IndexKind.Number); + + let indexTypes = getDeclaredIndexTypesOfSymbol(symbol) + + type.declaredStringIndex = indexTypes[IndexKind.String]; + type.declaredNumberIndex = indexTypes[IndexKind.Number]; } return links.declaredType; } @@ -2575,7 +2616,7 @@ module ts { function getDeclaredTypeOfEnum(symbol: Symbol): Type { let links = getSymbolLinks(symbol); if (!links.declaredType) { - let type = createType(TypeFlags.Enum); + let type = createType(TypeFlags.Enum | TypeFlags.Subset); type.symbol = symbol; links.declaredType = type; } @@ -2658,23 +2699,61 @@ module ts { } } + function createNumberIndex(value: Type, index?: Type): IndexType { + return createIndexType(IndexKind.Number, value, index); + } + + function createStringIndex(value: Type, index?: Type): IndexType { + return createIndexType(IndexKind.String, value, index); + } + + function createIndexType(kind: IndexKind, value: Type, index?: Type): IndexType { + let indexType: IndexType = { + kind: kind, + typeOfValue: value, + } + if (index) { + indexType.typeOfIndex = index; + } + return indexType; + } + + function getInheritedIndexFrom(baseType: Type): IndexTypeMap { + let resolved = resolveObjectOrUnionType(baseType); + var index : IndexTypeMap = [ + resolved.stringIndex, + resolved.numberIndex + ] + for (let i in index) { + if (index[i]) { + index[i].inherited = baseType.symbol + } + } + return index; + } + function resolveClassOrInterfaceMembers(type: InterfaceType): void { let members = type.symbol.members; let callSignatures = type.declaredCallSignatures; let constructSignatures = type.declaredConstructSignatures; - let stringIndexType = type.declaredStringIndexType; - let numberIndexType = type.declaredNumberIndexType; - if (type.baseTypes.length) { + let stringIndex = type.declaredStringIndex + let numberIndex = type.declaredNumberIndex + + if (type.baseTypes && type.baseTypes.length) { members = createSymbolTable(type.declaredProperties); forEach(type.baseTypes, baseType => { addInheritedMembers(members, getPropertiesOfObjectType(baseType)); callSignatures = concatenate(callSignatures, getSignaturesOfType(baseType, SignatureKind.Call)); constructSignatures = concatenate(constructSignatures, getSignaturesOfType(baseType, SignatureKind.Construct)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, IndexKind.String); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, IndexKind.Number); + if (!stringIndex || !numberIndex) { + let index = getInheritedIndexFrom(baseType); + stringIndex = stringIndex || index[IndexKind.String]; + numberIndex = numberIndex || index[IndexKind.Number]; + } }); } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function resolveTypeReferenceMembers(type: TypeReference): void { @@ -2683,17 +2762,21 @@ module ts { let members = createInstantiatedSymbolTable(target.declaredProperties, mapper); let callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); let constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - let stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - let numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; + + let stringIndex = target.declaredStringIndex ? instantiateIndexType(target.declaredStringIndex, mapper) : undefined; + let numberIndex = target.declaredNumberIndex ? instantiateIndexType(target.declaredNumberIndex, mapper) : undefined; forEach(target.baseTypes, baseType => { let instantiatedBaseType = instantiateType(baseType, mapper); addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Call)); constructSignatures = concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Construct)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, IndexKind.String); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, IndexKind.Number); + if (!stringIndex || !numberIndex) { + let index = getInheritedIndexFrom(instantiatedBaseType); + stringIndex = stringIndex || index[IndexKind.String]; + numberIndex = numberIndex || index[IndexKind.Number]; + } }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], parameters: Symbol[], @@ -2743,7 +2826,7 @@ module ts { let arrayType = resolveObjectOrUnionTypeMembers(createArrayType(getUnionType(type.elementTypes))); let members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); + setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndex, arrayType.numberIndex); } function signatureListsIdentical(s: Signature[], t: Signature[]): boolean { @@ -2787,7 +2870,7 @@ module ts { function getUnionIndexType(types: Type[], kind: IndexKind): Type { let indexTypes: Type[] = []; for (let type of types) { - let indexType = getIndexTypeOfType(type, kind); + let indexType = getIndexValueOfType(type, kind); if (!indexType) { return undefined; } @@ -2803,7 +2886,7 @@ module ts { let constructSignatures = getUnionSignatures(type.types, SignatureKind.Construct); let stringIndexType = getUnionIndexType(type.types, IndexKind.String); let numberIndexType = getUnionIndexType(type.types, IndexKind.Number); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType ? createStringIndex(stringIndexType) : undefined, numberIndexType ? createNumberIndex(numberIndexType) : undefined); } function resolveAnonymousTypeMembers(type: ObjectType) { @@ -2811,15 +2894,15 @@ module ts { let members: SymbolTable; let callSignatures: Signature[]; let constructSignatures: Signature[]; - let stringIndexType: Type; - let numberIndexType: Type; + let stringIndex: IndexType; + let numberIndex: IndexType; if (symbol.flags & SymbolFlags.TypeLiteral) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); - stringIndexType = getIndexTypeOfSymbol(symbol, IndexKind.String); - numberIndexType = getIndexTypeOfSymbol(symbol, IndexKind.Number); + stringIndex = getIndexTypeOfSymbol(symbol, IndexKind.String); + numberIndex = getIndexTypeOfSymbol(symbol, IndexKind.Number); } else { // Combinations of function, class, enum and module @@ -2843,10 +2926,11 @@ module ts { addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(classType.baseTypes[0].symbol))); } } - stringIndexType = undefined; - numberIndexType = (symbol.flags & SymbolFlags.Enum) ? stringType : undefined; + stringIndex = undefined; + // { kind: SymbolDisplayPartKind[kind] }, ideally typed to SetOf_Names + numberIndex = (symbol.flags & SymbolFlags.Enum) ? createNumberIndex(stringType) : undefined; } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndex, numberIndex); } function resolveObjectOrUnionTypeMembers(type: ObjectType): ResolvedType { @@ -2923,10 +3007,18 @@ module ts { } } if (type.flags & TypeFlags.StringLike) { - type = globalStringType; + if (type.flags & TypeFlags.Subset) { + type = globalStringSubsetType; + } else { + type = globalStringType; + } } else if (type.flags & TypeFlags.NumberLike) { - type = globalNumberType; + if (type.flags & TypeFlags.Subset) { + type = globalNumberSubsetType; + } else { + type = globalNumberType; + } } else if (type.flags & TypeFlags.Boolean) { type = globalBooleanType; @@ -3033,19 +3125,43 @@ module ts { return false; } - function getIndexTypeOfObjectOrUnionType(type: Type, kind: IndexKind): Type { + function resolveObjectOrUnionType(type: Type): ResolvedType { + if (type.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { + return resolveObjectOrUnionTypeMembers(type); + } + } + + function getIndexOfObjectOrUnionType(type: Type): IndexTypeMap { if (type.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { let resolved = resolveObjectOrUnionTypeMembers(type); - return kind === IndexKind.String ? resolved.stringIndexType : resolved.numberIndexType; + return [ + resolved.stringIndex, + resolved.numberIndex + ] } } + function getIndexTypeOfObjectOrUnionType(type: Type, kind: IndexKind): IndexType { + let indexMap = getIndexOfObjectOrUnionType(type); + return indexMap ? indexMap[kind] : undefined; + } + + function getIndexValueOfObjectOrUnionType(type: Type, kind: IndexKind): Type { + let indexType = getIndexTypeOfObjectOrUnionType(type, kind); + return indexType ? indexType.typeOfValue : undefined + } + // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. - function getIndexTypeOfType(type: Type, kind: IndexKind): Type { + function getIndexOfType(type: Type, kind: IndexKind): IndexType { return getIndexTypeOfObjectOrUnionType(getApparentType(type), kind); } + function getIndexValueOfType(type: Type, kind: IndexKind): Type { + let indexType = getIndexOfType(type, kind); + return indexType ? indexType.typeOfValue : undefined + } + // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). function getTypeParametersFromDeclaration(typeParameterDeclarations: TypeParameterDeclaration[]): TypeParameter[] { @@ -3236,30 +3352,44 @@ module ts { return symbol.members["__index"]; } - function getIndexDeclarationOfSymbol(symbol: Symbol, kind: IndexKind): SignatureDeclaration { - let syntaxKind = kind === IndexKind.Number ? SyntaxKind.NumberKeyword : SyntaxKind.StringKeyword; + function getDeclaredIndexTypesOfSymbol(symbol: Symbol): IndexTypeMap { + let indexMap: IndexTypeMap = [] let indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { - let len = indexSymbol.declarations.length; - for (let decl of indexSymbol.declarations) { - let node = decl; - if (node.parameters.length === 1) { - let parameter = node.parameters[0]; - if (parameter && parameter.type && parameter.type.kind === syntaxKind) { - return node; + for (let decl of indexSymbol.declarations) { + if (decl.parameters.length === 1) { + let type = getTypeFromIndexSignatureParameter(decl.parameters[0]); + if (!type) { + continue; + } + let kind = (type.flags & TypeFlags.NumberLike) ? IndexKind.Number : (type.flags & TypeFlags.String) ? IndexKind.String: null; + if (kind !== null) { + if (indexMap[kind]) { + indexMap[kind].declaredCount++; + } else { + indexMap[kind] = { + kind: kind, + typeOfIndex: type, + typeOfValue: decl.type ? getTypeFromTypeNodeOrHeritageClauseElement(decl.type) : anyType, + declaredNode: decl, + declaredCount: 1 + } + } } } } } + return indexMap; + } - return undefined; + function getIndexTypeOfSymbol(symbol: Symbol, kind: IndexKind): IndexType { + let indexTypes = getDeclaredIndexTypesOfSymbol(symbol); + return indexTypes[kind]; } - function getIndexTypeOfSymbol(symbol: Symbol, kind: IndexKind): Type { - let declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration - ? declaration.type ? getTypeFromTypeNodeOrHeritageClauseElement(declaration.type) : anyType - : undefined; + function getIndexValueOfSymbol(symbol: Symbol, kind: IndexKind): Type { + let info = getIndexTypeOfSymbol(symbol, kind); + return info ? info.typeOfValue : undefined } function getConstraintOfTypeParameter(type: TypeParameter): Type { @@ -3824,13 +3954,17 @@ module ts { result.members = createSymbolTable(result.properties); result.callSignatures = instantiateList(getSignaturesOfType(type, SignatureKind.Call), mapper, instantiateSignature); result.constructSignatures = instantiateList(getSignaturesOfType(type, SignatureKind.Construct), mapper, instantiateSignature); - let stringIndexType = getIndexTypeOfType(type, IndexKind.String); - let numberIndexType = getIndexTypeOfType(type, IndexKind.Number); - if (stringIndexType) result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + let stringIndex = getIndexOfType(type, IndexKind.String); + let numberIndex = getIndexOfType(type, IndexKind.Number); + if (stringIndex) result.stringIndex = instantiateIndexType(stringIndex, mapper); + if (numberIndex) result.numberIndex = instantiateIndexType(numberIndex, mapper); return result; } + function instantiateIndexType(index: IndexType, mapper: TypeMapper): IndexType { + return createIndexType(index.kind, instantiateType(index.typeOfValue, mapper), index.typeOfIndex) + } + function instantiateType(type: Type, mapper: TypeMapper): Type { if (mapper !== identityMapper) { if (type.flags & TypeFlags.TypeParameter) { @@ -4041,6 +4175,17 @@ module ts { } } else { + if ((source.flags & TypeFlags.Subset) && (target.flags & TypeFlags.Subset)) { + /* + if (target.flags & TypeFlags.Enum) { + // if const/immutable, only check index signature + if (target.symbol.flags & SymbolFlags.ConstEnum) { + if (result = indexRelatedTo(source, target, reportErrors)) { + return result; + } + } + }*/ + } let saveErrorInfo = errorInfo; if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { // We have type references to same target type, see if relationship holds for all type arguments @@ -4202,10 +4347,7 @@ module ts { if (result) { result &= signaturesRelatedTo(source, target, SignatureKind.Construct, reportErrors); if (result) { - result &= stringIndexTypesRelatedTo(source, target, reportErrors); - if (result) { - result &= numberIndexTypesRelatedTo(source, target, reportErrors); - } + result &= indexRelatedTo(source, target, reportErrors); } } } @@ -4455,74 +4597,90 @@ module ts { return result; } - function stringIndexTypesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { - if (relation === identityRelation) { - return indexTypesIdenticalTo(IndexKind.String, source, target); - } - let targetType = getIndexTypeOfType(target, IndexKind.String); - if (targetType) { - let sourceType = getIndexTypeOfType(source, IndexKind.String); - if (!sourceType) { - if (reportErrors) { - reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return Ternary.False; + function indexRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { + let sourceIndex = getIndexOfObjectOrUnionType(source); + let targetIndex = getIndexOfObjectOrUnionType(target); + + const sourceType = source; + const targetType = target; + + return stringIndexRelatedTo(sourceIndex[IndexKind.String], targetIndex[IndexKind.String]) && + numberIndexRelatedTo(sourceIndex,targetIndex[IndexKind.Number]); + + function stringIndexRelatedTo(source: IndexType, target: IndexType): Ternary { + if (relation === identityRelation) { + return indexTypesIdenticalTo(source, target, stringType); } - let related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(Diagnostics.Index_signatures_are_incompatible); + + if (target) { + if (!source) { + if (reportErrors) { + reportError(Diagnostics.Missing_0_index_signature_in_type_1, "[string]", typeToString(sourceType)); + } + return Ternary.False; } - return Ternary.False; + let related = indexTypesRelatedTo(source, target, stringType); + if (!related) { + if (reportErrors) { + reportError(Diagnostics.Index_signatures_0_and_1_are_incompatible, indexTypeToString(source), indexTypeToString(target)); + } + return Ternary.False; + } + return related; } - return related; + return Ternary.True; } - return Ternary.True; - } - function numberIndexTypesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { - if (relation === identityRelation) { - return indexTypesIdenticalTo(IndexKind.Number, source, target); - } - let targetType = getIndexTypeOfType(target, IndexKind.Number); - if (targetType) { - let sourceStringType = getIndexTypeOfType(source, IndexKind.String); - let sourceNumberType = getIndexTypeOfType(source, IndexKind.Number); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return Ternary.False; - } - let related: Ternary; - if (sourceStringType && sourceNumberType) { - // If we know for sure we're testing both string and numeric index types then only report errors from the second one - related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); - } - else { - related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); + function numberIndexRelatedTo(source: IndexTypeMap, targetNumberIndex: IndexType): Ternary { + let sourceNumberIndex = source[IndexKind.Number]; + if (relation === identityRelation) { + return indexTypesIdenticalTo(sourceNumberIndex, targetNumberIndex, numberType); } - if (!related) { - if (reportErrors) { - reportError(Diagnostics.Index_signatures_are_incompatible); + + if (targetNumberIndex) { + let sourceStringIndex = source[IndexKind.String]; + if (!sourceStringIndex && !sourceNumberIndex) { + if (reportErrors) { + reportError(Diagnostics.Missing_0_index_signature_in_type_1, "[string] or [number]", typeToString(sourceType) ); + } + return Ternary.False; } - return Ternary.False; + let related: Ternary; + let sourceError = sourceNumberIndex; + if (sourceStringIndex && sourceNumberIndex) { + // If we know for sure we're testing both string and numeric index types then only report errors from the second one + related = isRelatedTo(sourceStringIndex.typeOfValue, targetNumberIndex.typeOfValue, false) || indexTypesRelatedTo(sourceNumberIndex, targetNumberIndex, numberType); + } + else if (sourceStringIndex) { + related = isRelatedTo(sourceStringIndex.typeOfValue, targetNumberIndex.typeOfValue); + sourceError = sourceStringIndex; + } else if (sourceNumberIndex) { + related = indexTypesRelatedTo(sourceNumberIndex, targetNumberIndex, numberType); + } + if (!related) { + if (reportErrors) { + reportError(Diagnostics.Index_signatures_0_and_1_are_incompatible, indexTypeToString(sourceError), indexTypeToString(targetNumberIndex)); + } + return Ternary.False; + } + return related; } - return related; + return Ternary.True; } - return Ternary.True; - } - function indexTypesIdenticalTo(indexKind: IndexKind, source: ObjectType, target: ObjectType): Ternary { - let targetType = getIndexTypeOfType(target, indexKind); - let sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { - return Ternary.True; + function indexTypesRelatedTo(sourceIndex: IndexType, targetIndex: IndexType, defaultIndex: Type): Ternary { + return isRelatedTo(sourceIndex.typeOfIndex || defaultIndex, targetIndex.typeOfIndex || defaultIndex, reportErrors) && isRelatedTo(sourceIndex.typeOfValue, targetIndex.typeOfValue, reportErrors); } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); + + function indexTypesIdenticalTo(sourceIndex: IndexType, targetIndex: IndexType, defaultIndex: Type): Ternary { + if (!sourceIndex && !targetIndex) { + return Ternary.True; + } + if (sourceIndex && targetIndex) { + return indexTypesRelatedTo(sourceIndex, targetIndex, defaultIndex); + } + return Ternary.False; } - return Ternary.False; } } @@ -4689,11 +4847,11 @@ module ts { } members[p.name] = p; }); - let stringIndexType = getIndexTypeOfType(type, IndexKind.String); - let numberIndexType = getIndexTypeOfType(type, IndexKind.Number); - if (stringIndexType) stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) numberIndexType = getWidenedType(numberIndexType); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + let stringIndex = getIndexOfType(type, IndexKind.String); + let numberIndex = getIndexOfType(type, IndexKind.Number); + if (stringIndex) stringIndex = createStringIndex(getWidenedType(stringIndex.typeOfValue)); + if (numberIndex) numberIndex = createNumberIndex(getWidenedType(numberIndex.typeOfValue)); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndex, numberIndex); } function getWidenedType(type: Type): Type { @@ -4968,9 +5126,9 @@ module ts { } function inferFromIndexTypes(source: Type, target: Type, sourceKind: IndexKind, targetKind: IndexKind) { - let targetIndexType = getIndexTypeOfType(target, targetKind); + let targetIndexType = getIndexValueOfType(target, targetKind); if (targetIndexType) { - let sourceIndexType = getIndexTypeOfType(source, sourceKind); + let sourceIndexType = getIndexValueOfType(source, sourceKind); if (sourceIndexType) { inferFromTypes(sourceIndexType, targetIndexType); } @@ -5782,7 +5940,7 @@ module ts { } function getIndexTypeOfContextualType(type: Type, kind: IndexKind) { - return applyToContextualType(type, t => getIndexTypeOfObjectOrUnionType(t, kind)); + return applyToContextualType(type, t => getIndexValueOfObjectOrUnionType(t, kind)); } // Return true if the given contextual type is a tuple-like type @@ -5792,7 +5950,7 @@ module ts { // Return true if the given contextual type provides an index signature of the given kind function contextualTypeHasIndexSignature(type: Type, kind: IndexKind): boolean { - return !!(type.flags & TypeFlags.Union ? forEach((type).types, t => getIndexTypeOfObjectOrUnionType(t, kind)) : getIndexTypeOfObjectOrUnionType(type, kind)); + return !!(type.flags & TypeFlags.Union ? forEach((type).types, t => getIndexValueOfObjectOrUnionType(t, kind)) : getIndexValueOfObjectOrUnionType(type, kind)); } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of @@ -6135,7 +6293,7 @@ module ts { let stringIndexType = getIndexType(IndexKind.String); let numberIndexType = getIndexType(IndexKind.Number); - let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType ? createStringIndex(stringIndexType) : undefined, numberIndexType ? createNumberIndex(numberIndexType) : undefined); result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.ContainsUndefinedOrNull); return result; @@ -6339,14 +6497,14 @@ module ts { // Try to use a number indexer. if (allConstituentTypesHaveKind(indexType, TypeFlags.Any | TypeFlags.NumberLike)) { - let numberIndexType = getIndexTypeOfType(objectType, IndexKind.Number); + let numberIndexType = getIndexValueOfType(objectType, IndexKind.Number); if (numberIndexType) { return numberIndexType; } } // Try to use string indexing. - let stringIndexType = getIndexTypeOfType(objectType, IndexKind.String); + let stringIndexType = getIndexValueOfType(objectType, IndexKind.String); if (stringIndexType) { return stringIndexType; } @@ -6590,7 +6748,7 @@ module ts { if (type.flags & TypeFlags.ObjectType) { let resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { + resolved.properties.length === 0 && !resolved.stringIndex && !resolved.numberIndex) { return resolved.callSignatures[0]; } } @@ -7589,8 +7747,8 @@ module ts { let name = (p).name; let type = sourceType.flags & TypeFlags.Any ? sourceType : getTypeOfPropertyOfType(sourceType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || - getIndexTypeOfType(sourceType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexValueOfType(sourceType, IndexKind.Number) || + getIndexValueOfType(sourceType, IndexKind.String); if (type) { checkDestructuringAssignment((p).initializer || name, type); } @@ -8154,31 +8312,31 @@ module ts { // TypeScript 1.0 spec (April 2014) // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration - let indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { - let seenNumericIndexer = false; - let seenStringIndexer = false; + let symbol = getSymbolOfNode(node); + let indexMap = getDeclaredIndexTypesOfSymbol(symbol); + let stringIndex = indexMap[IndexKind.String]; + let numberIndex = indexMap[IndexKind.Number]; + + if (stringIndex && stringIndex.declaredCount > 1) { + errorDuplicateIndex(getIndexSymbol(symbol), stringIndex); + } + + if (numberIndex && numberIndex.declaredCount > 1) { + errorDuplicateIndex(getIndexSymbol(symbol), numberIndex); + } + + function errorDuplicateIndex(indexSymbol: Symbol, indexType: IndexType) { for (let decl of indexSymbol.declarations) { let declaration = decl; - if (declaration.parameters.length === 1 && declaration.parameters[0].type) { - switch (declaration.parameters[0].type.kind) { - case SyntaxKind.StringKeyword: - if (!seenStringIndexer) { - seenStringIndexer = true; - } - else { - error(declaration, Diagnostics.Duplicate_string_index_signature); - } - break; - case SyntaxKind.NumberKeyword: - if (!seenNumericIndexer) { - seenNumericIndexer = true; - } - else { - error(declaration, Diagnostics.Duplicate_number_index_signature); - } - break; - } + if (declaration.parameters.length !== 1 || declaration === indexType.declaredNode) { + continue; + } + let type = getTypeFromIndexSignatureParameter(declaration.parameters[0]) + if (type.flags & TypeFlags.String && indexType.kind === IndexKind.String) { + error(declaration, Diagnostics.Duplicate_string_index_signature); + } + else if (type.flags & TypeFlags.NumberLike && indexType.kind === IndexKind.Number) { + error(declaration, Diagnostics.Duplicate_number_index_signature); } } } @@ -9412,7 +9570,7 @@ module ts { } if (isArrayLikeType(inputType)) { - let indexType = getIndexTypeOfType(inputType, IndexKind.Number); + let indexType = getIndexValueOfType(inputType, IndexKind.Number); if (indexType) { return indexType; } @@ -9574,7 +9732,7 @@ module ts { return hasStringConstituent ? stringType : unknownType; } - let arrayElementType = getIndexTypeOfType(arrayType, IndexKind.Number) || unknownType; + let arrayElementType = getIndexValueOfType(arrayType, IndexKind.Number) || unknownType; if (hasStringConstituent) { // This is just an optimization for the case where arrayOrStringType is string | string[] if (arrayElementType.flags & TypeFlags.StringLike) { @@ -9755,63 +9913,75 @@ module ts { } function checkIndexConstraints(type: Type) { - let declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, IndexKind.Number); - let declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, IndexKind.String); - - let stringIndexType = getIndexTypeOfType(type, IndexKind.String); - let numberIndexType = getIndexTypeOfType(type, IndexKind.Number); + let resolved = resolveObjectOrUnionType(type); + if (!resolved) { + return; + } - if (stringIndexType || numberIndexType) { - forEach(getPropertiesOfObjectType(type), prop => { - let propType = getTypeOfSymbol(prop); - checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, IndexKind.String); - checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, IndexKind.Number); - }); + let stringIndex = resolved.stringIndex || createStringIndex(null); + let numberIndex = resolved.numberIndex || createNumberIndex(null) + let alphaNumeric = resolved.alphaNumericIndex; + if (!stringIndex.typeOfValue && !numberIndex.typeOfValue) { + return; + } - if (type.flags & TypeFlags.Class && type.symbol.valueDeclaration.kind === SyntaxKind.ClassDeclaration) { - let classDeclaration = type.symbol.valueDeclaration; - for (let member of classDeclaration.members) { - // Only process instance properties with computed names here. - // Static properties cannot be in conflict with indexers, - // and properties with literal names were already checked. - if (!(member.flags & NodeFlags.Static) && hasDynamicName(member)) { - let propType = getTypeOfSymbol(member.symbol); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, IndexKind.String); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, IndexKind.Number); - } - } + let containingNode = type.symbol.declarations[type.symbol.declarations.length - 1]; + let errorNode = containingNode; + let checkIndexNodes = [numberIndex.declaredNode, stringIndex.declaredNode]; + for (let node of checkIndexNodes) { + // Use index declaration as error node if contained in the class/interface + if (node && node.parent === containingNode) { + errorNode = node; + break; } } - let errorNode: Node; - if (stringIndexType && numberIndexType) { - errorNode = declaredNumberIndexer || declaredStringIndexer; - // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer - if (!errorNode && (type.flags & TypeFlags.Interface)) { - let someBaseTypeHasBothIndexers = forEach((type).baseTypes, base => getIndexTypeOfType(base, IndexKind.String) && getIndexTypeOfType(base, IndexKind.Number)); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; - } + // Don't check number index if not assignable + let checkNumberIndex = numberIndex; + if (alphaNumeric === IndexAlphaNumeric.YES && !isTypeAssignableTo(numberIndex.typeOfValue, stringIndex.typeOfValue)) { + error(errorNode, Diagnostics.Numeric_index_0_is_not_assignable_to_string_index_1, + indexTypeToString(numberIndex), indexTypeToString(stringIndex)); + + checkNumberIndex = null; } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { - error(errorNode, Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, - typeToString(numberIndexType), typeToString(stringIndexType)); + forEach(getPropertiesOfObjectType(type), prop => { + let propType = getTypeOfSymbol(prop); + checkIndexConstraintForProperty(prop, propType, type, stringIndex, alphaNumeric); + if (checkNumberIndex) { + checkIndexConstraintForProperty(prop, propType, type, numberIndex, alphaNumeric); + } + }); + + if (type.flags & TypeFlags.Class && type.symbol.valueDeclaration.kind === SyntaxKind.ClassDeclaration) { + let classDeclaration = type.symbol.valueDeclaration; + for (let member of classDeclaration.members) { + // Only process instance properties with computed names here. + // Static properties cannot be in conflict with indexers, + // and properties with literal names were already checked. + if (!(member.flags & NodeFlags.Static) && hasDynamicName(member)) { + let propType = getTypeOfSymbol(member.symbol); + checkIndexConstraintForProperty(member.symbol, propType, type, stringIndex, alphaNumeric); + if (checkNumberIndex) { + checkIndexConstraintForProperty(member.symbol, propType, type, numberIndex, alphaNumeric); + } + } + } } function checkIndexConstraintForProperty( prop: Symbol, propertyType: Type, containingType: Type, - indexDeclaration: Declaration, - indexType: Type, - indexKind: IndexKind): void { + indexType: IndexType, + alphaNumeric: IndexAlphaNumeric): void { - if (!indexType) { + if (!indexType.typeOfValue) { return; } // index is numeric and property name is not valid numeric literal - if (indexKind === IndexKind.Number && !isNumericName(prop.valueDeclaration.name)) { + if (indexType.kind === IndexKind.Number && !isNumericName(prop.valueDeclaration.name)) { return; } @@ -9821,23 +9991,25 @@ module ts { if (prop.valueDeclaration.name.kind === SyntaxKind.ComputedPropertyName || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } - else if (indexDeclaration) { - errorNode = indexDeclaration; - } - else if (containingType.flags & TypeFlags.Interface) { - // for interfaces property and indexer might be inherited from different bases - // check if any base class already has both property and indexer. - // check should be performed only if 'type' is the first type that brings property\indexer together - let someBaseClassHasBothPropertyAndIndexer = forEach((containingType).baseTypes, base => getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind)); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + else if (indexType.declaredNode) { + errorNode = indexType.declaredNode; + let containingNode = containingType.symbol.declarations[containingType.symbol.declarations.length - 1]; + if (errorNode.parent !== containingNode) { + errorNode = containingNode; + } + + if (alphaNumeric === IndexAlphaNumeric.INHERITED) { + // inherited node will report error instead + errorNode = undefined; + } } - if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { + if (errorNode && !isTypeAssignableTo(propertyType, indexType.typeOfValue)) { let errorMessage = - indexKind === IndexKind.String - ? Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 - : Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); + indexType.kind === IndexKind.String + ? Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_2 + : Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_2; + error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), indexTypeToString(indexType)); } } } @@ -11878,7 +12050,10 @@ module ts { globalObjectType = getGlobalType("Object"); globalFunctionType = getGlobalType("Function"); globalStringType = getGlobalType("String"); + globalStringSubsetType = cloneInterfaceType(globalStringType, TypeFlags.Subset); globalNumberType = getGlobalType("Number"); + globalNumberSubsetType = cloneInterfaceType(globalNumberType, TypeFlags.Subset); + globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); @@ -12288,6 +12463,25 @@ module ts { return false; } + function getTypeFromIndexSignatureParameter(parameter: ParameterDeclaration): Type { + if (parameter.type) { + if(parameter.type.kind === SyntaxKind.StringKeyword) { + return stringType; + } + if(parameter.type.kind === SyntaxKind.NumberKeyword) { + return numberType; + } + + if (parameter.type.kind === SyntaxKind.TypeReference) { + var type = getTypeFromTypeReference((parameter.type)); + if ((type.flags & TypeFlags.NumberLike) || (type.flags & TypeFlags.String)) { + return type; + } + } + } + return undefined; + } + function checkGrammarIndexSignatureParameters(node: SignatureDeclaration): boolean { let parameter = node.parameters[0]; if (node.parameters.length !== 1) { @@ -12313,8 +12507,8 @@ module ts { if (!parameter.type) { return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== SyntaxKind.StringKeyword && parameter.type.kind !== SyntaxKind.NumberKeyword) { - return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + if (!getTypeFromIndexSignatureParameter(parameter)) { + return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_type_must_be_string_number_or_an_enum_type); } if (!node.type) { return grammarErrorOnNode(node, Diagnostics.An_index_signature_must_have_a_type_annotation); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 0271ac731053e..f7808a50fcb42 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -19,7 +19,7 @@ module ts { An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, An_index_signature_must_have_a_type_annotation: { code: 1021, category: DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, + An_index_signature_parameter_type_must_be_string_number_or_an_enum_type: { code: 1023, category: DiagnosticCategory.Error, key: "An index signature parameter type must be 'string', 'number', or an enum type." }, A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, A_class_can_only_extend_a_single_class: { code: 1026, category: DiagnosticCategory.Error, key: "A class can only extend a single class." }, @@ -203,8 +203,8 @@ module ts { Types_of_property_0_are_incompatible: { code: 2326, category: DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible." }, Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: DiagnosticCategory.Error, key: "Index signatures are incompatible." }, + Missing_0_index_signature_in_type_1: { code: 2329, category: DiagnosticCategory.Error, key: "Missing {0} index signature in type '{1}'." }, + Index_signatures_0_and_1_are_incompatible: { code: 2330, category: DiagnosticCategory.Error, key: "Index signatures '{0}' and '{1}' are incompatible." }, this_cannot_be_referenced_in_a_module_body: { code: 2331, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a module body." }, this_cannot_be_referenced_in_current_location: { code: 2332, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, @@ -279,9 +279,9 @@ module ts { Setters_cannot_return_a_value: { code: 2408, category: DiagnosticCategory.Error, key: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" }, All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, + Property_0_of_type_1_is_not_assignable_to_string_index_2: { code: 2411, category: DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index '{2}'." }, + Property_0_of_type_1_is_not_assignable_to_numeric_index_2: { code: 2412, category: DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index '{2}'." }, + Numeric_index_0_is_not_assignable_to_string_index_1: { code: 2413, category: DiagnosticCategory.Error, key: "Numeric index '{0}' is not assignable to string index '{1}'." }, Class_name_cannot_be_0: { code: 2414, category: DiagnosticCategory.Error, key: "Class name cannot be '{0}'" }, Class_0_incorrectly_extends_base_class_1: { code: 2415, category: DiagnosticCategory.Error, key: "Class '{0}' incorrectly extends base class '{1}'." }, Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: DiagnosticCategory.Error, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 063a0d50ef5cb..d05b3be299838 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -63,7 +63,7 @@ "category": "Error", "code": 1022 }, - "An index signature parameter type must be 'string' or 'number'.": { + "An index signature parameter type must be 'string', 'number', or an enum type.": { "category": "Error", "code": 1023 }, @@ -799,11 +799,11 @@ "category": "Error", "code": 2328 }, - "Index signature is missing in type '{0}'.": { + "Missing {0} index signature in type '{1}'.": { "category": "Error", "code": 2329 }, - "Index signatures are incompatible.": { + "Index signatures '{0}' and '{1}' are incompatible.": { "category": "Error", "code": 2330 }, @@ -1103,15 +1103,15 @@ "category": "Error", "code": 2410 }, - "Property '{0}' of type '{1}' is not assignable to string index type '{2}'.": { + "Property '{0}' of type '{1}' is not assignable to string index '{2}'.": { "category": "Error", "code": 2411 }, - "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'.": { + "Property '{0}' of type '{1}' is not assignable to numeric index '{2}'.": { "category": "Error", "code": 2412 }, - "Numeric index type '{0}' is not assignable to string index type '{1}'.": { + "Numeric index '{0}' is not assignable to string index '{1}'.": { "category": "Error", "code": 2413 }, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 43c210331a5cf..f576babbb4c4b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1446,8 +1446,9 @@ module ts { /* @internal */ ContainsUndefinedOrNull = 0x00040000, // Type is or contains Undefined or Null type /* @internal */ - ContainsObjectLiteral = 0x00080000, // Type is or contains object literal type + ContainsObjectLiteral = 0x00080000, // Type is or contains object literal type ESSymbol = 0x00100000, // Type of symbol primitive introduced in ES6 + Subset = 0x00200000, // Type that has a subset of valid values /* @internal */ Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null, @@ -1455,6 +1456,7 @@ module ts { Primitive = String | Number | Boolean | ESSymbol | Void | Undefined | Null | StringLiteral | Enum, StringLike = String | StringLiteral, NumberLike = Number | Enum, + SubsetMaybe = Enum | Reference, ObjectType = Class | Interface | Reference | Tuple | Anonymous, /* @internal */ RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral @@ -1488,8 +1490,8 @@ module ts { declaredProperties: Symbol[]; // Declared members declaredCallSignatures: Signature[]; // Declared call signatures declaredConstructSignatures: Signature[]; // Declared construct signatures - declaredStringIndexType: Type; // Declared string index type - declaredNumberIndexType: Type; // Declared numeric index type + declaredStringIndex: IndexType; // Declared string type + declaredNumberIndex: IndexType; // Declared numeric type } // Type references (TypeFlags.Reference) @@ -1515,15 +1517,32 @@ module ts { resolvedProperties: SymbolTable; // Cache of resolved properties } - /* @internal */ - // Resolved object or union type + export enum IndexAlphaNumeric { + NO, + YES, // string & number indexes come from different types + INHERITED // string & number indexes are both from an inherited type + } + + export interface IndexType { + kind: IndexKind // Kind of index + typeOfValue: Type // any + typeOfIndex?: Type // string|number|enum + + // Useful for error reporting + declaredNode?: SignatureDeclaration, // Declaration of [x: typeOfIndex]: typeOfValue + declaredCount?: number // Number of declarations + inherited?: Symbol // Symbol of baseType where inherited + } + + /* @internal */ // Resolved object or union type export interface ResolvedType extends ObjectType, UnionType { - members: SymbolTable; // Properties by name - properties: Symbol[]; // Properties - callSignatures: Signature[]; // Call signatures of type - constructSignatures: Signature[]; // Construct signatures of type - stringIndexType: Type; // String index type - numberIndexType: Type; // Numeric index type + members: SymbolTable; // Properties by name + properties: Symbol[]; // Properties + callSignatures: Signature[]; // Call signatures of type + constructSignatures: Signature[]; // Construct signatures of type + stringIndex: IndexType; // String index type + numberIndex: IndexType; // Number index type + alphaNumericIndex?: IndexAlphaNumeric // Information about alphanumeric index } // Type parameters (TypeFlags.TypeParameter) diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index d147ded3f0e94..d999eb0b4f8d5 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -23,14 +23,14 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void >fileNames : string[], Symbol(fileNames, Decl(APISample_compile.ts, 13, 24)) >options : ts.CompilerOptions, Symbol(options, Decl(APISample_compile.ts, 13, 44)) >ts : any, Symbol(ts, Decl(APISample_compile.ts, 9, 20)) ->CompilerOptions : ts.CompilerOptions, Symbol(ts.CompilerOptions, Decl(typescript.d.ts, 1074, 5)) +>CompilerOptions : ts.CompilerOptions, Symbol(ts.CompilerOptions, Decl(typescript.d.ts, 1089, 5)) var program = ts.createProgram(fileNames, options); >program : ts.Program, Symbol(program, Decl(APISample_compile.ts, 14, 7)) >ts.createProgram(fileNames, options) : ts.Program ->ts.createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program, Symbol(ts.createProgram, Decl(typescript.d.ts, 1201, 113)) +>ts.createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program, Symbol(ts.createProgram, Decl(typescript.d.ts, 1216, 113)) >ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20)) ->createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program, Symbol(ts.createProgram, Decl(typescript.d.ts, 1201, 113)) +>createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program, Symbol(ts.createProgram, Decl(typescript.d.ts, 1216, 113)) >fileNames : string[], Symbol(fileNames, Decl(APISample_compile.ts, 13, 24)) >options : ts.CompilerOptions, Symbol(options, Decl(APISample_compile.ts, 13, 44)) @@ -46,9 +46,9 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void >ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics) : ts.Diagnostic[] >ts.getPreEmitDiagnostics(program).concat : { (...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46)) >ts.getPreEmitDiagnostics(program) : ts.Diagnostic[] ->ts.getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[], Symbol(ts.getPreEmitDiagnostics, Decl(typescript.d.ts, 1199, 98)) +>ts.getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[], Symbol(ts.getPreEmitDiagnostics, Decl(typescript.d.ts, 1214, 98)) >ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20)) ->getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[], Symbol(ts.getPreEmitDiagnostics, Decl(typescript.d.ts, 1199, 98)) +>getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[], Symbol(ts.getPreEmitDiagnostics, Decl(typescript.d.ts, 1214, 98)) >program : ts.Program, Symbol(program, Decl(APISample_compile.ts, 14, 7)) >concat : { (...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46)) >emitResult.diagnostics : ts.Diagnostic[], Symbol(ts.EmitResult.diagnostics, Decl(typescript.d.ts, 820, 29)) @@ -67,24 +67,24 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void >line : number, Symbol(line, Decl(APISample_compile.ts, 20, 13)) >character : number, Symbol(character, Decl(APISample_compile.ts, 20, 19)) >diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter ->diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1263, 46)) ->diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26)) +>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1278, 46)) +>diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1077, 26)) >diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27)) ->file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26)) ->getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1263, 46)) ->diagnostic.start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25)) +>file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1077, 26)) +>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1278, 46)) +>diagnostic.start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1078, 25)) >diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27)) ->start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25)) +>start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1078, 25)) var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); >message : string, Symbol(message, Decl(APISample_compile.ts, 21, 11)) >ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n') : string ->ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1200, 67)) +>ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1215, 67)) >ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20)) ->flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1200, 67)) ->diagnostic.messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23)) +>flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1215, 67)) +>diagnostic.messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1080, 23)) >diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27)) ->messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23)) +>messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1080, 23)) >'\n' : string console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); @@ -94,9 +94,9 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void >log : any >`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}` : string >diagnostic.file.fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29)) ->diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26)) +>diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1077, 26)) >diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27)) ->file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26)) +>file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1077, 26)) >fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29)) >line + 1 : number >line : number, Symbol(line, Decl(APISample_compile.ts, 20, 13)) @@ -153,16 +153,16 @@ compile(process.argv.slice(2), { target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS >target : ts.ScriptTarget, Symbol(target, Decl(APISample_compile.ts, 31, 45)) ->ts.ScriptTarget.ES5 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES5, Decl(typescript.d.ts, 1117, 16)) ->ts.ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5)) +>ts.ScriptTarget.ES5 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES5, Decl(typescript.d.ts, 1132, 16)) +>ts.ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1130, 5)) >ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20)) ->ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5)) ->ES5 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES5, Decl(typescript.d.ts, 1117, 16)) +>ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1130, 5)) +>ES5 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES5, Decl(typescript.d.ts, 1132, 16)) >module : ts.ModuleKind, Symbol(module, Decl(APISample_compile.ts, 32, 32)) ->ts.ModuleKind.CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17)) ->ts.ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5)) +>ts.ModuleKind.CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1123, 17)) +>ts.ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1121, 5)) >ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20)) ->ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5)) ->CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17)) +>ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1121, 5)) +>CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1123, 17)) }); diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index c285bc15390d8..04e82a93ff9e7 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -22,7 +22,7 @@ export function delint(sourceFile: ts.SourceFile) { >delint : (sourceFile: ts.SourceFile) => void, Symbol(delint, Decl(APISample_linter.ts, 11, 33)) >sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23)) >ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6)) ->SourceFile : ts.SourceFile, Symbol(ts.SourceFile, Decl(typescript.d.ts, 740, 5), Decl(typescript.d.ts, 1261, 5)) +>SourceFile : ts.SourceFile, Symbol(ts.SourceFile, Decl(typescript.d.ts, 740, 5), Decl(typescript.d.ts, 1276, 5)) delintNode(sourceFile); >delintNode(sourceFile) : void @@ -33,7 +33,7 @@ export function delint(sourceFile: ts.SourceFile) { >delintNode : (node: ts.Node) => void, Symbol(delintNode, Decl(APISample_linter.ts, 14, 27)) >node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24)) >ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6)) ->Node : ts.Node, Symbol(ts.Node, Decl(typescript.d.ts, 296, 5), Decl(typescript.d.ts, 1221, 32)) +>Node : ts.Node, Symbol(ts.Node, Decl(typescript.d.ts, 296, 5), Decl(typescript.d.ts, 1236, 32)) switch (node.kind) { >node.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38)) @@ -219,9 +219,9 @@ export function delint(sourceFile: ts.SourceFile) { ts.forEachChild(node, delintNode); >ts.forEachChild(node, delintNode) : void ->ts.forEachChild : (node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T, Symbol(ts.forEachChild, Decl(typescript.d.ts, 1186, 48)) +>ts.forEachChild : (node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T, Symbol(ts.forEachChild, Decl(typescript.d.ts, 1201, 48)) >ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6)) ->forEachChild : (node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T, Symbol(ts.forEachChild, Decl(typescript.d.ts, 1186, 48)) +>forEachChild : (node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T, Symbol(ts.forEachChild, Decl(typescript.d.ts, 1201, 48)) >node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24)) >delintNode : (node: ts.Node) => void, Symbol(delintNode, Decl(APISample_linter.ts, 14, 27)) } @@ -230,20 +230,20 @@ export function delint(sourceFile: ts.SourceFile) { >report : (node: ts.Node, message: string) => void, Symbol(report, Decl(APISample_linter.ts, 48, 5)) >node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 50, 20)) >ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6)) ->Node : ts.Node, Symbol(ts.Node, Decl(typescript.d.ts, 296, 5), Decl(typescript.d.ts, 1221, 32)) +>Node : ts.Node, Symbol(ts.Node, Decl(typescript.d.ts, 296, 5), Decl(typescript.d.ts, 1236, 32)) >message : string, Symbol(message, Decl(APISample_linter.ts, 50, 34)) let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart()); >line : number, Symbol(line, Decl(APISample_linter.ts, 51, 13)) >character : number, Symbol(character, Decl(APISample_linter.ts, 51, 19)) >sourceFile.getLineAndCharacterOfPosition(node.getStart()) : ts.LineAndCharacter ->sourceFile.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1263, 46)) +>sourceFile.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1278, 46)) >sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23)) ->getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1263, 46)) +>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1278, 46)) >node.getStart() : number ->node.getStart : (sourceFile?: ts.SourceFile) => number, Symbol(ts.Node.getStart, Decl(typescript.d.ts, 1226, 53)) +>node.getStart : (sourceFile?: ts.SourceFile) => number, Symbol(ts.Node.getStart, Decl(typescript.d.ts, 1241, 53)) >node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 50, 20)) ->getStart : (sourceFile?: ts.SourceFile) => number, Symbol(ts.Node.getStart, Decl(typescript.d.ts, 1226, 53)) +>getStart : (sourceFile?: ts.SourceFile) => number, Symbol(ts.Node.getStart, Decl(typescript.d.ts, 1241, 53)) console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`); >console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`) : any @@ -286,9 +286,9 @@ fileNames.forEach(fileName => { let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); >sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 59, 7)) >ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true) : ts.SourceFile ->ts.createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile, Symbol(ts.createSourceFile, Decl(typescript.d.ts, 1190, 62)) +>ts.createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile, Symbol(ts.createSourceFile, Decl(typescript.d.ts, 1205, 62)) >ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6)) ->createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile, Symbol(ts.createSourceFile, Decl(typescript.d.ts, 1190, 62)) +>createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile, Symbol(ts.createSourceFile, Decl(typescript.d.ts, 1205, 62)) >fileName : any, Symbol(fileName, Decl(APISample_linter.ts, 57, 18)) >readFileSync(fileName).toString() : any >readFileSync(fileName).toString : any @@ -296,11 +296,11 @@ fileNames.forEach(fileName => { >readFileSync : any, Symbol(readFileSync, Decl(APISample_linter.ts, 9, 11)) >fileName : any, Symbol(fileName, Decl(APISample_linter.ts, 57, 18)) >toString : any ->ts.ScriptTarget.ES6 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES6, Decl(typescript.d.ts, 1118, 16)) ->ts.ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5)) +>ts.ScriptTarget.ES6 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES6, Decl(typescript.d.ts, 1133, 16)) +>ts.ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1130, 5)) >ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6)) ->ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5)) ->ES6 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES6, Decl(typescript.d.ts, 1118, 16)) +>ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1130, 5)) +>ES6 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES6, Decl(typescript.d.ts, 1133, 16)) >true : boolean // delint it diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index 6e27f70d87722..6e5f7c7ded21e 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -19,17 +19,17 @@ const source = "let x: string = 'string'"; let result = ts.transpile(source, { module: ts.ModuleKind.CommonJS }); >result : string, Symbol(result, Decl(APISample_transform.ts, 13, 3)) >ts.transpile(source, { module: ts.ModuleKind.CommonJS }) : string ->ts.transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string, Symbol(ts.transpile, Decl(typescript.d.ts, 1729, 5)) +>ts.transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string, Symbol(ts.transpile, Decl(typescript.d.ts, 1744, 5)) >ts : typeof ts, Symbol(ts, Decl(APISample_transform.ts, 9, 6)) ->transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string, Symbol(ts.transpile, Decl(typescript.d.ts, 1729, 5)) +>transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string, Symbol(ts.transpile, Decl(typescript.d.ts, 1744, 5)) >source : string, Symbol(source, Decl(APISample_transform.ts, 11, 5)) >{ module: ts.ModuleKind.CommonJS } : { [x: string]: ts.ModuleKind; module: ts.ModuleKind; } >module : ts.ModuleKind, Symbol(module, Decl(APISample_transform.ts, 13, 35)) ->ts.ModuleKind.CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17)) ->ts.ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5)) +>ts.ModuleKind.CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1123, 17)) +>ts.ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1121, 5)) >ts : typeof ts, Symbol(ts, Decl(APISample_transform.ts, 9, 6)) ->ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5)) ->CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17)) +>ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1121, 5)) +>CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1123, 17)) console.log(JSON.stringify(result)); >console.log(JSON.stringify(result)) : any diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index abc915e37763f..5d8a7fd5c7c57 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -26,7 +26,7 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { >rootFileNames : string[], Symbol(rootFileNames, Decl(APISample_watcher.ts, 14, 15)) >options : ts.CompilerOptions, Symbol(options, Decl(APISample_watcher.ts, 14, 39)) >ts : any, Symbol(ts, Decl(APISample_watcher.ts, 12, 6)) ->CompilerOptions : ts.CompilerOptions, Symbol(ts.CompilerOptions, Decl(typescript.d.ts, 1074, 5)) +>CompilerOptions : ts.CompilerOptions, Symbol(ts.CompilerOptions, Decl(typescript.d.ts, 1089, 5)) const files: ts.Map<{ version: number }> = {}; >files : ts.Map<{ version: number; }>, Symbol(files, Decl(APISample_watcher.ts, 15, 9)) @@ -59,7 +59,7 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { const servicesHost: ts.LanguageServiceHost = { >servicesHost : ts.LanguageServiceHost, Symbol(servicesHost, Decl(APISample_watcher.ts, 23, 9)) >ts : any, Symbol(ts, Decl(APISample_watcher.ts, 12, 6)) ->LanguageServiceHost : ts.LanguageServiceHost, Symbol(ts.LanguageServiceHost, Decl(typescript.d.ts, 1295, 5)) +>LanguageServiceHost : ts.LanguageServiceHost, Symbol(ts.LanguageServiceHost, Decl(typescript.d.ts, 1310, 5)) >{ getScriptFileNames: () => rootFileNames, getScriptVersion: (fileName) => files[fileName] && files[fileName].version.toString(), getScriptSnapshot: (fileName) => { if (!fs.existsSync(fileName)) { return undefined; } return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()); }, getCurrentDirectory: () => process.cwd(), getCompilationSettings: () => options, getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options), } : { getScriptFileNames: () => string[]; getScriptVersion: (fileName: string) => string; getScriptSnapshot: (fileName: string) => ts.IScriptSnapshot; getCurrentDirectory: () => any; getCompilationSettings: () => ts.CompilerOptions; getDefaultLibFileName: (options: ts.CompilerOptions) => string; } getScriptFileNames: () => rootFileNames, @@ -103,11 +103,11 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()); >ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()) : ts.IScriptSnapshot ->ts.ScriptSnapshot.fromString : (text: string) => ts.IScriptSnapshot, Symbol(ts.ScriptSnapshot.fromString, Decl(typescript.d.ts, 1288, 27)) ->ts.ScriptSnapshot : typeof ts.ScriptSnapshot, Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1287, 5)) +>ts.ScriptSnapshot.fromString : (text: string) => ts.IScriptSnapshot, Symbol(ts.ScriptSnapshot.fromString, Decl(typescript.d.ts, 1303, 27)) +>ts.ScriptSnapshot : typeof ts.ScriptSnapshot, Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1302, 5)) >ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6)) ->ScriptSnapshot : typeof ts.ScriptSnapshot, Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1287, 5)) ->fromString : (text: string) => ts.IScriptSnapshot, Symbol(ts.ScriptSnapshot.fromString, Decl(typescript.d.ts, 1288, 27)) +>ScriptSnapshot : typeof ts.ScriptSnapshot, Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1302, 5)) +>fromString : (text: string) => ts.IScriptSnapshot, Symbol(ts.ScriptSnapshot.fromString, Decl(typescript.d.ts, 1303, 27)) >fs.readFileSync(fileName).toString() : any >fs.readFileSync(fileName).toString : any >fs.readFileSync(fileName) : any @@ -136,9 +136,9 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { >(options) => ts.getDefaultLibFilePath(options) : (options: ts.CompilerOptions) => string >options : ts.CompilerOptions, Symbol(options, Decl(APISample_watcher.ts, 35, 32)) >ts.getDefaultLibFilePath(options) : string ->ts.getDefaultLibFilePath : (options: ts.CompilerOptions) => string, Symbol(ts.getDefaultLibFilePath, Decl(typescript.d.ts, 1737, 44)) +>ts.getDefaultLibFilePath : (options: ts.CompilerOptions) => string, Symbol(ts.getDefaultLibFilePath, Decl(typescript.d.ts, 1752, 44)) >ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6)) ->getDefaultLibFilePath : (options: ts.CompilerOptions) => string, Symbol(ts.getDefaultLibFilePath, Decl(typescript.d.ts, 1737, 44)) +>getDefaultLibFilePath : (options: ts.CompilerOptions) => string, Symbol(ts.getDefaultLibFilePath, Decl(typescript.d.ts, 1752, 44)) >options : ts.CompilerOptions, Symbol(options, Decl(APISample_watcher.ts, 35, 32)) }; @@ -147,14 +147,14 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { const services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry()) >services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9)) >ts.createLanguageService(servicesHost, ts.createDocumentRegistry()) : ts.LanguageService ->ts.createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService, Symbol(ts.createLanguageService, Decl(typescript.d.ts, 1735, 97)) +>ts.createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService, Symbol(ts.createLanguageService, Decl(typescript.d.ts, 1750, 97)) >ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6)) ->createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService, Symbol(ts.createLanguageService, Decl(typescript.d.ts, 1735, 97)) +>createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService, Symbol(ts.createLanguageService, Decl(typescript.d.ts, 1750, 97)) >servicesHost : ts.LanguageServiceHost, Symbol(servicesHost, Decl(APISample_watcher.ts, 23, 9)) >ts.createDocumentRegistry() : ts.DocumentRegistry ->ts.createDocumentRegistry : () => ts.DocumentRegistry, Symbol(ts.createDocumentRegistry, Decl(typescript.d.ts, 1733, 193)) +>ts.createDocumentRegistry : () => ts.DocumentRegistry, Symbol(ts.createDocumentRegistry, Decl(typescript.d.ts, 1748, 193)) >ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6)) ->createDocumentRegistry : () => ts.DocumentRegistry, Symbol(ts.createDocumentRegistry, Decl(typescript.d.ts, 1733, 193)) +>createDocumentRegistry : () => ts.DocumentRegistry, Symbol(ts.createDocumentRegistry, Decl(typescript.d.ts, 1748, 193)) // Now let's watch the files rootFileNames.forEach(fileName => { @@ -231,16 +231,16 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { let output = services.getEmitOutput(fileName); >output : ts.EmitOutput, Symbol(output, Decl(APISample_watcher.ts, 64, 11)) >services.getEmitOutput(fileName) : ts.EmitOutput ->services.getEmitOutput : (fileName: string) => ts.EmitOutput, Symbol(ts.LanguageService.getEmitOutput, Decl(typescript.d.ts, 1339, 132)) +>services.getEmitOutput : (fileName: string) => ts.EmitOutput, Symbol(ts.LanguageService.getEmitOutput, Decl(typescript.d.ts, 1354, 132)) >services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9)) ->getEmitOutput : (fileName: string) => ts.EmitOutput, Symbol(ts.LanguageService.getEmitOutput, Decl(typescript.d.ts, 1339, 132)) +>getEmitOutput : (fileName: string) => ts.EmitOutput, Symbol(ts.LanguageService.getEmitOutput, Decl(typescript.d.ts, 1354, 132)) >fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 63, 22)) if (!output.emitSkipped) { >!output.emitSkipped : boolean ->output.emitSkipped : boolean, Symbol(ts.EmitOutput.emitSkipped, Decl(typescript.d.ts, 1542, 34)) +>output.emitSkipped : boolean, Symbol(ts.EmitOutput.emitSkipped, Decl(typescript.d.ts, 1557, 34)) >output : ts.EmitOutput, Symbol(output, Decl(APISample_watcher.ts, 64, 11)) ->emitSkipped : boolean, Symbol(ts.EmitOutput.emitSkipped, Decl(typescript.d.ts, 1542, 34)) +>emitSkipped : boolean, Symbol(ts.EmitOutput.emitSkipped, Decl(typescript.d.ts, 1557, 34)) console.log(`Emitting ${fileName}`); >console.log(`Emitting ${fileName}`) : any @@ -268,9 +268,9 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { output.outputFiles.forEach(o => { >output.outputFiles.forEach(o => { fs.writeFileSync(o.name, o.text, "utf8"); }) : void >output.outputFiles.forEach : (callbackfn: (value: ts.OutputFile, index: number, array: ts.OutputFile[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95)) ->output.outputFiles : ts.OutputFile[], Symbol(ts.EmitOutput.outputFiles, Decl(typescript.d.ts, 1541, 26)) +>output.outputFiles : ts.OutputFile[], Symbol(ts.EmitOutput.outputFiles, Decl(typescript.d.ts, 1556, 26)) >output : ts.EmitOutput, Symbol(output, Decl(APISample_watcher.ts, 64, 11)) ->outputFiles : ts.OutputFile[], Symbol(ts.EmitOutput.outputFiles, Decl(typescript.d.ts, 1541, 26)) +>outputFiles : ts.OutputFile[], Symbol(ts.EmitOutput.outputFiles, Decl(typescript.d.ts, 1556, 26)) >forEach : (callbackfn: (value: ts.OutputFile, index: number, array: ts.OutputFile[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95)) >o => { fs.writeFileSync(o.name, o.text, "utf8"); } : (o: ts.OutputFile) => void >o : ts.OutputFile, Symbol(o, Decl(APISample_watcher.ts, 74, 35)) @@ -280,12 +280,12 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { >fs.writeFileSync : any >fs : any, Symbol(fs, Decl(APISample_watcher.ts, 9, 11)) >writeFileSync : any ->o.name : string, Symbol(ts.OutputFile.name, Decl(typescript.d.ts, 1550, 26)) +>o.name : string, Symbol(ts.OutputFile.name, Decl(typescript.d.ts, 1565, 26)) >o : ts.OutputFile, Symbol(o, Decl(APISample_watcher.ts, 74, 35)) ->name : string, Symbol(ts.OutputFile.name, Decl(typescript.d.ts, 1550, 26)) ->o.text : string, Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1552, 36)) +>name : string, Symbol(ts.OutputFile.name, Decl(typescript.d.ts, 1565, 26)) +>o.text : string, Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1567, 36)) >o : ts.OutputFile, Symbol(o, Decl(APISample_watcher.ts, 74, 35)) ->text : string, Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1552, 36)) +>text : string, Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1567, 36)) >"utf8" : string }); @@ -302,24 +302,24 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { >services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) : ts.Diagnostic[] >services.getCompilerOptionsDiagnostics() .concat : { (...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46)) >services.getCompilerOptionsDiagnostics() : ts.Diagnostic[] ->services.getCompilerOptionsDiagnostics : () => ts.Diagnostic[], Symbol(ts.LanguageService.getCompilerOptionsDiagnostics, Decl(typescript.d.ts, 1313, 63)) +>services.getCompilerOptionsDiagnostics : () => ts.Diagnostic[], Symbol(ts.LanguageService.getCompilerOptionsDiagnostics, Decl(typescript.d.ts, 1328, 63)) >services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9)) ->getCompilerOptionsDiagnostics : () => ts.Diagnostic[], Symbol(ts.LanguageService.getCompilerOptionsDiagnostics, Decl(typescript.d.ts, 1313, 63)) +>getCompilerOptionsDiagnostics : () => ts.Diagnostic[], Symbol(ts.LanguageService.getCompilerOptionsDiagnostics, Decl(typescript.d.ts, 1328, 63)) .concat(services.getSyntacticDiagnostics(fileName)) >concat : { (...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46)) >services.getSyntacticDiagnostics(fileName) : ts.Diagnostic[] ->services.getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSyntacticDiagnostics, Decl(typescript.d.ts, 1311, 37)) +>services.getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSyntacticDiagnostics, Decl(typescript.d.ts, 1326, 37)) >services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9)) ->getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSyntacticDiagnostics, Decl(typescript.d.ts, 1311, 37)) +>getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSyntacticDiagnostics, Decl(typescript.d.ts, 1326, 37)) >fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 79, 23)) .concat(services.getSemanticDiagnostics(fileName)); >concat : { (...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46)) >services.getSemanticDiagnostics(fileName) : ts.Diagnostic[] ->services.getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSemanticDiagnostics, Decl(typescript.d.ts, 1312, 64)) +>services.getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSemanticDiagnostics, Decl(typescript.d.ts, 1327, 64)) >services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9)) ->getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSemanticDiagnostics, Decl(typescript.d.ts, 1312, 64)) +>getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSemanticDiagnostics, Decl(typescript.d.ts, 1327, 64)) >fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 79, 23)) allDiagnostics.forEach(diagnostic => { @@ -333,31 +333,31 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); >message : string, Symbol(message, Decl(APISample_watcher.ts, 85, 15)) >ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n") : string ->ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1200, 67)) +>ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1215, 67)) >ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6)) ->flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1200, 67)) ->diagnostic.messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23)) +>flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1215, 67)) +>diagnostic.messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1080, 23)) >diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31)) ->messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23)) +>messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1080, 23)) >"\n" : string if (diagnostic.file) { ->diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26)) +>diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1077, 26)) >diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31)) ->file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26)) +>file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1077, 26)) let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); >line : number, Symbol(line, Decl(APISample_watcher.ts, 87, 21)) >character : number, Symbol(character, Decl(APISample_watcher.ts, 87, 27)) >diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter ->diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1263, 46)) ->diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26)) +>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1278, 46)) +>diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1077, 26)) >diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31)) ->file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26)) ->getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1263, 46)) ->diagnostic.start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25)) +>file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1077, 26)) +>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1278, 46)) +>diagnostic.start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1078, 25)) >diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31)) ->start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25)) +>start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1078, 25)) console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); >console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`) : any @@ -366,9 +366,9 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { >log : any >` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}` : string >diagnostic.file.fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29)) ->diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26)) +>diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1077, 26)) >diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31)) ->file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26)) +>file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1077, 26)) >fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29)) >line + 1 : number >line : number, Symbol(line, Decl(APISample_watcher.ts, 87, 21)) @@ -435,9 +435,9 @@ watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }); >currentDirectoryFiles : any, Symbol(currentDirectoryFiles, Decl(APISample_watcher.ts, 98, 5)) >{ module: ts.ModuleKind.CommonJS } : { [x: string]: ts.ModuleKind; module: ts.ModuleKind; } >module : ts.ModuleKind, Symbol(module, Decl(APISample_watcher.ts, 102, 30)) ->ts.ModuleKind.CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17)) ->ts.ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5)) +>ts.ModuleKind.CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1123, 17)) +>ts.ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1121, 5)) >ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6)) ->ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5)) ->CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17)) +>ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1121, 5)) +>CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1123, 17)) diff --git a/tests/baselines/reference/arraySigChecking.errors.txt b/tests/baselines/reference/arraySigChecking.errors.txt index b70b659773c75..cecdf7ddb99b0 100644 --- a/tests/baselines/reference/arraySigChecking.errors.txt +++ b/tests/baselines/reference/arraySigChecking.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/arraySigChecking.ts(11,17): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/compiler/arraySigChecking.ts(11,17): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. tests/cases/compiler/arraySigChecking.ts(18,5): error TS2322: Type 'void[]' is not assignable to type 'string[]'. Type 'void' is not assignable to type 'string'. tests/cases/compiler/arraySigChecking.ts(22,1): error TS2322: Type 'number[][]' is not assignable to type 'number[][][]'. @@ -20,7 +20,7 @@ tests/cases/compiler/arraySigChecking.ts(22,1): error TS2322: Type 'number[][]' var foo: { [index: any]; }; // expect an error here ~~~~~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } interface myInt { diff --git a/tests/baselines/reference/assignmentCompat1.errors.txt b/tests/baselines/reference/assignmentCompat1.errors.txt index 6734e6fc964d4..52c7413b44f92 100644 --- a/tests/baselines/reference/assignmentCompat1.errors.txt +++ b/tests/baselines/reference/assignmentCompat1.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/assignmentCompat1.ts(4,1): error TS2322: Type '{ [index: string]: any; }' is not assignable to type '{ one: number; }'. Property 'one' is missing in type '{ [index: string]: any; }'. tests/cases/compiler/assignmentCompat1.ts(5,1): error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: any; }'. - Index signature is missing in type '{ one: number; }'. + Missing [string] index signature in type '{ one: number; }'. ==== tests/cases/compiler/assignmentCompat1.ts (2 errors) ==== @@ -15,4 +15,4 @@ tests/cases/compiler/assignmentCompat1.ts(5,1): error TS2322: Type '{ one: numbe y = x; ~ !!! error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: any; }'. -!!! error TS2322: Index signature is missing in type '{ one: number; }'. \ No newline at end of file +!!! error TS2322: Missing [string] index signature in type '{ one: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.errors.txt b/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.errors.txt index 65c1d30779375..68bcb23e81c5d 100644 --- a/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.errors.txt +++ b/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/assignmentCompatInterfaceWithStringIndexSignature.ts(15,5): error TS2345: Argument of type 'Foo' is not assignable to parameter of type 'IHandlerMap'. - Index signature is missing in type 'Foo'. + Missing [string] index signature in type 'Foo'. ==== tests/cases/compiler/assignmentCompatInterfaceWithStringIndexSignature.ts (1 errors) ==== @@ -20,5 +20,5 @@ tests/cases/compiler/assignmentCompatInterfaceWithStringIndexSignature.ts(15,5): Biz(new Foo()); ~~~~~~~~~ !!! error TS2345: Argument of type 'Foo' is not assignable to parameter of type 'IHandlerMap'. -!!! error TS2345: Index signature is missing in type 'Foo'. +!!! error TS2345: Missing [string] index signature in type 'Foo'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt b/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt index 0a9b50ff0b81e..e9166ce75d1f5 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer.errors.txt @@ -1,22 +1,22 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(14,1): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. - Index signatures are incompatible. + Index signatures '[number]: Base' and '[number]: Derived' are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(18,1): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. - Index signatures are incompatible. + Index signatures '[number]: Base' and '[number]: Derived2' are incompatible. Type 'Base' is not assignable to type 'Derived2'. Property 'baz' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(32,9): error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. - Index signatures are incompatible. + Index signatures '[number]: Derived' and '[number]: T' are incompatible. Type 'Derived' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(33,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. - Index signatures are incompatible. + Index signatures '[number]: T' and '[number]: Derived' are incompatible. Type 'T' is not assignable to type 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(36,9): error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. - Index signatures are incompatible. + Index signatures '[number]: Derived2' and '[number]: T' are incompatible. Type 'Derived2' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(37,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. - Index signatures are incompatible. + Index signatures '[number]: T' and '[number]: Derived2' are incompatible. Type 'T' is not assignable to type 'Derived2'. @@ -37,7 +37,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b = a; // error ~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: Base' and '[number]: Derived' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'Derived'. !!! error TS2322: Property 'bar' is missing in type 'Base'. @@ -46,7 +46,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b2 = a; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: Base' and '[number]: Derived2' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'Derived2'. !!! error TS2322: Property 'baz' is missing in type 'Base'. @@ -65,24 +65,24 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a = b; // error ~ !!! error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: Derived' and '[number]: T' are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. b = a; // error ~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: T' and '[number]: Derived' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived'. var b2: { [x: number]: Derived2; } a = b2; // error ~ !!! error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: Derived2' and '[number]: T' are incompatible. !!! error TS2322: Type 'Derived2' is not assignable to type 'T'. b2 = a; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: T' and '[number]: Derived2' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. var b3: { [x: number]: T; } diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt index b15f2f7905d55..6d50625d3202b 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.errors.txt @@ -1,22 +1,22 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(14,1): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. - Index signatures are incompatible. + Index signatures '[number]: Base' and '[number]: Derived' are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(18,1): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. - Index signatures are incompatible. + Index signatures '[number]: Base' and '[number]: Derived2' are incompatible. Type 'Base' is not assignable to type 'Derived2'. Property 'baz' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(32,9): error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. - Index signatures are incompatible. + Index signatures '[number]: Derived' and '[number]: T' are incompatible. Type 'Derived' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(33,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. - Index signatures are incompatible. + Index signatures '[number]: T' and '[number]: Derived' are incompatible. Type 'T' is not assignable to type 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(36,9): error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. - Index signatures are incompatible. + Index signatures '[number]: Derived2' and '[number]: T' are incompatible. Type 'Derived2' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(37,9): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. - Index signatures are incompatible. + Index signatures '[number]: T' and '[number]: Derived2' are incompatible. Type 'T' is not assignable to type 'Derived2'. @@ -37,7 +37,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b = a; // error ~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: Base' and '[number]: Derived' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'Derived'. !!! error TS2322: Property 'bar' is missing in type 'Base'. @@ -46,7 +46,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b2 = a; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: Base' and '[number]: Derived2' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'Derived2'. !!! error TS2322: Property 'baz' is missing in type 'Base'. @@ -65,24 +65,24 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a = b; // error ~ !!! error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: Derived' and '[number]: T' are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. b = a; // error ~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: T' and '[number]: Derived' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived'. var b2: { [x: number]: Derived2; } a = b2; // error ~ !!! error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: Derived2' and '[number]: T' are incompatible. !!! error TS2322: Type 'Derived2' is not assignable to type 'T'. b2 = a; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: T' and '[number]: Derived2' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. var b3: { [x: number]: T; } diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.errors.txt b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.errors.txt index 61f9e082a481c..50ae7846e43a1 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.errors.txt @@ -1,13 +1,13 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts(14,1): error TS2322: Type '{ [x: number]: Base; }' is not assignable to type 'A'. - Index signatures are incompatible. + Index signatures '[number]: Base' and '[number]: Derived' are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts(23,1): error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. - Index signatures are incompatible. + Index signatures '[number]: Derived' and '[number]: Derived2' are incompatible. Type 'Derived' is not assignable to type 'Derived2'. Property 'baz' is missing in type 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts(33,9): error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. - Index signatures are incompatible. + Index signatures '[number]: Derived' and '[number]: T' are incompatible. Type 'Derived' is not assignable to type 'T'. @@ -28,7 +28,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a = b; // error ~ !!! error TS2322: Type '{ [x: number]: Base; }' is not assignable to type 'A'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: Base' and '[number]: Derived' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'Derived'. !!! error TS2322: Property 'bar' is missing in type 'Base'. b = a; // ok @@ -42,7 +42,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b2 = a; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: number]: Derived2; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: Derived' and '[number]: Derived2' are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'Derived2'. !!! error TS2322: Property 'baz' is missing in type 'Derived'. @@ -57,7 +57,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a = b; // error ~ !!! error TS2322: Type '{ [x: number]: Derived; }' is not assignable to type 'A'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: Derived' and '[number]: T' are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. b = a; // ok diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt b/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt index f002c70e90b0b..e01902b6d7cc5 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer.errors.txt @@ -1,28 +1,28 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(15,1): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. - Index signatures are incompatible. + Index signatures '[string]: Base' and '[string]: Derived' are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(19,1): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. - Index signatures are incompatible. + Index signatures '[string]: Base' and '[string]: Derived2' are incompatible. Type 'Base' is not assignable to type 'Derived2'. Property 'baz' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(33,5): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. - Index signatures are incompatible. + Index signatures '[string]: Base' and '[string]: Derived' are incompatible. Type 'Base' is not assignable to type 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(41,5): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. - Index signatures are incompatible. + Index signatures '[string]: Base' and '[string]: Derived2' are incompatible. Type 'Base' is not assignable to type 'Derived2'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(46,9): error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. - Index signatures are incompatible. + Index signatures '[string]: Derived' and '[string]: T' are incompatible. Type 'Derived' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(47,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. - Index signatures are incompatible. + Index signatures '[string]: T' and '[string]: Derived' are incompatible. Type 'T' is not assignable to type 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(50,9): error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. - Index signatures are incompatible. + Index signatures '[string]: Derived2' and '[string]: T' are incompatible. Type 'Derived2' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(51,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. - Index signatures are incompatible. + Index signatures '[string]: T' and '[string]: Derived2' are incompatible. Type 'T' is not assignable to type 'Derived2'. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b = a; // error ~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: Base' and '[string]: Derived' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'Derived'. !!! error TS2322: Property 'bar' is missing in type 'Base'. @@ -53,7 +53,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b2 = a; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: Base' and '[string]: Derived2' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'Derived2'. !!! error TS2322: Property 'baz' is missing in type 'Base'. @@ -72,7 +72,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b1 = a1; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: Base' and '[string]: Derived' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'Derived'. class B2 extends A { @@ -84,7 +84,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b2 = a1; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: Base' and '[string]: Derived2' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'Derived2'. function foo() { @@ -93,24 +93,24 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a3 = b3; // error ~~ !!! error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: Derived' and '[string]: T' are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. b3 = a3; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: T' and '[string]: Derived' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived'. var b4: { [x: string]: Derived2; }; a3 = b4; // error ~~ !!! error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: Derived2' and '[string]: T' are incompatible. !!! error TS2322: Type 'Derived2' is not assignable to type 'T'. b4 = a3; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: T' and '[string]: Derived2' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. } } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt b/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt index c322364280ebf..f446cd076a729 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer2.errors.txt @@ -1,28 +1,28 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(15,1): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. - Index signatures are incompatible. + Index signatures '[string]: Base' and '[string]: Derived' are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(19,1): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. - Index signatures are incompatible. + Index signatures '[string]: Base' and '[string]: Derived2' are incompatible. Type 'Base' is not assignable to type 'Derived2'. Property 'baz' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(33,5): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. - Index signatures are incompatible. + Index signatures '[string]: Base' and '[string]: Derived' are incompatible. Type 'Base' is not assignable to type 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(41,5): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. - Index signatures are incompatible. + Index signatures '[string]: Base' and '[string]: Derived2' are incompatible. Type 'Base' is not assignable to type 'Derived2'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(46,9): error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. - Index signatures are incompatible. + Index signatures '[string]: Derived' and '[string]: T' are incompatible. Type 'Derived' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(47,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. - Index signatures are incompatible. + Index signatures '[string]: T' and '[string]: Derived' are incompatible. Type 'T' is not assignable to type 'Derived'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(50,9): error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. - Index signatures are incompatible. + Index signatures '[string]: Derived2' and '[string]: T' are incompatible. Type 'Derived2' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(51,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. - Index signatures are incompatible. + Index signatures '[string]: T' and '[string]: Derived2' are incompatible. Type 'T' is not assignable to type 'Derived2'. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b = a; // error ~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: Base' and '[string]: Derived' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'Derived'. !!! error TS2322: Property 'bar' is missing in type 'Base'. @@ -53,7 +53,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b2 = a; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: Base' and '[string]: Derived2' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'Derived2'. !!! error TS2322: Property 'baz' is missing in type 'Base'. @@ -72,7 +72,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b1 = a1; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: Base' and '[string]: Derived' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'Derived'. interface B2 extends A { @@ -84,7 +84,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b2 = a1; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: Base' and '[string]: Derived2' are incompatible. !!! error TS2322: Type 'Base' is not assignable to type 'Derived2'. function foo() { @@ -93,24 +93,24 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a3 = b3; // error ~~ !!! error TS2322: Type '{ [x: string]: Derived; }' is not assignable to type 'A'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: Derived' and '[string]: T' are incompatible. !!! error TS2322: Type 'Derived' is not assignable to type 'T'. b3 = a3; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: T' and '[string]: Derived' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived'. var b4: { [x: string]: Derived2; }; a3 = b4; // error ~~ !!! error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: Derived2' and '[string]: T' are incompatible. !!! error TS2322: Type 'Derived2' is not assignable to type 'T'. b4 = a3; // error ~~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: Derived2; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: T' and '[string]: Derived2' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'Derived2'. } } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer3.errors.txt b/tests/baselines/reference/assignmentCompatWithStringIndexer3.errors.txt index a31b2ef30250f..e719334f1aa12 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer3.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts(7,8): error TS2304: Cannot find name 'A'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts(20,9): error TS2322: Type '{ [x: string]: string; }' is not assignable to type 'A'. - Index signatures are incompatible. + Index signatures '[string]: string' and '[string]: T' are incompatible. Type 'string' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts(21,9): error TS2322: Type 'A' is not assignable to type '{ [x: string]: string; }'. - Index signatures are incompatible. + Index signatures '[string]: T' and '[string]: string' are incompatible. Type 'T' is not assignable to type 'string'. @@ -32,12 +32,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a = b; // error ~ !!! error TS2322: Type '{ [x: string]: string; }' is not assignable to type 'A'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: string' and '[string]: T' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'T'. b = a; // error ~ !!! error TS2322: Type 'A' is not assignable to type '{ [x: string]: string; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: T' and '[string]: string' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'string'. } } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability35.errors.txt b/tests/baselines/reference/assignmentCompatability35.errors.txt index 2073b861f523b..c847b08c017bd 100644 --- a/tests/baselines/reference/assignmentCompatability35.errors.txt +++ b/tests/baselines/reference/assignmentCompatability35.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/assignmentCompatability35.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ [index: number]: number; }'. - Index signature is missing in type 'interfaceWithPublicAndOptional'. + Missing [string] or [number] index signature in type 'interfaceWithPublicAndOptional'. ==== tests/cases/compiler/assignmentCompatability35.ts (1 errors) ==== @@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability35.ts(9,1): error TS2322: Type 'inte __test2__.__val__aa = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ [index: number]: number; }'. -!!! error TS2322: Index signature is missing in type 'interfaceWithPublicAndOptional'. \ No newline at end of file +!!! error TS2322: Missing [string] or [number] index signature in type 'interfaceWithPublicAndOptional'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability36.errors.txt b/tests/baselines/reference/assignmentCompatability36.errors.txt index 591dc072fab36..6b383e80fa10a 100644 --- a/tests/baselines/reference/assignmentCompatability36.errors.txt +++ b/tests/baselines/reference/assignmentCompatability36.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/assignmentCompatability36.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ [index: string]: any; }'. - Index signature is missing in type 'interfaceWithPublicAndOptional'. + Missing [string] index signature in type 'interfaceWithPublicAndOptional'. ==== tests/cases/compiler/assignmentCompatability36.ts (1 errors) ==== @@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability36.ts(9,1): error TS2322: Type 'inte __test2__.__val__aa = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ [index: string]: any; }'. -!!! error TS2322: Index signature is missing in type 'interfaceWithPublicAndOptional'. \ No newline at end of file +!!! error TS2322: Missing [string] index signature in type 'interfaceWithPublicAndOptional'. \ No newline at end of file diff --git a/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.errors.txt b/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.errors.txt index eb5020e97f97e..4d6af0e8a1ed6 100644 --- a/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.errors.txt +++ b/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts(15,5): error TS2322: Type '{}' is not assignable to type '{ [n: number]: Foo; }'. - Index signature is missing in type '{}'. + Missing [string] or [number] index signature in type '{}'. tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts(19,5): error TS2322: Type '() => void' is not assignable to type '{ [n: number]: Bar; }'. - Index signature is missing in type '() => void'. + Missing [string] or [number] index signature in type '() => void'. ==== tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts (2 errors) ==== @@ -22,13 +22,13 @@ tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignatur var v1: { ~~ !!! error TS2322: Type '{}' is not assignable to type '{ [n: number]: Foo; }'. -!!! error TS2322: Index signature is missing in type '{}'. +!!! error TS2322: Missing [string] or [number] index signature in type '{}'. [n: number]: Foo } = o; // Should be allowed var v2: { ~~ !!! error TS2322: Type '() => void' is not assignable to type '{ [n: number]: Bar; }'. -!!! error TS2322: Index signature is missing in type '() => void'. +!!! error TS2322: Missing [string] or [number] index signature in type '() => void'. [n: number]: Bar } = f; // Should be allowed \ No newline at end of file diff --git a/tests/baselines/reference/classIndexer2.errors.txt b/tests/baselines/reference/classIndexer2.errors.txt index 82629584ee562..ebaa36492064e 100644 --- a/tests/baselines/reference/classIndexer2.errors.txt +++ b/tests/baselines/reference/classIndexer2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classIndexer2.ts(4,5): error TS2411: Property 'y' of type 'string' is not assignable to string index type 'number'. +tests/cases/compiler/classIndexer2.ts(4,5): error TS2411: Property 'y' of type 'string' is not assignable to string index '[string]: number'. ==== tests/cases/compiler/classIndexer2.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/classIndexer2.ts(4,5): error TS2411: Property 'y' of type ' x: number; y: string; ~~~~~~~~~~ -!!! error TS2411: Property 'y' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property 'y' of type 'string' is not assignable to string index '[string]: number'. constructor() { } } \ No newline at end of file diff --git a/tests/baselines/reference/classIndexer3.errors.txt b/tests/baselines/reference/classIndexer3.errors.txt index eb7a2467fbaa9..561439ad113ef 100644 --- a/tests/baselines/reference/classIndexer3.errors.txt +++ b/tests/baselines/reference/classIndexer3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classIndexer3.ts(9,5): error TS2411: Property 'y' of type 'string' is not assignable to string index type 'number'. +tests/cases/compiler/classIndexer3.ts(9,5): error TS2411: Property 'y' of type 'string' is not assignable to string index '[string]: number'. ==== tests/cases/compiler/classIndexer3.ts (1 errors) ==== @@ -12,5 +12,5 @@ tests/cases/compiler/classIndexer3.ts(9,5): error TS2411: Property 'y' of type ' x: number; y: string; ~~~~~~~~~~ -!!! error TS2411: Property 'y' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property 'y' of type 'string' is not assignable to string index '[string]: number'. } \ No newline at end of file diff --git a/tests/baselines/reference/classIndexer4.errors.txt b/tests/baselines/reference/classIndexer4.errors.txt index f5a132b3dc254..375b908b2fbd3 100644 --- a/tests/baselines/reference/classIndexer4.errors.txt +++ b/tests/baselines/reference/classIndexer4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classIndexer4.ts(9,5): error TS2411: Property 'y' of type 'string' is not assignable to string index type 'number'. +tests/cases/compiler/classIndexer4.ts(9,5): error TS2411: Property 'y' of type 'string' is not assignable to string index '[string]: number'. ==== tests/cases/compiler/classIndexer4.ts (1 errors) ==== @@ -12,5 +12,5 @@ tests/cases/compiler/classIndexer4.ts(9,5): error TS2411: Property 'y' of type ' x: number; y: string; ~~~~~~~~~~ -!!! error TS2411: Property 'y' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property 'y' of type 'string' is not assignable to string index '[string]: number'. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames36_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames36_ES5.errors.txt index 6c38043c8e0f2..23013f7eb5eb6 100644 --- a/tests/baselines/reference/computedPropertyNames36_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames36_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES5.ts(8,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES5.ts(8,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES5.ts (1 errors) ==== @@ -11,6 +11,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES5.ts(8, // Computed properties get ["get1"]() { return new Foo } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. set ["set1"](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames36_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames36_ES6.errors.txt index 8127898fde467..c616cc64e5e8e 100644 --- a/tests/baselines/reference/computedPropertyNames36_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames36_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES6.ts(8,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES6.ts(8,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES6.ts (1 errors) ==== @@ -11,6 +11,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES6.ts(8, // Computed properties get ["get1"]() { return new Foo } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. set ["set1"](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames38_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames38_ES5.errors.txt index acc08ee5527a5..64f13559b2ded 100644 --- a/tests/baselines/reference/computedPropertyNames38_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames38_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES5.ts(8,5): error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES5.ts(8,5): error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index '[string]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES5.ts (1 errors) ==== @@ -11,6 +11,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES5.ts(8, // Computed properties get [1 << 6]() { return new Foo } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index '[string]: Foo2'. set [1 << 6](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames38_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames38_ES6.errors.txt index 0a95b37f9a9a0..1e694d7e9fed5 100644 --- a/tests/baselines/reference/computedPropertyNames38_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames38_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES6.ts(8,5): error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES6.ts(8,5): error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index '[string]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES6.ts (1 errors) ==== @@ -11,6 +11,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES6.ts(8, // Computed properties get [1 << 6]() { return new Foo } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index '[string]: Foo2'. set [1 << 6](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames39_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames39_ES5.errors.txt index 669314676f9cc..c6fd815118d03 100644 --- a/tests/baselines/reference/computedPropertyNames39_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames39_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES5.ts(8,5): error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES5.ts(8,5): error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index '[number]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES5.ts (1 errors) ==== @@ -11,6 +11,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES5.ts(8, // Computed properties get [1 << 6]() { return new Foo } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'. +!!! error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index '[number]: Foo2'. set [1 << 6](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames39_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames39_ES6.errors.txt index 38f432162d53d..b86bb8683739f 100644 --- a/tests/baselines/reference/computedPropertyNames39_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames39_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES6.ts(8,5): error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES6.ts(8,5): error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index '[number]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES6.ts (1 errors) ==== @@ -11,6 +11,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES6.ts(8, // Computed properties get [1 << 6]() { return new Foo } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'. +!!! error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index '[number]: Foo2'. set [1 << 6](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames40_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames40_ES5.errors.txt index e8ceef0d58115..125510e3e4b37 100644 --- a/tests/baselines/reference/computedPropertyNames40_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames40_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES5.ts(8,5): error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index type '() => Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES5.ts(8,5): error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index '[string]: () => Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES5.ts (1 errors) ==== @@ -11,6 +11,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES5.ts(8, // Computed properties [""]() { return new Foo } ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index type '() => Foo2'. +!!! error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index '[string]: () => Foo2'. [""]() { return new Foo2 } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames40_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames40_ES6.errors.txt index 1a032a87b2b00..e7fab20974572 100644 --- a/tests/baselines/reference/computedPropertyNames40_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames40_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES6.ts(8,5): error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index type '() => Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES6.ts(8,5): error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index '[string]: () => Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES6.ts (1 errors) ==== @@ -11,6 +11,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES6.ts(8, // Computed properties [""]() { return new Foo } ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index type '() => Foo2'. +!!! error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index '[string]: () => Foo2'. [""]() { return new Foo2 } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames42_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames42_ES5.errors.txt index 94153c47aa5d4..9f281c20674b4 100644 --- a/tests/baselines/reference/computedPropertyNames42_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames42_ES5.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES5.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES5.ts(8,5): error TS2411: Property '[""]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES5.ts(8,5): error TS2411: Property '[""]' of type 'Foo' is not assignable to string index '[string]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES5.ts (2 errors) ==== @@ -14,5 +14,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES5.ts(8, ~~~~ !!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. ~~~~~~~~~~ -!!! error TS2411: Property '[""]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '[""]' of type 'Foo' is not assignable to string index '[string]: Foo2'. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames42_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames42_ES6.errors.txt index 1f4e27d6e810a..ab0627b32f3d7 100644 --- a/tests/baselines/reference/computedPropertyNames42_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames42_ES6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES6.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES6.ts(8,5): error TS2411: Property '[""]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES6.ts(8,5): error TS2411: Property '[""]' of type 'Foo' is not assignable to string index '[string]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES6.ts (2 errors) ==== @@ -14,5 +14,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES6.ts(8, ~~~~ !!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. ~~~~~~~~~~ -!!! error TS2411: Property '[""]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '[""]' of type 'Foo' is not assignable to string index '[string]: Foo2'. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames43_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames43_ES5.errors.txt index 62c239a5a54b9..63d35ba5cb350 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames43_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES5.ts(10,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES5.ts(10,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES5.ts (1 errors) ==== @@ -13,6 +13,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES5.ts(10 // Computed properties get ["get1"]() { return new Foo } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. set ["set1"](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames43_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames43_ES6.errors.txt index 0efe0ba39ec84..5c1f4ebc76431 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames43_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES6.ts(10,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES6.ts(10,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES6.ts (1 errors) ==== @@ -13,6 +13,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES6.ts(10 // Computed properties get ["get1"]() { return new Foo } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. set ["set1"](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames44_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames44_ES5.errors.txt index 35ab422e0934a..9587ec629f078 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames44_ES5.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(6,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. -tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(10,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(6,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(10,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts (2 errors) ==== @@ -10,11 +10,11 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(10 [s: string]: Foo2; get ["get1"]() { return new Foo } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. } class D extends C { set ["set1"](p: Foo) { } ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames44_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames44_ES6.errors.txt index 5170746395cd0..1f187d825b96d 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames44_ES6.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(6,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. -tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(10,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(6,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(10,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts (2 errors) ==== @@ -10,11 +10,11 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(10 [s: string]: Foo2; get ["get1"]() { return new Foo } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. } class D extends C { set ["set1"](p: Foo) { } ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames45_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames45_ES5.errors.txt index 83855c5f0b7e2..05b8c5a72b726 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames45_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(11,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(11,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts (1 errors) ==== @@ -14,5 +14,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(11 [s: string]: Foo2; set ["set1"](p: Foo) { } ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames45_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames45_ES6.errors.txt index 963e01ed86bd8..a9e023151a6d6 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames45_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(11,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(11,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts (1 errors) ==== @@ -14,5 +14,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(11 [s: string]: Foo2; set ["set1"](p: Foo) { } ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +!!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index '[string]: Foo2'. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.errors.txt index 7fa95fe942616..b4337a4e3dfbd 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType10_ES5.ts(5,5): error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. - Index signatures are incompatible. + Index signatures '[number]: string | number' and '[number]: boolean' are incompatible. Type 'string | number' is not assignable to type 'boolean'. Type 'string' is not assignable to type 'boolean'. @@ -12,7 +12,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualTy var o: I = { ~ !!! error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: string | number' and '[number]: boolean' are incompatible. !!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. !!! error TS2322: Type 'string' is not assignable to type 'boolean'. [+"foo"]: "", diff --git a/tests/baselines/reference/computedPropertyNamesContextualType10_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType10_ES6.errors.txt index 116cd1a25311e..b173ce0e8040f 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType10_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType10_ES6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType10_ES6.ts(5,5): error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. - Index signatures are incompatible. + Index signatures '[number]: string | number' and '[number]: boolean' are incompatible. Type 'string | number' is not assignable to type 'boolean'. Type 'string' is not assignable to type 'boolean'. @@ -12,7 +12,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualTy var o: I = { ~ !!! error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: string | number' and '[number]: boolean' are incompatible. !!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. !!! error TS2322: Type 'string' is not assignable to type 'boolean'. [+"foo"]: "", diff --git a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt index 3376243e3707f..266adb1210a1f 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts(6,5): error TS2322: Type '{ [x: string]: string | number; [x: number]: undefined; }' is not assignable to type 'I'. - Index signatures are incompatible. + Index signatures '[string]: string | number' and '[string]: boolean' are incompatible. Type 'string | number' is not assignable to type 'boolean'. Type 'string' is not assignable to type 'boolean'. @@ -13,7 +13,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualTy var o: I = { ~ !!! error TS2322: Type '{ [x: string]: string | number; [x: number]: undefined; }' is not assignable to type 'I'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: string | number' and '[string]: boolean' are incompatible. !!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. !!! error TS2322: Type 'string' is not assignable to type 'boolean'. [""+"foo"]: "", diff --git a/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt index e4540337ed4f0..a066532542119 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES6.ts(6,5): error TS2322: Type '{ [x: string]: string | number; [x: number]: undefined; }' is not assignable to type 'I'. - Index signatures are incompatible. + Index signatures '[string]: string | number' and '[string]: boolean' are incompatible. Type 'string | number' is not assignable to type 'boolean'. Type 'string' is not assignable to type 'boolean'. @@ -13,7 +13,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualTy var o: I = { ~ !!! error TS2322: Type '{ [x: string]: string | number; [x: number]: undefined; }' is not assignable to type 'I'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: string | number' and '[string]: boolean' are incompatible. !!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. !!! error TS2322: Type 'string' is not assignable to type 'boolean'. [""+"foo"]: "", diff --git a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.errors.txt index d4085a37e6053..786382a626ecd 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType9_ES5.ts(6,5): error TS2322: Type '{ [x: string]: string | number; [x: number]: string | number; }' is not assignable to type 'I'. - Index signatures are incompatible. + Index signatures '[string]: string | number' and '[string]: boolean' are incompatible. Type 'string | number' is not assignable to type 'boolean'. Type 'string' is not assignable to type 'boolean'. @@ -13,7 +13,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualTy var o: I = { ~ !!! error TS2322: Type '{ [x: string]: string | number; [x: number]: string | number; }' is not assignable to type 'I'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: string | number' and '[string]: boolean' are incompatible. !!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. !!! error TS2322: Type 'string' is not assignable to type 'boolean'. [+"foo"]: "", diff --git a/tests/baselines/reference/computedPropertyNamesContextualType9_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType9_ES6.errors.txt index eca1360c26fff..b159e46069504 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType9_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType9_ES6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType9_ES6.ts(6,5): error TS2322: Type '{ [x: string]: string | number; [x: number]: string | number; }' is not assignable to type 'I'. - Index signatures are incompatible. + Index signatures '[string]: string | number' and '[string]: boolean' are incompatible. Type 'string | number' is not assignable to type 'boolean'. Type 'string' is not assignable to type 'boolean'. @@ -13,7 +13,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualTy var o: I = { ~ !!! error TS2322: Type '{ [x: string]: string | number; [x: number]: string | number; }' is not assignable to type 'I'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: string | number' and '[string]: boolean' are incompatible. !!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. !!! error TS2322: Type 'string' is not assignable to type 'boolean'. [+"foo"]: "", diff --git a/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt b/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt index 26b06abf78280..58523172cccdb 100644 --- a/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt +++ b/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type '(number | Date)[]' is not assignable to type 'I'. - Index signatures are incompatible. + Index signatures '[number]: number | Date' and '[number]: Date' are incompatible. Type 'number | Date' is not assignable to type 'Date'. Type 'number' is not assignable to type 'Date'. Property 'toDateString' is missing in type 'Number'. @@ -13,7 +13,7 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ var x3: I = [new Date(), 1]; ~~ !!! error TS2322: Type '(number | Date)[]' is not assignable to type 'I'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: number | Date' and '[number]: Date' are incompatible. !!! error TS2322: Type 'number | Date' is not assignable to type 'Date'. !!! error TS2322: Type 'number' is not assignable to type 'Date'. !!! error TS2322: Property 'toDateString' is missing in type 'Number'. diff --git a/tests/baselines/reference/contextualTypingOfObjectLiterals.errors.txt b/tests/baselines/reference/contextualTypingOfObjectLiterals.errors.txt index ac8063a4378fc..ce27330e0be20 100644 --- a/tests/baselines/reference/contextualTypingOfObjectLiterals.errors.txt +++ b/tests/baselines/reference/contextualTypingOfObjectLiterals.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/contextualTypingOfObjectLiterals.ts(4,1): error TS2322: Type '{ x: string; }' is not assignable to type '{ [x: string]: string; }'. - Index signature is missing in type '{ x: string; }'. + Missing [string] index signature in type '{ x: string; }'. tests/cases/compiler/contextualTypingOfObjectLiterals.ts(10,3): error TS2345: Argument of type '{ x: string; }' is not assignable to parameter of type '{ [s: string]: string; }'. - Index signature is missing in type '{ x: string; }'. + Missing [string] index signature in type '{ x: string; }'. ==== tests/cases/compiler/contextualTypingOfObjectLiterals.ts (2 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/contextualTypingOfObjectLiterals.ts(10,3): error TS2345: Ar obj1 = obj2; // Error - indexer doesn't match ~~~~ !!! error TS2322: Type '{ x: string; }' is not assignable to type '{ [x: string]: string; }'. -!!! error TS2322: Index signature is missing in type '{ x: string; }'. +!!! error TS2322: Missing [string] index signature in type '{ x: string; }'. function f(x: { [s: string]: string }) { } @@ -20,4 +20,4 @@ tests/cases/compiler/contextualTypingOfObjectLiterals.ts(10,3): error TS2345: Ar f(obj2); // Error - indexer doesn't match ~~~~ !!! error TS2345: Argument of type '{ x: string; }' is not assignable to parameter of type '{ [s: string]: string; }'. -!!! error TS2345: Index signature is missing in type '{ x: string; }'. \ No newline at end of file +!!! error TS2345: Missing [string] index signature in type '{ x: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/declareClassInterfaceImplementation.errors.txt b/tests/baselines/reference/declareClassInterfaceImplementation.errors.txt index d6944e0e033f6..e338eccec0e68 100644 --- a/tests/baselines/reference/declareClassInterfaceImplementation.errors.txt +++ b/tests/baselines/reference/declareClassInterfaceImplementation.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/declareClassInterfaceImplementation.ts(5,15): error TS2420: Class 'Buffer' incorrectly implements interface 'IBuffer'. - Index signature is missing in type 'Buffer'. + Missing [string] or [number] index signature in type 'Buffer'. ==== tests/cases/compiler/declareClassInterfaceImplementation.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/compiler/declareClassInterfaceImplementation.ts(5,15): error TS2420: declare class Buffer implements IBuffer { ~~~~~~ !!! error TS2420: Class 'Buffer' incorrectly implements interface 'IBuffer'. -!!! error TS2420: Index signature is missing in type 'Buffer'. +!!! error TS2420: Missing [string] or [number] index signature in type 'Buffer'. } \ No newline at end of file diff --git a/tests/baselines/reference/derivedInterfaceIncompatibleWithBaseIndexer.errors.txt b/tests/baselines/reference/derivedInterfaceIncompatibleWithBaseIndexer.errors.txt index 7212121e106e0..2175475e9b3ca 100644 --- a/tests/baselines/reference/derivedInterfaceIncompatibleWithBaseIndexer.errors.txt +++ b/tests/baselines/reference/derivedInterfaceIncompatibleWithBaseIndexer.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(7,5): error TS2411: Property '1' of type '{ y: number; }' is not assignable to string index type '{ x: number; }'. -tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(7,5): error TS2412: Property '1' of type '{ y: number; }' is not assignable to numeric index type '{ x: number; y: number; }'. -tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(11,5): error TS2411: Property ''1'' of type '{ y: number; }' is not assignable to string index type '{ x: number; }'. -tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(11,5): error TS2412: Property ''1'' of type '{ y: number; }' is not assignable to numeric index type '{ x: number; y: number; }'. -tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(15,5): error TS2411: Property 'foo' of type '{ y: number; }' is not assignable to string index type '{ x: number; }'. -tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(19,5): error TS2411: Property 'foo' of type '() => { x: number; }' is not assignable to string index type '{ x: number; }'. +tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(7,5): error TS2411: Property '1' of type '{ y: number; }' is not assignable to string index '[string]: { x: number; }'. +tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(7,5): error TS2412: Property '1' of type '{ y: number; }' is not assignable to numeric index '[number]: { x: number; y: number; }'. +tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(11,5): error TS2411: Property ''1'' of type '{ y: number; }' is not assignable to string index '[string]: { x: number; }'. +tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(11,5): error TS2412: Property ''1'' of type '{ y: number; }' is not assignable to numeric index '[number]: { x: number; y: number; }'. +tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(15,5): error TS2411: Property 'foo' of type '{ y: number; }' is not assignable to string index '[string]: { x: number; }'. +tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(19,5): error TS2411: Property 'foo' of type '() => { x: number; }' is not assignable to string index '[string]: { x: number; }'. tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(24,5): error TS2300: Duplicate identifier '1'. -tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(24,5): error TS2412: Property '1' of type '{ x: number; }' is not assignable to numeric index type '{ x: number; y: number; }'. +tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(24,5): error TS2412: Property '1' of type '{ x: number; }' is not assignable to numeric index '[number]: { x: number; y: number; }'. tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(28,5): error TS2300: Duplicate identifier ''1''. @@ -18,29 +18,29 @@ tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompa interface Derived extends Base { 1: { y: number } // error ~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '1' of type '{ y: number; }' is not assignable to string index type '{ x: number; }'. +!!! error TS2411: Property '1' of type '{ y: number; }' is not assignable to string index '[string]: { x: number; }'. ~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '1' of type '{ y: number; }' is not assignable to numeric index type '{ x: number; y: number; }'. +!!! error TS2412: Property '1' of type '{ y: number; }' is not assignable to numeric index '[number]: { x: number; y: number; }'. } interface Derived2 extends Base { '1': { y: number } // error ~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property ''1'' of type '{ y: number; }' is not assignable to string index type '{ x: number; }'. +!!! error TS2411: Property ''1'' of type '{ y: number; }' is not assignable to string index '[string]: { x: number; }'. ~~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property ''1'' of type '{ y: number; }' is not assignable to numeric index type '{ x: number; y: number; }'. +!!! error TS2412: Property ''1'' of type '{ y: number; }' is not assignable to numeric index '[number]: { x: number; y: number; }'. } interface Derived3 extends Base { foo: { y: number } // error ~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type '{ y: number; }' is not assignable to string index type '{ x: number; }'. +!!! error TS2411: Property 'foo' of type '{ y: number; }' is not assignable to string index '[string]: { x: number; }'. } interface Derived4 extends Base { foo(): { x: number } // error ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type '() => { x: number; }' is not assignable to string index type '{ x: number; }'. +!!! error TS2411: Property 'foo' of type '() => { x: number; }' is not assignable to string index '[string]: { x: number; }'. } // satisifies string indexer but not numeric indexer @@ -49,7 +49,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompa ~ !!! error TS2300: Duplicate identifier '1'. ~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '1' of type '{ x: number; }' is not assignable to numeric index type '{ x: number; y: number; }'. +!!! error TS2412: Property '1' of type '{ x: number; }' is not assignable to numeric index '[number]: { x: number; y: number; }'. } interface Derived5 extends Base { diff --git a/tests/baselines/reference/derivedTypeIncompatibleSignatures.errors.txt b/tests/baselines/reference/derivedTypeIncompatibleSignatures.errors.txt index 71fe36660c496..34b77ac1c37c2 100644 --- a/tests/baselines/reference/derivedTypeIncompatibleSignatures.errors.txt +++ b/tests/baselines/reference/derivedTypeIncompatibleSignatures.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/derivedTypeIncompatibleSignatures.ts(21,11): error TS2430: Interface 'F' incorrectly extends interface 'E'. - Index signatures are incompatible. + Index signatures '[string]: number' and '[string]: string' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/compiler/derivedTypeIncompatibleSignatures.ts(29,11): error TS2430: Interface 'H' incorrectly extends interface 'G'. - Index signatures are incompatible. + Index signatures '[number]: number' and '[number]: string' are incompatible. Type 'number' is not assignable to type 'string'. @@ -30,7 +30,7 @@ tests/cases/compiler/derivedTypeIncompatibleSignatures.ts(29,11): error TS2430: interface F extends E { ~ !!! error TS2430: Interface 'F' incorrectly extends interface 'E'. -!!! error TS2430: Index signatures are incompatible. +!!! error TS2430: Index signatures '[string]: number' and '[string]: string' are incompatible. !!! error TS2430: Type 'number' is not assignable to type 'string'. [a: string]: number; // Number is not a subtype of string. Should error. } @@ -42,7 +42,7 @@ tests/cases/compiler/derivedTypeIncompatibleSignatures.ts(29,11): error TS2430: interface H extends G { ~ !!! error TS2430: Interface 'H' incorrectly extends interface 'G'. -!!! error TS2430: Index signatures are incompatible. +!!! error TS2430: Index signatures '[number]: number' and '[number]: string' are incompatible. !!! error TS2430: Type 'number' is not assignable to type 'string'. [a: number]: number; // Should error for the same reason } \ No newline at end of file diff --git a/tests/baselines/reference/enumAssignmentCompat.errors.txt b/tests/baselines/reference/enumAssignmentCompat.errors.txt index 3cddaf459666c..86308cdd3ea6d 100644 --- a/tests/baselines/reference/enumAssignmentCompat.errors.txt +++ b/tests/baselines/reference/enumAssignmentCompat.errors.txt @@ -2,9 +2,11 @@ tests/cases/compiler/enumAssignmentCompat.ts(26,5): error TS2322: Type 'typeof W tests/cases/compiler/enumAssignmentCompat.ts(28,5): error TS2322: Type 'W' is not assignable to type 'typeof W'. Property 'D' is missing in type 'Number'. tests/cases/compiler/enumAssignmentCompat.ts(30,5): error TS2322: Type 'number' is not assignable to type 'typeof W'. + Property 'D' is missing in type 'Number'. tests/cases/compiler/enumAssignmentCompat.ts(32,5): error TS2322: Type 'W' is not assignable to type 'WStatic'. Property 'a' is missing in type 'Number'. tests/cases/compiler/enumAssignmentCompat.ts(33,5): error TS2322: Type 'number' is not assignable to type 'WStatic'. + Property 'a' is missing in type 'Number'. ==== tests/cases/compiler/enumAssignmentCompat.ts (5 errors) ==== @@ -45,6 +47,7 @@ tests/cases/compiler/enumAssignmentCompat.ts(33,5): error TS2322: Type 'number' var d: typeof W = 3; // error ~ !!! error TS2322: Type 'number' is not assignable to type 'typeof W'. +!!! error TS2322: Property 'D' is missing in type 'Number'. var e: typeof W.a = 4; var f: WStatic = W.a; // error ~ @@ -53,6 +56,7 @@ tests/cases/compiler/enumAssignmentCompat.ts(33,5): error TS2322: Type 'number' var g: WStatic = 5; // error ~ !!! error TS2322: Type 'number' is not assignable to type 'WStatic'. +!!! error TS2322: Property 'a' is missing in type 'Number'. var h: W = 3; var i: W = W.a; i = W.a; diff --git a/tests/baselines/reference/enumAssignmentCompat2.errors.txt b/tests/baselines/reference/enumAssignmentCompat2.errors.txt index d87d6acf6a099..be8ed9806a6db 100644 --- a/tests/baselines/reference/enumAssignmentCompat2.errors.txt +++ b/tests/baselines/reference/enumAssignmentCompat2.errors.txt @@ -2,9 +2,11 @@ tests/cases/compiler/enumAssignmentCompat2.ts(25,5): error TS2322: Type 'typeof tests/cases/compiler/enumAssignmentCompat2.ts(27,5): error TS2322: Type 'W' is not assignable to type 'typeof W'. Property 'a' is missing in type 'Number'. tests/cases/compiler/enumAssignmentCompat2.ts(29,5): error TS2322: Type 'number' is not assignable to type 'typeof W'. + Property 'a' is missing in type 'Number'. tests/cases/compiler/enumAssignmentCompat2.ts(31,5): error TS2322: Type 'W' is not assignable to type 'WStatic'. Property 'a' is missing in type 'Number'. tests/cases/compiler/enumAssignmentCompat2.ts(32,5): error TS2322: Type 'number' is not assignable to type 'WStatic'. + Property 'a' is missing in type 'Number'. ==== tests/cases/compiler/enumAssignmentCompat2.ts (5 errors) ==== @@ -44,6 +46,7 @@ tests/cases/compiler/enumAssignmentCompat2.ts(32,5): error TS2322: Type 'number' var d: typeof W = 3; // error ~ !!! error TS2322: Type 'number' is not assignable to type 'typeof W'. +!!! error TS2322: Property 'a' is missing in type 'Number'. var e: typeof W.a = 4; var f: WStatic = W.a; // error ~ @@ -52,6 +55,7 @@ tests/cases/compiler/enumAssignmentCompat2.ts(32,5): error TS2322: Type 'number' var g: WStatic = 5; // error ~ !!! error TS2322: Type 'number' is not assignable to type 'WStatic'. +!!! error TS2322: Property 'a' is missing in type 'Number'. var h: W = 3; var i: W = W.a; i = W.a; diff --git a/tests/baselines/reference/enumIsNotASubtypeOfAnythingButNumber.errors.txt b/tests/baselines/reference/enumIsNotASubtypeOfAnythingButNumber.errors.txt index e5c341b34df08..6236591030de1 100644 --- a/tests/baselines/reference/enumIsNotASubtypeOfAnythingButNumber.errors.txt +++ b/tests/baselines/reference/enumIsNotASubtypeOfAnythingButNumber.errors.txt @@ -1,20 +1,20 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(18,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'string'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(24,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'boolean'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(30,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'Date'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(36,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'RegExp'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(42,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type '{ bar: number; }'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(48,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'number[]'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(54,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'I8'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(60,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'A'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(66,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'A2'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(72,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type '(x: any) => number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(78,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type '(x: T) => T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(85,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'E2'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(95,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'typeof f'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(105,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'typeof c'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(111,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(18,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(24,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: boolean'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(30,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: Date'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(36,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: RegExp'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(42,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: { bar: number; }'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(48,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: number[]'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(54,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: I8'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(60,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: A'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(66,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: A2'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(72,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: (x: any) => number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(78,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: (x: T) => T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(85,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: E2'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(95,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: typeof f'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(105,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: typeof c'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(111,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(115,18): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(117,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts(117,5): error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: U'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotASubtypeOfAnythingButNumber.ts (17 errors) ==== @@ -37,7 +37,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: string; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'string'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: string'. } @@ -45,7 +45,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: boolean; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'boolean'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: boolean'. } @@ -53,7 +53,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: Date; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'Date'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: Date'. } @@ -61,7 +61,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: RegExp; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'RegExp'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: RegExp'. } @@ -69,7 +69,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: { bar: number }; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type '{ bar: number; }'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: { bar: number; }'. } @@ -77,7 +77,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: number[]; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'number[]'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: number[]'. } @@ -85,7 +85,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: I8; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'I8'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: I8'. } class A { foo: number; } @@ -93,7 +93,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: A; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'A'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: A'. } class A2 { foo: T; } @@ -101,7 +101,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: A2; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'A2'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: A2'. } @@ -109,7 +109,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: (x) => number; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type '(x: any) => number'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: (x: any) => number'. } @@ -117,7 +117,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: (x: T) => T; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type '(x: T) => T'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: (x: T) => T'. } @@ -126,7 +126,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: E2; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'E2'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: E2'. } @@ -138,7 +138,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: typeof f; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'typeof f'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: typeof f'. } @@ -150,7 +150,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: typeof c; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'typeof c'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: typeof c'. } @@ -158,7 +158,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: T; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: T'. } @@ -168,7 +168,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/enumIsNotA [x: string]: U; foo: E; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index type 'U'. +!!! error TS2411: Property 'foo' of type 'E' is not assignable to string index '[string]: U'. } diff --git a/tests/baselines/reference/functionAndInterfaceWithSeparateErrors.errors.txt b/tests/baselines/reference/functionAndInterfaceWithSeparateErrors.errors.txt index 51287c8739314..dd3a0d8f17f7b 100644 --- a/tests/baselines/reference/functionAndInterfaceWithSeparateErrors.errors.txt +++ b/tests/baselines/reference/functionAndInterfaceWithSeparateErrors.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/functionAndInterfaceWithSeparateErrors.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. -tests/cases/compiler/functionAndInterfaceWithSeparateErrors.ts(6,5): error TS2411: Property 'prop' of type 'number' is not assignable to string index type 'string'. +tests/cases/compiler/functionAndInterfaceWithSeparateErrors.ts(6,5): error TS2411: Property 'prop' of type 'number' is not assignable to string index '[string]: string'. ==== tests/cases/compiler/functionAndInterfaceWithSeparateErrors.ts (2 errors) ==== @@ -12,5 +12,5 @@ tests/cases/compiler/functionAndInterfaceWithSeparateErrors.ts(6,5): error TS241 [s: string]: string; prop: number; ~~~~~~~~~~~~~ -!!! error TS2411: Property 'prop' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property 'prop' of type 'number' is not assignable to string index '[string]: string'. } \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexersErrors.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexersErrors.errors.txt index 2a7bfd696cc15..930a297fb7cef 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexersErrors.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexersErrors.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexersErrors.ts(15,17): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexersErrors.ts(18,9): error TS2413: Numeric index type 'T' is not assignable to string index type 'Object'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexersErrors.ts(18,9): error TS2413: Numeric index '[number]: T' is not assignable to string index '[string]: Object'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndIndexersErrors.ts(23,9): error TS2322: Type 'T' is not assignable to type 'U'. @@ -25,7 +25,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj [x: string]: Object; [x: number]: T; ~~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'T' is not assignable to string index type 'Object'. +!!! error TS2413: Numeric index '[number]: T' is not assignable to string index '[string]: Object'. }; var r2 = foo(b); var d = r2[1]; diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt index 5ae71fa2a89ad..67626ba3ef74f 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(10,21): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(11,22): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(11,26): error TS2314: Generic type 'C' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(12,19): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(12,19): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(12,22): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(12,26): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(14,23): error TS2314: Generic type 'C' requires 1 type argument(s). @@ -36,7 +36,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc !!! error TS2314: Generic type 'C' requires 1 type argument(s). declare var d: { [x: C]: C }; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ~ !!! error TS2314: Generic type 'C' requires 1 type argument(s). ~ diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.errors.txt index d57f3c2fc0d03..e1d2ddf86c09e 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(10,13): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(11,14): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(11,18): error TS2314: Generic type 'C' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(12,11): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(12,11): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(12,14): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(12,18): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(14,13): error TS2314: Generic type 'C' requires 1 type argument(s). @@ -46,7 +46,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc !!! error TS2314: Generic type 'C' requires 1 type argument(s). var d: { [x: C]: C }; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ~ !!! error TS2314: Generic type 'C' requires 1 type argument(s). ~ diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt index 2949ce52ce041..1cf09cd679df7 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(10,13): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(11,14): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(11,18): error TS2314: Generic type 'I' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(12,11): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(12,11): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(12,14): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(12,18): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(14,13): error TS2314: Generic type 'I' requires 1 type argument(s). @@ -46,7 +46,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc !!! error TS2314: Generic type 'I' requires 1 type argument(s). var d: { [x: I]: I }; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ~ !!! error TS2314: Generic type 'I' requires 1 type argument(s). ~ diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt index c0e4137452795..e70ce9060de3c 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(10,21): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(11,22): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(11,26): error TS2314: Generic type 'C' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(12,19): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(12,19): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(12,22): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(12,26): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(14,23): error TS2314: Generic type 'C' requires 1 type argument(s). @@ -36,7 +36,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc !!! error TS2314: Generic type 'C' requires 1 type argument(s). declare var d: { [x: C]: C }; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ~ !!! error TS2314: Generic type 'C' requires 1 type argument(s). ~ diff --git a/tests/baselines/reference/indexSignatureTypeCheck.errors.txt b/tests/baselines/reference/indexSignatureTypeCheck.errors.txt index 8a020fde5c64b..95d4beb4442b1 100644 --- a/tests/baselines/reference/indexSignatureTypeCheck.errors.txt +++ b/tests/baselines/reference/indexSignatureTypeCheck.errors.txt @@ -1,21 +1,64 @@ -tests/cases/compiler/indexSignatureTypeCheck.ts(14,8): error TS1019: An index signature parameter cannot have a question mark. -tests/cases/compiler/indexSignatureTypeCheck.ts(15,6): error TS1017: An index signature cannot have a rest parameter. -tests/cases/compiler/indexSignatureTypeCheck.ts(16,6): error TS1096: An index signature must have exactly one parameter. -tests/cases/compiler/indexSignatureTypeCheck.ts(17,6): error TS1096: An index signature must have exactly one parameter. +tests/cases/compiler/indexSignatureTypeCheck.ts(34,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +tests/cases/compiler/indexSignatureTypeCheck.ts(37,8): error TS1019: An index signature parameter cannot have a question mark. +tests/cases/compiler/indexSignatureTypeCheck.ts(38,6): error TS1017: An index signature cannot have a rest parameter. +tests/cases/compiler/indexSignatureTypeCheck.ts(39,6): error TS1096: An index signature must have exactly one parameter. +tests/cases/compiler/indexSignatureTypeCheck.ts(40,6): error TS1096: An index signature must have exactly one parameter. +tests/cases/compiler/indexSignatureTypeCheck.ts(57,5): error TS2375: Duplicate number index signature. +tests/cases/compiler/indexSignatureTypeCheck.ts(62,5): error TS2375: Duplicate number index signature. +tests/cases/compiler/indexSignatureTypeCheck.ts(72,1): error TS2322: Type '{ [x: number]: string; }' is not assignable to type '{ [x: string]: string; }'. + Missing [string] index signature in type '{ [x: number]: string; }'. +tests/cases/compiler/indexSignatureTypeCheck.ts(73,1): error TS2322: Type '{ [x: E < number]: number; }' is not assignable to type '{ [x: string]: string; }'. + Missing [string] index signature in type '{ [x: E < number]: number; }'. +tests/cases/compiler/indexSignatureTypeCheck.ts(77,1): error TS2322: Type '{ [x: E < number]: number; }' is not assignable to type '{ [x: number]: string; }'. + Index signatures '[E]: number' and '[number]: string' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/compiler/indexSignatureTypeCheck.ts(79,1): error TS2322: Type '{ [x: string]: string; }' is not assignable to type '{ [x: E < number]: number; }'. + Index signatures '[string]: string' and '[E]: number' are incompatible. +tests/cases/compiler/indexSignatureTypeCheck.ts(80,1): error TS2322: Type '{ [x: number]: string; }' is not assignable to type '{ [x: E < number]: number; }'. + Index signatures '[number]: string' and '[E]: number' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/compiler/indexSignatureTypeCheck.ts(96,1): error TS2322: Type '{ [x: number]: string; }' is not assignable to type '{ [x: string]: string; }'. + Missing [string] index signature in type '{ [x: number]: string; }'. +tests/cases/compiler/indexSignatureTypeCheck.ts(103,17): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. -==== tests/cases/compiler/indexSignatureTypeCheck.ts (4 errors) ==== +==== tests/cases/compiler/indexSignatureTypeCheck.ts (14 errors) ==== interface IPropertySet { - [index: string]: any; - } - var ps: IPropertySet = null; var index: any = "hello"; ps[index] = 12; + enum Values { + a = 1, + b = 2 + } + + type Values2 = Values; + type Values3 = number; + + interface EnumMap { + [index: Values]: Values; + } + + interface EnumMap2 { + [index: Values2]: Values2; + } + interface NumberMap { + [index: Values3]: Values3; + } + + var pe: Values = null; + + pe[1] = null + pe[3] = null + pe[Values.b] = 5 + + pe[true] = null + ~~~~~~~~ +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. interface indexErrors { [p2?: string]; @@ -30,4 +73,109 @@ tests/cases/compiler/indexSignatureTypeCheck.ts(17,6): error TS1096: An index si [p6: string, ...p7: any[]]; ~~ !!! error TS1096: An index signature must have exactly one parameter. - } \ No newline at end of file + } + + enum E { + A, B, C + } + + enum E2 { + A, B, C + } + + enum F { + H, I, J + } + + interface DuplicateAccess { + [index: Values]: Values; + [index: Values2]: Values2; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2375: Duplicate number index signature. + } + + interface DuplicateAccess2 { + [index: number]: Values; + [index: Values3]: Values3; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2375: Duplicate number index signature. + } + + var x: { [x: string]: string } + var xn: {[x: string]: number } + var y: { [x: number]: string } + var yn: { [x: number]: number } + var z: { [x: E]: number } + + x = x; + x = y; + ~ +!!! error TS2322: Type '{ [x: number]: string; }' is not assignable to type '{ [x: string]: string; }'. +!!! error TS2322: Missing [string] index signature in type '{ [x: number]: string; }'. + x = z; + ~ +!!! error TS2322: Type '{ [x: E < number]: number; }' is not assignable to type '{ [x: string]: string; }'. +!!! error TS2322: Missing [string] index signature in type '{ [x: E < number]: number; }'. + + y = x; + y = y; + y = z; + ~ +!!! error TS2322: Type '{ [x: E < number]: number; }' is not assignable to type '{ [x: number]: string; }'. +!!! error TS2322: Index signatures '[E]: number' and '[number]: string' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + z = x; // error + ~ +!!! error TS2322: Type '{ [x: string]: string; }' is not assignable to type '{ [x: E < number]: number; }'. +!!! error TS2322: Index signatures '[string]: string' and '[E]: number' are incompatible. + z = y; // error + ~ +!!! error TS2322: Type '{ [x: number]: string; }' is not assignable to type '{ [x: E < number]: number; }'. +!!! error TS2322: Index signatures '[number]: string' and '[E]: number' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + z = z; + z = yn; // should error? + // var x: E = 5; // allowed to a assign a wider type (number) to an enum value (number.subset) + z = xn; + yn = z; + + type foo = string + var s: { [x: foo]: string } + var ss: { [x: string]: string } + var sn: { [x: number]: string } + + s = ss; + ss = s; + + sn = s; + s = sn; + ~ +!!! error TS2322: Type '{ [x: number]: string; }' is not assignable to type '{ [x: string]: string; }'. +!!! error TS2322: Missing [string] index signature in type '{ [x: number]: string; }'. + + enum setOf_number1 { a, b, c } + enum setOf_number2 { d, e, f } + + type setOf_numbers = setOf_number1 | setOf_number2; + + var ssubset: { [x: setOf_numbers ]: string } + ~ +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. + + /* + Subset types + type stringSet = "a" | "b" | "c"; + type numberSet = 1 | 2 | 3; + + // Union must flatten subset types into number.subset & string.subset + type mixedSet = stringSubset | numberSet | "d"; + + enum stringSubset { [x: stringSet]: string } + enum numberSubset { [x: numberSet]: string } + + // Special case, mixedSet creates numberIndex = [x: numberSubset] + // stringIndex = [x: stringSubset | "d"] + enum mixedSubset { [x: mixedSet]: string } + + */ \ No newline at end of file diff --git a/tests/baselines/reference/indexSignatureTypeCheck.js b/tests/baselines/reference/indexSignatureTypeCheck.js index 02676348bec74..f349f0889d134 100644 --- a/tests/baselines/reference/indexSignatureTypeCheck.js +++ b/tests/baselines/reference/indexSignatureTypeCheck.js @@ -1,24 +1,208 @@ //// [indexSignatureTypeCheck.ts] interface IPropertySet { - [index: string]: any; - } - var ps: IPropertySet = null; var index: any = "hello"; ps[index] = 12; +enum Values { + a = 1, + b = 2 +} + +type Values2 = Values; +type Values3 = number; + +interface EnumMap { + [index: Values]: Values; +} + +interface EnumMap2 { + [index: Values2]: Values2; +} +interface NumberMap { + [index: Values3]: Values3; +} + +var pe: Values = null; + +pe[1] = null +pe[3] = null +pe[Values.b] = 5 + +pe[true] = null interface indexErrors { [p2?: string]; [...p3: any[]]; [p4: string, p5?: string]; [p6: string, ...p7: any[]]; -} +} + +enum E { + A, B, C +} + +enum E2 { + A, B, C +} + +enum F { + H, I, J +} + +interface DuplicateAccess { + [index: Values]: Values; + [index: Values2]: Values2; +} + +interface DuplicateAccess2 { + [index: number]: Values; + [index: Values3]: Values3; +} + +var x: { [x: string]: string } +var xn: {[x: string]: number } +var y: { [x: number]: string } +var yn: { [x: number]: number } +var z: { [x: E]: number } + +x = x; +x = y; +x = z; + +y = x; +y = y; +y = z; + +z = x; // error +z = y; // error +z = z; +z = yn; // should error? + // var x: E = 5; // allowed to a assign a wider type (number) to an enum value (number.subset) +z = xn; +yn = z; + +type foo = string +var s: { [x: foo]: string } +var ss: { [x: string]: string } +var sn: { [x: number]: string } + +s = ss; +ss = s; + +sn = s; +s = sn; + +enum setOf_number1 { a, b, c } +enum setOf_number2 { d, e, f } + +type setOf_numbers = setOf_number1 | setOf_number2; + +var ssubset: { [x: setOf_numbers ]: string } + +/* + Subset types +type stringSet = "a" | "b" | "c"; +type numberSet = 1 | 2 | 3; + +// Union must flatten subset types into number.subset & string.subset +type mixedSet = stringSubset | numberSet | "d"; + +enum stringSubset { [x: stringSet]: string } +enum numberSubset { [x: numberSet]: string } + +// Special case, mixedSet creates numberIndex = [x: numberSubset] +// stringIndex = [x: stringSubset | "d"] +enum mixedSubset { [x: mixedSet]: string } + +*/ //// [indexSignatureTypeCheck.js] var ps = null; var index = "hello"; ps[index] = 12; +var Values; +(function (Values) { + Values[Values["a"] = 1] = "a"; + Values[Values["b"] = 2] = "b"; +})(Values || (Values = {})); +var pe = null; +pe[1] = null; +pe[3] = null; +pe[Values.b] = 5; +pe[true] = null; +var E; +(function (E) { + E[E["A"] = 0] = "A"; + E[E["B"] = 1] = "B"; + E[E["C"] = 2] = "C"; +})(E || (E = {})); +var E2; +(function (E2) { + E2[E2["A"] = 0] = "A"; + E2[E2["B"] = 1] = "B"; + E2[E2["C"] = 2] = "C"; +})(E2 || (E2 = {})); +var F; +(function (F) { + F[F["H"] = 0] = "H"; + F[F["I"] = 1] = "I"; + F[F["J"] = 2] = "J"; +})(F || (F = {})); +var x; +var xn; +var y; +var yn; +var z; +x = x; +x = y; +x = z; +y = x; +y = y; +y = z; +z = x; // error +z = y; // error +z = z; +z = yn; // should error? +// var x: E = 5; // allowed to a assign a wider type (number) to an enum value (number.subset) +z = xn; +yn = z; +var s; +var ss; +var sn; +s = ss; +ss = s; +sn = s; +s = sn; +var setOf_number1; +(function (setOf_number1) { + setOf_number1[setOf_number1["a"] = 0] = "a"; + setOf_number1[setOf_number1["b"] = 1] = "b"; + setOf_number1[setOf_number1["c"] = 2] = "c"; +})(setOf_number1 || (setOf_number1 = {})); +var setOf_number2; +(function (setOf_number2) { + setOf_number2[setOf_number2["d"] = 0] = "d"; + setOf_number2[setOf_number2["e"] = 1] = "e"; + setOf_number2[setOf_number2["f"] = 2] = "f"; +})(setOf_number2 || (setOf_number2 = {})); +var ssubset; +/* + Subset types +type stringSet = "a" | "b" | "c"; +type numberSet = 1 | 2 | 3; + +// Union must flatten subset types into number.subset & string.subset +type mixedSet = stringSubset | numberSet | "d"; + +enum stringSubset { [x: stringSet]: string } +enum numberSubset { [x: numberSet]: string } + +// Special case, mixedSet creates numberIndex = [x: numberSubset] +// stringIndex = [x: stringSubset | "d"] +enum mixedSubset { [x: mixedSet]: string } + +*/ diff --git a/tests/baselines/reference/indexSignatureTypeInference.errors.txt b/tests/baselines/reference/indexSignatureTypeInference.errors.txt index f93bfc6ce40d2..e2bb4de06827a 100644 --- a/tests/baselines/reference/indexSignatureTypeInference.errors.txt +++ b/tests/baselines/reference/indexSignatureTypeInference.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/types/typeRelationships/typeInference/indexSignatureTypeInference.ts(18,27): error TS2345: Argument of type 'NumberMap' is not assignable to parameter of type 'StringMap<{}>'. - Index signature is missing in type 'NumberMap'. + Missing [string] index signature in type 'NumberMap'. ==== tests/cases/conformance/types/typeRelationships/typeInference/indexSignatureTypeInference.ts (1 errors) ==== @@ -23,6 +23,6 @@ tests/cases/conformance/types/typeRelationships/typeInference/indexSignatureType var v1 = stringMapToArray(numberMap); // Error expected here ~~~~~~~~~ !!! error TS2345: Argument of type 'NumberMap' is not assignable to parameter of type 'StringMap<{}>'. -!!! error TS2345: Index signature is missing in type 'NumberMap'. +!!! error TS2345: Missing [string] index signature in type 'NumberMap'. var v1 = stringMapToArray(stringMap); // Ok \ No newline at end of file diff --git a/tests/baselines/reference/indexTypeCheck.errors.txt b/tests/baselines/reference/indexTypeCheck.errors.txt index 9f4b403ca2ec5..68fdbe09118b1 100644 --- a/tests/baselines/reference/indexTypeCheck.errors.txt +++ b/tests/baselines/reference/indexTypeCheck.errors.txt @@ -1,10 +1,10 @@ tests/cases/compiler/indexTypeCheck.ts(2,2): error TS1021: An index signature must have a type annotation. tests/cases/compiler/indexTypeCheck.ts(3,2): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/indexTypeCheck.ts(17,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'. -tests/cases/compiler/indexTypeCheck.ts(22,2): error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'. -tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'. +tests/cases/compiler/indexTypeCheck.ts(17,2): error TS2413: Numeric index '[number]: number' is not assignable to string index '[string]: string'. +tests/cases/compiler/indexTypeCheck.ts(22,2): error TS2413: Numeric index '[number]: Orange' is not assignable to string index '[string]: Yellow'. +tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index '[number]: number' is not assignable to string index '[string]: string'. tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter. -tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. @@ -31,21 +31,21 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression interface Orange { [n:number]: number; // ok ~~~~~~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'number' is not assignable to string index type 'string'. +!!! error TS2413: Numeric index '[number]: number' is not assignable to string index '[string]: string'. [s:string]: string; // error } interface Green { [n:number]: Orange; // error ~~~~~~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'. +!!! error TS2413: Numeric index '[number]: Orange' is not assignable to string index '[string]: Yellow'. [s:string]: Yellow; // ok } interface Cyan { [n:number]: number; // error ~~~~~~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'number' is not assignable to string index type 'string'. +!!! error TS2413: Numeric index '[number]: number' is not assignable to string index '[string]: string'. [s:string]: string; // ok } @@ -58,7 +58,7 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression interface Magenta { [p:Purple]; // error ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } var yellow: Yellow; diff --git a/tests/baselines/reference/indexerAssignability.errors.txt b/tests/baselines/reference/indexerAssignability.errors.txt index 44c2184517eca..ad9b6b1c243eb 100644 --- a/tests/baselines/reference/indexerAssignability.errors.txt +++ b/tests/baselines/reference/indexerAssignability.errors.txt @@ -1,9 +1,9 @@ tests/cases/compiler/indexerAssignability.ts(5,1): error TS2322: Type '{ [n: number]: string; }' is not assignable to type '{ [s: string]: string; }'. - Index signature is missing in type '{ [n: number]: string; }'. + Missing [string] index signature in type '{ [n: number]: string; }'. tests/cases/compiler/indexerAssignability.ts(6,1): error TS2322: Type '{}' is not assignable to type '{ [s: string]: string; }'. - Index signature is missing in type '{}'. + Missing [string] index signature in type '{}'. tests/cases/compiler/indexerAssignability.ts(8,1): error TS2322: Type '{}' is not assignable to type '{ [n: number]: string; }'. - Index signature is missing in type '{}'. + Missing [string] or [number] index signature in type '{}'. ==== tests/cases/compiler/indexerAssignability.ts (3 errors) ==== @@ -14,15 +14,15 @@ tests/cases/compiler/indexerAssignability.ts(8,1): error TS2322: Type '{}' is no a = b; ~ !!! error TS2322: Type '{ [n: number]: string; }' is not assignable to type '{ [s: string]: string; }'. -!!! error TS2322: Index signature is missing in type '{ [n: number]: string; }'. +!!! error TS2322: Missing [string] index signature in type '{ [n: number]: string; }'. a = c; ~ !!! error TS2322: Type '{}' is not assignable to type '{ [s: string]: string; }'. -!!! error TS2322: Index signature is missing in type '{}'. +!!! error TS2322: Missing [string] index signature in type '{}'. b = a; b = c; ~ !!! error TS2322: Type '{}' is not assignable to type '{ [n: number]: string; }'. -!!! error TS2322: Index signature is missing in type '{}'. +!!! error TS2322: Missing [string] or [number] index signature in type '{}'. c = a; c = b; \ No newline at end of file diff --git a/tests/baselines/reference/indexerConstraints.errors.txt b/tests/baselines/reference/indexerConstraints.errors.txt index cb7785535d18a..e4f3e8164550c 100644 --- a/tests/baselines/reference/indexerConstraints.errors.txt +++ b/tests/baselines/reference/indexerConstraints.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/indexerConstraints.ts(17,5): error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. -tests/cases/compiler/indexerConstraints.ts(25,5): error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. -tests/cases/compiler/indexerConstraints.ts(33,5): error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. -tests/cases/compiler/indexerConstraints.ts(41,5): error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. +tests/cases/compiler/indexerConstraints.ts(17,5): error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. +tests/cases/compiler/indexerConstraints.ts(25,5): error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. +tests/cases/compiler/indexerConstraints.ts(33,5): error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. +tests/cases/compiler/indexerConstraints.ts(41,5): error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. ==== tests/cases/compiler/indexerConstraints.ts (4 errors) ==== @@ -23,7 +23,7 @@ tests/cases/compiler/indexerConstraints.ts(41,5): error TS2413: Numeric index ty interface E { [n: number]: A; ~~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. +!!! error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. } // Inheritance @@ -33,7 +33,7 @@ tests/cases/compiler/indexerConstraints.ts(41,5): error TS2413: Numeric index ty interface G extends F { [n: number]: A; ~~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. +!!! error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. } // Other way @@ -43,7 +43,7 @@ tests/cases/compiler/indexerConstraints.ts(41,5): error TS2413: Numeric index ty interface I extends H { [s: string]: B; ~~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. +!!! error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. } // With hidden indexer @@ -53,6 +53,6 @@ tests/cases/compiler/indexerConstraints.ts(41,5): error TS2413: Numeric index ty interface K extends J { [n: number]: A; ~~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. +!!! error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. [s: string]: B; } \ No newline at end of file diff --git a/tests/baselines/reference/indexerConstraints2.errors.txt b/tests/baselines/reference/indexerConstraints2.errors.txt index 316486e709f96..30531306fcf3a 100644 --- a/tests/baselines/reference/indexerConstraints2.errors.txt +++ b/tests/baselines/reference/indexerConstraints2.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/indexerConstraints2.ts(9,5): error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. -tests/cases/compiler/indexerConstraints2.ts(17,5): error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. -tests/cases/compiler/indexerConstraints2.ts(26,5): error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. +tests/cases/compiler/indexerConstraints2.ts(9,5): error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. +tests/cases/compiler/indexerConstraints2.ts(17,5): error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. +tests/cases/compiler/indexerConstraints2.ts(26,5): error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. ==== tests/cases/compiler/indexerConstraints2.ts (3 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/indexerConstraints2.ts(26,5): error TS2413: Numeric index t class G extends F { [n: number]: A ~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. +!!! error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. } // Other way @@ -24,7 +24,7 @@ tests/cases/compiler/indexerConstraints2.ts(26,5): error TS2413: Numeric index t class I extends H { [s: string]: B ~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. +!!! error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. } // With hidden indexer @@ -35,6 +35,6 @@ tests/cases/compiler/indexerConstraints2.ts(26,5): error TS2413: Numeric index t class K extends J { [n: number]: A; ~~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'A' is not assignable to string index type 'B'. +!!! error TS2413: Numeric index '[number]: A' is not assignable to string index '[string]: B'. [s: string]: B; } \ No newline at end of file diff --git a/tests/baselines/reference/inheritedMembersAndIndexSignaturesFromDifferentBases.errors.txt b/tests/baselines/reference/inheritedMembersAndIndexSignaturesFromDifferentBases.errors.txt index d2ad69730dad7..8413a62fbac9c 100644 --- a/tests/baselines/reference/inheritedMembersAndIndexSignaturesFromDifferentBases.errors.txt +++ b/tests/baselines/reference/inheritedMembersAndIndexSignaturesFromDifferentBases.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(17,11): error TS2411: Property 'm' of type '{}' is not assignable to string index type '{ a: any; }'. -tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(23,11): error TS2411: Property '0' of type '{}' is not assignable to string index type '{ a: any; }'. -tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(23,11): error TS2412: Property '0' of type '{}' is not assignable to numeric index type '{ a: any; b: any; }'. -tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(25,11): error TS2411: Property '0' of type '{}' is not assignable to string index type '{ a: any; }'. -tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(25,11): error TS2411: Property 'm' of type '{}' is not assignable to string index type '{ a: any; }'. -tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(25,11): error TS2412: Property '0' of type '{}' is not assignable to numeric index type '{ a: any; b: any; }'. +tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(17,11): error TS2411: Property 'm' of type '{}' is not assignable to string index '[string]: { a: any; }'. +tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(23,11): error TS2411: Property '0' of type '{}' is not assignable to string index '[string]: { a: any; }'. +tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(23,11): error TS2412: Property '0' of type '{}' is not assignable to numeric index '[number]: { a: any; b: any; }'. +tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(25,11): error TS2411: Property '0' of type '{}' is not assignable to string index '[string]: { a: any; }'. +tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(25,11): error TS2411: Property 'm' of type '{}' is not assignable to string index '[string]: { a: any; }'. +tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(25,11): error TS2412: Property '0' of type '{}' is not assignable to numeric index '[number]: { a: any; b: any; }'. ==== tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts (6 errors) ==== @@ -25,7 +25,7 @@ tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(25, interface D extends A, B, C { } // error because m is not a subtype of {a;} ~ -!!! error TS2411: Property 'm' of type '{}' is not assignable to string index type '{ a: any; }'. +!!! error TS2411: Property 'm' of type '{}' is not assignable to string index '[string]: { a: any; }'. interface E { 0: {}; @@ -33,16 +33,16 @@ tests/cases/compiler/inheritedMembersAndIndexSignaturesFromDifferentBases.ts(25, interface F extends A, B, E { } // error because 0 is not a subtype of {a; b;} ~ -!!! error TS2411: Property '0' of type '{}' is not assignable to string index type '{ a: any; }'. +!!! error TS2411: Property '0' of type '{}' is not assignable to string index '[string]: { a: any; }'. ~ -!!! error TS2412: Property '0' of type '{}' is not assignable to numeric index type '{ a: any; b: any; }'. +!!! error TS2412: Property '0' of type '{}' is not assignable to numeric index '[number]: { a: any; b: any; }'. interface G extends A, B, C, E { } // should only report one error ~ -!!! error TS2411: Property '0' of type '{}' is not assignable to string index type '{ a: any; }'. +!!! error TS2411: Property '0' of type '{}' is not assignable to string index '[string]: { a: any; }'. ~ -!!! error TS2411: Property 'm' of type '{}' is not assignable to string index type '{ a: any; }'. +!!! error TS2411: Property 'm' of type '{}' is not assignable to string index '[string]: { a: any; }'. ~ -!!! error TS2412: Property '0' of type '{}' is not assignable to numeric index type '{ a: any; b: any; }'. +!!! error TS2412: Property '0' of type '{}' is not assignable to numeric index '[number]: { a: any; b: any; }'. interface H extends A, F { } // Should report no error at all because error is internal to F \ No newline at end of file diff --git a/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes.errors.txt b/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes.errors.txt index b99efb5e157ce..c1ab04c5fe74f 100644 --- a/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes.errors.txt +++ b/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/inheritedStringIndexersFromDifferentBaseTypes.ts(13,11): error TS2430: Interface 'E' incorrectly extends interface 'D'. - Index signatures are incompatible. + Index signatures '[string]: number' and '[string]: string' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/compiler/inheritedStringIndexersFromDifferentBaseTypes.ts(28,11): error TS2430: Interface 'E2' incorrectly extends interface 'D2'. - Index signatures are incompatible. + Index signatures '[number]: number' and '[number]: string' are incompatible. Type 'number' is not assignable to type 'string'. @@ -22,7 +22,7 @@ tests/cases/compiler/inheritedStringIndexersFromDifferentBaseTypes.ts(28,11): er interface E extends A, D { } // error ~ !!! error TS2430: Interface 'E' incorrectly extends interface 'D'. -!!! error TS2430: Index signatures are incompatible. +!!! error TS2430: Index signatures '[string]: number' and '[string]: string' are incompatible. !!! error TS2430: Type 'number' is not assignable to type 'string'. @@ -41,5 +41,5 @@ tests/cases/compiler/inheritedStringIndexersFromDifferentBaseTypes.ts(28,11): er interface E2 extends A2, D2 { } // error ~~ !!! error TS2430: Interface 'E2' incorrectly extends interface 'D2'. -!!! error TS2430: Index signatures are incompatible. +!!! error TS2430: Index signatures '[number]: number' and '[number]: string' are incompatible. !!! error TS2430: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes2.errors.txt b/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes2.errors.txt index 8e6fc5b3158e3..17e0e2a467353 100644 --- a/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes2.errors.txt +++ b/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/inheritedStringIndexersFromDifferentBaseTypes2.ts(18,11): error TS2413: Numeric index type '{}' is not assignable to string index type '{ a: any; }'. +tests/cases/compiler/inheritedStringIndexersFromDifferentBaseTypes2.ts(18,11): error TS2413: Numeric index '[number]: {}' is not assignable to string index '[string]: { a: any; }'. ==== tests/cases/compiler/inheritedStringIndexersFromDifferentBaseTypes2.ts (1 errors) ==== @@ -21,7 +21,7 @@ tests/cases/compiler/inheritedStringIndexersFromDifferentBaseTypes2.ts(18,11): e } interface E extends A, D { } // error ~ -!!! error TS2413: Numeric index type '{}' is not assignable to string index type '{ a: any; }'. +!!! error TS2413: Numeric index '[number]: {}' is not assignable to string index '[string]: { a: any; }'. interface F extends A, D { [s: number]: { diff --git a/tests/baselines/reference/intTypeCheck.errors.txt b/tests/baselines/reference/intTypeCheck.errors.txt index bd8b20480452a..d05fd0dbbab21 100644 --- a/tests/baselines/reference/intTypeCheck.errors.txt +++ b/tests/baselines/reference/intTypeCheck.errors.txt @@ -30,14 +30,14 @@ tests/cases/compiler/intTypeCheck.ts(134,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(134,22): error TS2304: Cannot find name 'i3'. tests/cases/compiler/intTypeCheck.ts(135,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(141,5): error TS2322: Type 'Object' is not assignable to type 'i4'. - Index signature is missing in type 'Object'. + Missing [string] index signature in type 'Object'. tests/cases/compiler/intTypeCheck.ts(142,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(143,5): error TS2322: Type 'Base' is not assignable to type 'i4'. - Index signature is missing in type 'Base'. + Missing [string] index signature in type 'Base'. tests/cases/compiler/intTypeCheck.ts(145,5): error TS2322: Type '() => void' is not assignable to type 'i4'. - Index signature is missing in type '() => void'. + Missing [string] index signature in type '() => void'. tests/cases/compiler/intTypeCheck.ts(148,5): error TS2322: Type 'boolean' is not assignable to type 'i4'. - Index signature is missing in type 'Boolean'. + Missing [string] index signature in type 'Boolean'. tests/cases/compiler/intTypeCheck.ts(148,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(148,22): error TS2304: Cannot find name 'i4'. tests/cases/compiler/intTypeCheck.ts(149,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -74,14 +74,14 @@ tests/cases/compiler/intTypeCheck.ts(190,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(190,22): error TS2304: Cannot find name 'i7'. tests/cases/compiler/intTypeCheck.ts(191,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(197,5): error TS2322: Type 'Object' is not assignable to type 'i8'. - Index signature is missing in type 'Object'. + Missing [string] index signature in type 'Object'. tests/cases/compiler/intTypeCheck.ts(198,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(199,5): error TS2322: Type 'Base' is not assignable to type 'i8'. - Index signature is missing in type 'Base'. + Missing [string] index signature in type 'Base'. tests/cases/compiler/intTypeCheck.ts(201,5): error TS2322: Type '() => void' is not assignable to type 'i8'. - Index signature is missing in type '() => void'. + Missing [string] index signature in type '() => void'. tests/cases/compiler/intTypeCheck.ts(204,5): error TS2322: Type 'boolean' is not assignable to type 'i8'. - Index signature is missing in type 'Boolean'. + Missing [string] index signature in type 'Boolean'. tests/cases/compiler/intTypeCheck.ts(204,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(204,22): error TS2304: Cannot find name 'i8'. tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -289,25 +289,25 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit var obj35: i4 = new Object(); ~~~~~ !!! error TS2322: Type 'Object' is not assignable to type 'i4'. -!!! error TS2322: Index signature is missing in type 'Object'. +!!! error TS2322: Missing [string] index signature in type 'Object'. var obj36: i4 = new obj33; ~~~~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. var obj37: i4 = new Base; ~~~~~ !!! error TS2322: Type 'Base' is not assignable to type 'i4'. -!!! error TS2322: Index signature is missing in type 'Base'. +!!! error TS2322: Missing [string] index signature in type 'Base'. var obj38: i4 = null; var obj39: i4 = function () { }; ~~~~~ !!! error TS2322: Type '() => void' is not assignable to type 'i4'. -!!! error TS2322: Index signature is missing in type '() => void'. +!!! error TS2322: Missing [string] index signature in type '() => void'. //var obj40: i4 = function foo() { }; var obj41: i4 = anyVar; var obj42: i4 = new anyVar; ~~~~~ !!! error TS2322: Type 'boolean' is not assignable to type 'i4'. -!!! error TS2322: Index signature is missing in type 'Boolean'. +!!! error TS2322: Missing [string] index signature in type 'Boolean'. ~ !!! error TS1109: Expression expected. ~~ @@ -423,25 +423,25 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit var obj79: i8 = new Object(); ~~~~~ !!! error TS2322: Type 'Object' is not assignable to type 'i8'. -!!! error TS2322: Index signature is missing in type 'Object'. +!!! error TS2322: Missing [string] index signature in type 'Object'. var obj80: i8 = new obj77; ~~~~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. var obj81: i8 = new Base; ~~~~~ !!! error TS2322: Type 'Base' is not assignable to type 'i8'. -!!! error TS2322: Index signature is missing in type 'Base'. +!!! error TS2322: Missing [string] index signature in type 'Base'. var obj82: i8 = null; var obj83: i8 = function () { }; ~~~~~ !!! error TS2322: Type '() => void' is not assignable to type 'i8'. -!!! error TS2322: Index signature is missing in type '() => void'. +!!! error TS2322: Missing [string] index signature in type '() => void'. //var obj84: i8 = function foo() { }; var obj85: i8 = anyVar; var obj86: i8 = new anyVar; ~~~~~ !!! error TS2322: Type 'boolean' is not assignable to type 'i8'. -!!! error TS2322: Index signature is missing in type 'Boolean'. +!!! error TS2322: Missing [string] index signature in type 'Boolean'. ~ !!! error TS1109: Expression expected. ~~ diff --git a/tests/baselines/reference/interfaceExtendingClass2.errors.txt b/tests/baselines/reference/interfaceExtendingClass2.errors.txt index 3b394d4922ab7..e96a471437a5a 100644 --- a/tests/baselines/reference/interfaceExtendingClass2.errors.txt +++ b/tests/baselines/reference/interfaceExtendingClass2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(11,5): error TS2411: Property 'a' of type '{ toString: () => {}; }' is not assignable to string index type 'Object'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(11,5): error TS2411: Property 'a' of type '{ toString: () => {}; }' is not assignable to string index '[string]: Object'. tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(13,13): error TS1131: Property or signature expected. tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(14,9): error TS1128: Declaration or statement expected. tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(15,5): error TS1128: Declaration or statement expected. @@ -19,7 +19,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtending ~~~~ toString: () => { ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'a' of type '{ toString: () => {}; }' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'a' of type '{ toString: () => {}; }' is not assignable to string index '[string]: Object'. return 1; ~~~~~~ !!! error TS1131: Property or signature expected. diff --git a/tests/baselines/reference/interfaceMemberValidation.errors.txt b/tests/baselines/reference/interfaceMemberValidation.errors.txt index 3b2b1d1874c21..d07ddbaae8aae 100644 --- a/tests/baselines/reference/interfaceMemberValidation.errors.txt +++ b/tests/baselines/reference/interfaceMemberValidation.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/interfaceMemberValidation.ts(2,11): error TS2430: Interface 'i2' incorrectly extends interface 'i1'. Types of property 'name' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/compiler/interfaceMemberValidation.ts(5,2): error TS2411: Property 'bar' of type '{ (): any; (): any; }' is not assignable to string index type 'number'. +tests/cases/compiler/interfaceMemberValidation.ts(5,2): error TS2411: Property 'bar' of type '{ (): any; (): any; }' is not assignable to string index '[string]: number'. tests/cases/compiler/interfaceMemberValidation.ts(10,2): error TS2374: Duplicate string index signature. @@ -16,7 +16,7 @@ tests/cases/compiler/interfaceMemberValidation.ts(10,2): error TS2374: Duplicate interface foo { bar():any; ~~~~~~~~~~ -!!! error TS2411: Property 'bar' of type '{ (): any; (): any; }' is not assignable to string index type 'number'. +!!! error TS2411: Property 'bar' of type '{ (): any; (): any; }' is not assignable to string index '[string]: number'. bar():any; new():void; new():void; diff --git a/tests/baselines/reference/interfaceWithStringIndexerHidingBaseTypeIndexer.errors.txt b/tests/baselines/reference/interfaceWithStringIndexerHidingBaseTypeIndexer.errors.txt index 40dc5668eb20f..7d4a3521b41ff 100644 --- a/tests/baselines/reference/interfaceWithStringIndexerHidingBaseTypeIndexer.errors.txt +++ b/tests/baselines/reference/interfaceWithStringIndexerHidingBaseTypeIndexer.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithStringIndexerHidingBaseTypeIndexer.ts(13,5): error TS2411: Property 'y' of type '{ a: number; }' is not assignable to string index type '{ a: number; b: number; }'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithStringIndexerHidingBaseTypeIndexer.ts(13,5): error TS2411: Property 'y' of type '{ a: number; }' is not assignable to string index '[string]: { a: number; b: number; }'. ==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithStringIndexerHidingBaseTypeIndexer.ts (1 errors) ==== @@ -20,5 +20,5 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithStringInde ~~~~~~~~~~~~~~~~~~ } ~~~~~ -!!! error TS2411: Property 'y' of type '{ a: number; }' is not assignable to string index type '{ a: number; b: number; }'. +!!! error TS2411: Property 'y' of type '{ a: number; }' is not assignable to string index '[string]: { a: number; b: number; }'. } \ No newline at end of file diff --git a/tests/baselines/reference/interfaceWithStringIndexerHidingBaseTypeIndexer2.errors.txt b/tests/baselines/reference/interfaceWithStringIndexerHidingBaseTypeIndexer2.errors.txt index ac66d08a83ada..b2665d295bdaa 100644 --- a/tests/baselines/reference/interfaceWithStringIndexerHidingBaseTypeIndexer2.errors.txt +++ b/tests/baselines/reference/interfaceWithStringIndexerHidingBaseTypeIndexer2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithStringIndexerHidingBaseTypeIndexer2.ts(17,5): error TS2412: Property '1' of type '{ a: number; }' is not assignable to numeric index type '{ a: number; b: number; }'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithStringIndexerHidingBaseTypeIndexer2.ts(17,5): error TS2412: Property '1' of type '{ a: number; }' is not assignable to numeric index '[number]: { a: number; b: number; }'. ==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithStringIndexerHidingBaseTypeIndexer2.ts (1 errors) ==== @@ -24,5 +24,5 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithStringInde ~~~~~~~~~~~~~~~~~~ } ~~~~~ -!!! error TS2412: Property '1' of type '{ a: number; }' is not assignable to numeric index type '{ a: number; b: number; }'. +!!! error TS2412: Property '1' of type '{ a: number; }' is not assignable to numeric index '[number]: { a: number; b: number; }'. } \ No newline at end of file diff --git a/tests/baselines/reference/interfaceWithStringIndexerHidingBaseTypeIndexer3.errors.txt b/tests/baselines/reference/interfaceWithStringIndexerHidingBaseTypeIndexer3.errors.txt index 932780aaa1a9d..981fe63b02882 100644 --- a/tests/baselines/reference/interfaceWithStringIndexerHidingBaseTypeIndexer3.errors.txt +++ b/tests/baselines/reference/interfaceWithStringIndexerHidingBaseTypeIndexer3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithStringIndexerHidingBaseTypeIndexer3.ts(13,5): error TS2412: Property '2' of type '{ a: number; }' is not assignable to numeric index type '{ a: number; b: number; }'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithStringIndexerHidingBaseTypeIndexer3.ts(13,5): error TS2412: Property '2' of type '{ a: number; }' is not assignable to numeric index '[number]: { a: number; b: number; }'. ==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithStringIndexerHidingBaseTypeIndexer3.ts (1 errors) ==== @@ -20,5 +20,5 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithStringInde ~~~~~~~~~~~~~~~~~~ } ~~~~~ -!!! error TS2412: Property '2' of type '{ a: number; }' is not assignable to numeric index type '{ a: number; b: number; }'. +!!! error TS2412: Property '2' of type '{ a: number; }' is not assignable to numeric index '[number]: { a: number; b: number; }'. } \ No newline at end of file diff --git a/tests/baselines/reference/interfacedeclWithIndexerErrors.errors.txt b/tests/baselines/reference/interfacedeclWithIndexerErrors.errors.txt index 3eff7ad420c36..c8b65ad1660cc 100644 --- a/tests/baselines/reference/interfacedeclWithIndexerErrors.errors.txt +++ b/tests/baselines/reference/interfacedeclWithIndexerErrors.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/interfacedeclWithIndexerErrors.ts(12,5): error TS2411: Property 'p2' of type 'string' is not assignable to string index type '() => string'. -tests/cases/compiler/interfacedeclWithIndexerErrors.ts(14,5): error TS2411: Property 'p4' of type 'number' is not assignable to string index type '() => string'. -tests/cases/compiler/interfacedeclWithIndexerErrors.ts(15,5): error TS2411: Property 'p5' of type '(s: number) => string' is not assignable to string index type '() => string'. -tests/cases/compiler/interfacedeclWithIndexerErrors.ts(19,5): error TS2411: Property 'f3' of type '(a: string) => number' is not assignable to string index type '() => string'. -tests/cases/compiler/interfacedeclWithIndexerErrors.ts(20,5): error TS2411: Property 'f4' of type '(s: number) => string' is not assignable to string index type '() => string'. +tests/cases/compiler/interfacedeclWithIndexerErrors.ts(12,5): error TS2411: Property 'p2' of type 'string' is not assignable to string index '[string]: () => string'. +tests/cases/compiler/interfacedeclWithIndexerErrors.ts(14,5): error TS2411: Property 'p4' of type 'number' is not assignable to string index '[string]: () => string'. +tests/cases/compiler/interfacedeclWithIndexerErrors.ts(15,5): error TS2411: Property 'p5' of type '(s: number) => string' is not assignable to string index '[string]: () => string'. +tests/cases/compiler/interfacedeclWithIndexerErrors.ts(19,5): error TS2411: Property 'f3' of type '(a: string) => number' is not assignable to string index '[string]: () => string'. +tests/cases/compiler/interfacedeclWithIndexerErrors.ts(20,5): error TS2411: Property 'f4' of type '(s: number) => string' is not assignable to string index '[string]: () => string'. ==== tests/cases/compiler/interfacedeclWithIndexerErrors.ts (5 errors) ==== @@ -19,23 +19,23 @@ tests/cases/compiler/interfacedeclWithIndexerErrors.ts(20,5): error TS2411: Prop p1; p2: string; ~~~~~~~~~~~ -!!! error TS2411: Property 'p2' of type 'string' is not assignable to string index type '() => string'. +!!! error TS2411: Property 'p2' of type 'string' is not assignable to string index '[string]: () => string'. p3?; p4?: number; ~~~~~~~~~~~~ -!!! error TS2411: Property 'p4' of type 'number' is not assignable to string index type '() => string'. +!!! error TS2411: Property 'p4' of type 'number' is not assignable to string index '[string]: () => string'. p5: (s: number) =>string; ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'p5' of type '(s: number) => string' is not assignable to string index type '() => string'. +!!! error TS2411: Property 'p5' of type '(s: number) => string' is not assignable to string index '[string]: () => string'. f1(); f2? (); f3(a: string): number; ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'f3' of type '(a: string) => number' is not assignable to string index type '() => string'. +!!! error TS2411: Property 'f3' of type '(a: string) => number' is not assignable to string index '[string]: () => string'. f4? (s: number): string; ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'f4' of type '(s: number) => string' is not assignable to string index type '() => string'. +!!! error TS2411: Property 'f4' of type '(s: number) => string' is not assignable to string index '[string]: () => string'. } diff --git a/tests/baselines/reference/mergedInterfacesWithIndexers2.errors.txt b/tests/baselines/reference/mergedInterfacesWithIndexers2.errors.txt index 768abc0f9c05e..f063760a02baf 100644 --- a/tests/baselines/reference/mergedInterfacesWithIndexers2.errors.txt +++ b/tests/baselines/reference/mergedInterfacesWithIndexers2.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithIndexers2.ts(4,5): error TS2413: Numeric index type 'string' is not assignable to string index type '{ length: string; }'. -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithIndexers2.ts(14,5): error TS2411: Property ''a'' of type 'number' is not assignable to string index type '{ length: number; }'. -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithIndexers2.ts(20,5): error TS2412: Property '1' of type '{ length: number; }' is not assignable to numeric index type 'string'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithIndexers2.ts(9,5): error TS2413: Numeric index '[number]: string' is not assignable to string index '[string]: { length: string; }'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithIndexers2.ts(14,5): error TS2411: Property ''a'' of type 'number' is not assignable to string index '[string]: { length: number; }'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithIndexers2.ts(20,5): error TS2412: Property '1' of type '{ length: number; }' is not assignable to numeric index '[number]: string'. ==== tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithIndexers2.ts (3 errors) ==== @@ -8,20 +8,20 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithIndexe interface A { [x: number]: string; // error - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'string' is not assignable to string index type '{ length: string; }'. } interface A { [x: string]: { length: string }; // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2413: Numeric index '[number]: string' is not assignable to string index '[string]: { length: string; }'. } interface A2 { [x: number]: string; 'a': number; //error ~~~~~~~~~~~~ -!!! error TS2411: Property ''a'' of type 'number' is not assignable to string index type '{ length: number; }'. +!!! error TS2411: Property ''a'' of type 'number' is not assignable to string index '[string]: { length: number; }'. } @@ -29,6 +29,6 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithIndexe [x: string]: { length: number }; 1: { length: number }; // error ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '1' of type '{ length: number; }' is not assignable to numeric index type 'string'. +!!! error TS2412: Property '1' of type '{ length: number; }' is not assignable to numeric index '[number]: string'. } \ No newline at end of file diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt index 35673eb3072a1..4894799d09e7a 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(18,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(21,5): error TS2412: Property '3.0' of type 'MyNumber' is not assignable to numeric index type 'string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(18,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index '[number]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(21,5): error TS2412: Property '3.0' of type 'MyNumber' is not assignable to numeric index '[number]: string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(26,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(50,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(68,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(50,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index '[number]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(68,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index '[number]: string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: number]: string | number; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. - Index signatures are incompatible. + Index signatures '[number]: string | number' and '[number]: string' are incompatible. Type 'string | number' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(88,9): error TS2304: Cannot find name 'Myn'. @@ -34,12 +34,12 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo 1.0: string; // ok 2.0: number; // error ~~~~~~~~~~~~ -!!! error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. +!!! error TS2412: Property '2.0' of type 'number' is not assignable to numeric index '[number]: string'. "3.0": string; // ok "4.0": number; // error 3.0: MyNumber // error ~~~~~~~~~~~~~ -!!! error TS2412: Property '3.0' of type 'MyNumber' is not assignable to numeric index type 'string'. +!!! error TS2412: Property '3.0' of type 'MyNumber' is not assignable to numeric index '[number]: string'. get X() { // ok ~ @@ -76,7 +76,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo 1.0: string; // ok 2.0: number; // error ~~~~~~~~~~~~ -!!! error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. +!!! error TS2412: Property '2.0' of type 'number' is not assignable to numeric index '[number]: string'. (): string; // ok (x): number // ok foo(): string; // ok @@ -96,7 +96,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo 1.0: string; // ok 2.0: number; // error ~~~~~~~~~~~~ -!!! error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. +!!! error TS2412: Property '2.0' of type 'number' is not assignable to numeric index '[number]: string'. (): string; // ok (x): number // ok foo(): string; // ok @@ -109,7 +109,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo var b: { [x: number]: string; } = { ~ !!! error TS2322: Type '{ [x: number]: string | number; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: string | number' and '[number]: string' are incompatible. !!! error TS2322: Type 'string | number' is not assignable to type 'string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. a: '', diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt index 7f73ac6da0a53..a23b3214ca828 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(25,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index '[number]: A'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(25,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index '[number]: A'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index '[number]: A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: number | A; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. - Index signatures are incompatible. + Index signatures '[number]: number | A' and '[number]: A' are incompatible. Type 'number | A' is not assignable to type 'A'. Type 'number' is not assignable to type 'A'. @@ -25,7 +25,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo "2.5": B // ok 3.0: number; // error ~~~~~~~~~~~~ -!!! error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. +!!! error TS2412: Property '3.0' of type 'number' is not assignable to numeric index '[number]: A'. "4.0": string; // error } @@ -36,7 +36,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo "2.5": B // ok 3.0: number; // error ~~~~~~~~~~~~ -!!! error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. +!!! error TS2412: Property '3.0' of type 'number' is not assignable to numeric index '[number]: A'. "4.0": string; // error } @@ -47,7 +47,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo "2.5": B // ok 3.0: number; // error ~~~~~~~~~~~~ -!!! error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. +!!! error TS2412: Property '3.0' of type 'number' is not assignable to numeric index '[number]: A'. "4.0": string; // error }; @@ -55,7 +55,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo var b: { [x: number]: A } = { ~ !!! error TS2322: Type '{ [x: number]: number | A; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: number | A' and '[number]: A' are incompatible. !!! error TS2322: Type 'number | A' is not assignable to type 'A'. !!! error TS2322: Type 'number' is not assignable to type 'A'. 1.0: new A(), diff --git a/tests/baselines/reference/numericIndexerConstraint.errors.txt b/tests/baselines/reference/numericIndexerConstraint.errors.txt index af24643310a07..e72671ed55c47 100644 --- a/tests/baselines/reference/numericIndexerConstraint.errors.txt +++ b/tests/baselines/reference/numericIndexerConstraint.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/numericIndexerConstraint.ts(2,5): error TS2412: Property '0' of type 'number' is not assignable to numeric index type 'RegExp'. +tests/cases/compiler/numericIndexerConstraint.ts(2,5): error TS2412: Property '0' of type 'number' is not assignable to numeric index '[number]: RegExp'. ==== tests/cases/compiler/numericIndexerConstraint.ts (1 errors) ==== class C { 0: number; ~~~~~~~~~~ -!!! error TS2412: Property '0' of type 'number' is not assignable to numeric index type 'RegExp'. +!!! error TS2412: Property '0' of type 'number' is not assignable to numeric index '[number]: RegExp'. [x: number]: RegExp; } \ No newline at end of file diff --git a/tests/baselines/reference/numericIndexerConstraint2.errors.txt b/tests/baselines/reference/numericIndexerConstraint2.errors.txt index 385efbcead2ab..efc19a995aeab 100644 --- a/tests/baselines/reference/numericIndexerConstraint2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstraint2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/numericIndexerConstraint2.ts(4,1): error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: Foo; }'. - Index signature is missing in type '{ one: number; }'. + Missing [string] index signature in type '{ one: number; }'. ==== tests/cases/compiler/numericIndexerConstraint2.ts (1 errors) ==== @@ -9,4 +9,4 @@ tests/cases/compiler/numericIndexerConstraint2.ts(4,1): error TS2322: Type '{ on x = a; ~ !!! error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: Foo; }'. -!!! error TS2322: Index signature is missing in type '{ one: number; }'. \ No newline at end of file +!!! error TS2322: Missing [string] index signature in type '{ one: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/numericIndexerConstraint5.errors.txt b/tests/baselines/reference/numericIndexerConstraint5.errors.txt index 98acc65eeb73c..815dd5a0cd78d 100644 --- a/tests/baselines/reference/numericIndexerConstraint5.errors.txt +++ b/tests/baselines/reference/numericIndexerConstraint5.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ 0: Date; name: string; }' is not assignable to type '{ [name: number]: string; }'. - Index signature is missing in type '{ 0: Date; name: string; }'. + Missing [string] or [number] index signature in type '{ 0: Date; name: string; }'. ==== tests/cases/compiler/numericIndexerConstraint5.ts (1 errors) ==== @@ -7,4 +7,4 @@ tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ 0: var z: { [name: number]: string } = x; ~ !!! error TS2322: Type '{ 0: Date; name: string; }' is not assignable to type '{ [name: number]: string; }'. -!!! error TS2322: Index signature is missing in type '{ 0: Date; name: string; }'. \ No newline at end of file +!!! error TS2322: Missing [string] or [number] index signature in type '{ 0: Date; name: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt index c35e49f02a31f..383bfccc353ff 100644 --- a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. - Index signatures are incompatible. + Index signatures '[number]: A' and '[number]: B' are incompatible. Type 'A' is not assignable to type 'B'. @@ -19,6 +19,6 @@ tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ var o1: { [s: string]: A;[n: number]: B; } = { x: b, 0: a }; // both indexers are A ~~ !!! error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[number]: A' and '[number]: B' are incompatible. !!! error TS2322: Type 'A' is not assignable to type 'B'. o1 = { x: c, 0: a }; // string indexer is any, number indexer is A \ No newline at end of file diff --git a/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.errors.txt b/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.errors.txt index 19c12ebf62fac..4ed95d6204a2d 100644 --- a/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.errors.txt +++ b/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'constructor' of type 'Function' is not assignable to string index type 'Object'. -tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'data' of type 'A' is not assignable to string index type 'Object'. -tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'hasOwnProperty' of type '(v: string) => boolean' is not assignable to string index type 'Object'. -tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'isPrototypeOf' of type '(v: Object) => boolean' is not assignable to string index type 'Object'. -tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'propertyIsEnumerable' of type '(v: string) => boolean' is not assignable to string index type 'Object'. -tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'toLocaleString' of type '() => string' is not assignable to string index type 'Object'. -tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'toString' of type '() => string' is not assignable to string index type 'Object'. -tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'valueOf' of type '() => Object' is not assignable to string index type 'Object'. +tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'constructor' of type 'Function' is not assignable to string index '[string]: Object'. +tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'data' of type 'A' is not assignable to string index '[string]: Object'. +tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'hasOwnProperty' of type '(v: string) => boolean' is not assignable to string index '[string]: Object'. +tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'isPrototypeOf' of type '(v: Object) => boolean' is not assignable to string index '[string]: Object'. +tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'propertyIsEnumerable' of type '(v: string) => boolean' is not assignable to string index '[string]: Object'. +tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'toLocaleString' of type '() => string' is not assignable to string index '[string]: Object'. +tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'toString' of type '() => string' is not assignable to string index '[string]: Object'. +tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts(11,5): error TS2411: Property 'valueOf' of type '() => Object' is not assignable to string index '[string]: Object'. ==== tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts (8 errors) ==== @@ -21,21 +21,21 @@ tests/cases/conformance/types/members/objectTypeHidingMembersOfExtendedObject.ts data: A; [x: string]: Object; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'constructor' of type 'Function' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'constructor' of type 'Function' is not assignable to string index '[string]: Object'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'data' of type 'A' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'data' of type 'A' is not assignable to string index '[string]: Object'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'hasOwnProperty' of type '(v: string) => boolean' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'hasOwnProperty' of type '(v: string) => boolean' is not assignable to string index '[string]: Object'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'isPrototypeOf' of type '(v: Object) => boolean' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'isPrototypeOf' of type '(v: Object) => boolean' is not assignable to string index '[string]: Object'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'propertyIsEnumerable' of type '(v: string) => boolean' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'propertyIsEnumerable' of type '(v: string) => boolean' is not assignable to string index '[string]: Object'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'toLocaleString' of type '() => string' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'toLocaleString' of type '() => string' is not assignable to string index '[string]: Object'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'toString' of type '() => string' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'toString' of type '() => string' is not assignable to string index '[string]: Object'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'valueOf' of type '() => Object' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'valueOf' of type '() => Object' is not assignable to string index '[string]: Object'. } class C { diff --git a/tests/baselines/reference/objectTypeWithStringIndexerHidingObjectIndexer.errors.txt b/tests/baselines/reference/objectTypeWithStringIndexerHidingObjectIndexer.errors.txt index d09701c3b0698..a5ad7307aa980 100644 --- a/tests/baselines/reference/objectTypeWithStringIndexerHidingObjectIndexer.errors.txt +++ b/tests/baselines/reference/objectTypeWithStringIndexerHidingObjectIndexer.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'constructor' of type 'Function' is not assignable to string index type 'Object'. -tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'hasOwnProperty' of type '(v: string) => boolean' is not assignable to string index type 'Object'. -tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'isPrototypeOf' of type '(v: Object) => boolean' is not assignable to string index type 'Object'. -tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'propertyIsEnumerable' of type '(v: string) => boolean' is not assignable to string index type 'Object'. -tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'toLocaleString' of type '() => string' is not assignable to string index type 'Object'. -tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'toString' of type '() => string' is not assignable to string index type 'Object'. -tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'valueOf' of type '() => Object' is not assignable to string index type 'Object'. +tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'constructor' of type 'Function' is not assignable to string index '[string]: Object'. +tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'hasOwnProperty' of type '(v: string) => boolean' is not assignable to string index '[string]: Object'. +tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'isPrototypeOf' of type '(v: Object) => boolean' is not assignable to string index '[string]: Object'. +tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'propertyIsEnumerable' of type '(v: string) => boolean' is not assignable to string index '[string]: Object'. +tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'toLocaleString' of type '() => string' is not assignable to string index '[string]: Object'. +tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'toString' of type '() => string' is not assignable to string index '[string]: Object'. +tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'valueOf' of type '() => Object' is not assignable to string index '[string]: Object'. ==== tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts (7 errors) ==== @@ -14,19 +14,19 @@ tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectInd interface Object { [x: string]: Object; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'constructor' of type 'Function' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'constructor' of type 'Function' is not assignable to string index '[string]: Object'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'hasOwnProperty' of type '(v: string) => boolean' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'hasOwnProperty' of type '(v: string) => boolean' is not assignable to string index '[string]: Object'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'isPrototypeOf' of type '(v: Object) => boolean' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'isPrototypeOf' of type '(v: Object) => boolean' is not assignable to string index '[string]: Object'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'propertyIsEnumerable' of type '(v: string) => boolean' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'propertyIsEnumerable' of type '(v: string) => boolean' is not assignable to string index '[string]: Object'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'toLocaleString' of type '() => string' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'toLocaleString' of type '() => string' is not assignable to string index '[string]: Object'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'toString' of type '() => string' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'toString' of type '() => string' is not assignable to string index '[string]: Object'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'valueOf' of type '() => Object' is not assignable to string index type 'Object'. +!!! error TS2411: Property 'valueOf' of type '() => Object' is not assignable to string index '[string]: Object'. } var o = {}; var r = o['']; // should be Object diff --git a/tests/baselines/reference/parseTypes.errors.txt b/tests/baselines/reference/parseTypes.errors.txt index baa5aaff7387f..3da7f901916cd 100644 --- a/tests/baselines/reference/parseTypes.errors.txt +++ b/tests/baselines/reference/parseTypes.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/parseTypes.ts(9,1): error TS2322: Type '(s: string) => void' is not assignable to type '() => number'. tests/cases/compiler/parseTypes.ts(10,1): error TS2322: Type '(s: string) => void' is not assignable to type '() => number'. tests/cases/compiler/parseTypes.ts(11,1): error TS2322: Type '(s: string) => void' is not assignable to type '{ [x: number]: number; }'. - Index signature is missing in type '(s: string) => void'. + Missing [string] or [number] index signature in type '(s: string) => void'. tests/cases/compiler/parseTypes.ts(12,1): error TS2322: Type '(s: string) => void' is not assignable to type 'new () => number'. @@ -23,7 +23,7 @@ tests/cases/compiler/parseTypes.ts(12,1): error TS2322: Type '(s: string) => voi w=g; ~ !!! error TS2322: Type '(s: string) => void' is not assignable to type '{ [x: number]: number; }'. -!!! error TS2322: Index signature is missing in type '(s: string) => void'. +!!! error TS2322: Missing [string] or [number] index signature in type '(s: string) => void'. z=g; ~ !!! error TS2322: Type '(s: string) => void' is not assignable to type 'new () => number'. diff --git a/tests/baselines/reference/parserES5SymbolIndexer1.errors.txt b/tests/baselines/reference/parserES5SymbolIndexer1.errors.txt index adfac8f700f2f..01bfd9009df58 100644 --- a/tests/baselines/reference/parserES5SymbolIndexer1.errors.txt +++ b/tests/baselines/reference/parserES5SymbolIndexer1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/Symbols/parserES5SymbolIndexer1.ts(2,6): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/parser/ecmascript5/Symbols/parserES5SymbolIndexer1.ts(2,6): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/parser/ecmascript5/Symbols/parserES5SymbolIndexer1.ts (1 errors) ==== interface I { [s: symbol]: string; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5SymbolIndexer2.errors.txt b/tests/baselines/reference/parserES5SymbolIndexer2.errors.txt index 12eef8ec04967..5180cbf2b7c35 100644 --- a/tests/baselines/reference/parserES5SymbolIndexer2.errors.txt +++ b/tests/baselines/reference/parserES5SymbolIndexer2.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/Symbols/parserES5SymbolIndexer2.ts(2,6): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/parser/ecmascript5/Symbols/parserES5SymbolIndexer2.ts(2,6): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/parser/ecmascript5/Symbols/parserES5SymbolIndexer2.ts (1 errors) ==== class C { [s: symbol]: string; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5SymbolIndexer3.errors.txt b/tests/baselines/reference/parserES5SymbolIndexer3.errors.txt index c9cd9db4fab8b..3237b91aaddc3 100644 --- a/tests/baselines/reference/parserES5SymbolIndexer3.errors.txt +++ b/tests/baselines/reference/parserES5SymbolIndexer3.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/Symbols/parserES5SymbolIndexer3.ts(2,6): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/parser/ecmascript5/Symbols/parserES5SymbolIndexer3.ts(2,6): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/parser/ecmascript5/Symbols/parserES5SymbolIndexer3.ts (1 errors) ==== var x: { [s: symbol]: string; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/parserIndexSignature6.errors.txt b/tests/baselines/reference/parserIndexSignature6.errors.txt index db53f219832ed..dd63980c3bf50 100644 --- a/tests/baselines/reference/parserIndexSignature6.errors.txt +++ b/tests/baselines/reference/parserIndexSignature6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature6.ts(2,4): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature6.ts(2,4): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature6.ts (1 errors) ==== interface I { [a:boolean] ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/parserIndexSignature8.errors.txt b/tests/baselines/reference/parserIndexSignature8.errors.txt index 87369df1b76c7..e38c5cd6b990f 100644 --- a/tests/baselines/reference/parserIndexSignature8.errors.txt +++ b/tests/baselines/reference/parserIndexSignature8.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature8.ts(1,13): error TS1023: An index signature parameter type must be 'string' or 'number'. -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature8.ts(2,14): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature8.ts(1,13): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature8.ts(2,14): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature8.ts (2 errors) ==== var foo: { [index: any]; }; // expect an error here ~~~~~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. var foo2: { [index: RegExp]; }; // expect an error here ~~~~~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolIndexer1.errors.txt b/tests/baselines/reference/parserSymbolIndexer1.errors.txt index 5c6c38d52b122..43aa207495f6e 100644 --- a/tests/baselines/reference/parserSymbolIndexer1.errors.txt +++ b/tests/baselines/reference/parserSymbolIndexer1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer1.ts(2,6): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer1.ts(2,6): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer1.ts (1 errors) ==== interface I { [s: symbol]: string; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolIndexer2.errors.txt b/tests/baselines/reference/parserSymbolIndexer2.errors.txt index 3961f4942de4b..55d1198f4c2b8 100644 --- a/tests/baselines/reference/parserSymbolIndexer2.errors.txt +++ b/tests/baselines/reference/parserSymbolIndexer2.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer2.ts(2,6): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer2.ts(2,6): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer2.ts (1 errors) ==== class C { [s: symbol]: string; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolIndexer3.errors.txt b/tests/baselines/reference/parserSymbolIndexer3.errors.txt index 5484a096d4ce0..22b98c3a9018c 100644 --- a/tests/baselines/reference/parserSymbolIndexer3.errors.txt +++ b/tests/baselines/reference/parserSymbolIndexer3.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer3.ts(2,13): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer3.ts(2,13): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer3.ts (1 errors) ==== class C { static [s: symbol]: string; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolIndexer4.errors.txt b/tests/baselines/reference/parserSymbolIndexer4.errors.txt index 1cf184a48472b..9437b29303967 100644 --- a/tests/baselines/reference/parserSymbolIndexer4.errors.txt +++ b/tests/baselines/reference/parserSymbolIndexer4.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer4.ts(2,6): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer4.ts(2,6): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer4.ts (1 errors) ==== var x: { [s: symbol]: string; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/propertiesAndIndexers.errors.txt b/tests/baselines/reference/propertiesAndIndexers.errors.txt index 4ab8bba644c97..96d14be7fa146 100644 --- a/tests/baselines/reference/propertiesAndIndexers.errors.txt +++ b/tests/baselines/reference/propertiesAndIndexers.errors.txt @@ -1,25 +1,28 @@ -tests/cases/compiler/propertiesAndIndexers.ts(16,5): error TS2412: Property '1' of type 'Z' is not assignable to numeric index type 'string'. -tests/cases/compiler/propertiesAndIndexers.ts(18,5): error TS2412: Property '3' of type 'boolean' is not assignable to numeric index type 'string'. -tests/cases/compiler/propertiesAndIndexers.ts(19,5): error TS2412: Property '6' of type '() => string' is not assignable to numeric index type 'string'. -tests/cases/compiler/propertiesAndIndexers.ts(23,5): error TS2412: Property '4' of type 'boolean' is not assignable to numeric index type 'string'. -tests/cases/compiler/propertiesAndIndexers.ts(28,5): error TS2411: Property '1' of type 'Z' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers.ts(28,5): error TS2411: Property 'a' of type 'Y' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers.ts(28,5): error TS2411: Property 'b' of type 'X' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers.ts(29,5): error TS2411: Property 'c' of type 'boolean' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers.ts(30,5): error TS2411: Property '3' of type 'boolean' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property '4' of type 'boolean' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property '5' of type 'string' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property '6' of type '() => string' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2413: Numeric index type 'string' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers.ts(34,5): error TS2411: Property '2' of type 'Z' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers.ts(34,5): error TS2412: Property '2' of type 'Z' is not assignable to numeric index type 'string'. -tests/cases/compiler/propertiesAndIndexers.ts(35,5): error TS2412: Property 'Infinity' of type 'number' is not assignable to numeric index type 'string'. -tests/cases/compiler/propertiesAndIndexers.ts(36,5): error TS2411: Property 'zoo' of type 'string' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers.ts(44,5): error TS2411: Property 't' of type 'number' is not assignable to string index type 'string'. -tests/cases/compiler/propertiesAndIndexers.ts(50,5): error TS2412: Property '3' of type 'boolean' is not assignable to numeric index type 'string'. +tests/cases/compiler/propertiesAndIndexers.ts(18,5): error TS2412: Property '3' of type 'boolean' is not assignable to numeric index '[number]: string'. +tests/cases/compiler/propertiesAndIndexers.ts(19,5): error TS2412: Property '6' of type '() => string' is not assignable to numeric index '[number]: string'. +tests/cases/compiler/propertiesAndIndexers.ts(22,11): error TS2412: Property '1' of type 'Z' is not assignable to numeric index '[number]: string'. +tests/cases/compiler/propertiesAndIndexers.ts(23,5): error TS2412: Property '4' of type 'boolean' is not assignable to numeric index '[number]: string'. +tests/cases/compiler/propertiesAndIndexers.ts(28,5): error TS2411: Property '1' of type 'Z' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(28,5): error TS2411: Property 'a' of type 'Y' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(28,5): error TS2411: Property 'b' of type 'X' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(29,5): error TS2411: Property 'c' of type 'boolean' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(30,5): error TS2411: Property '3' of type 'boolean' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property '1' of type 'Z' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property '3' of type 'boolean' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property '4' of type 'boolean' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property '5' of type 'string' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property '6' of type '() => string' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property 'a' of type 'Y' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property 'b' of type 'X' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property 'c' of type 'boolean' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2413: Numeric index '[number]: string' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(34,5): error TS2411: Property '2' of type 'Z' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(36,5): error TS2411: Property 'zoo' of type 'string' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers.ts(44,5): error TS2411: Property 't' of type 'number' is not assignable to string index '[string]: string'. +tests/cases/compiler/propertiesAndIndexers.ts(50,5): error TS2412: Property '3' of type 'boolean' is not assignable to numeric index '[number]: string'. -==== tests/cases/compiler/propertiesAndIndexers.ts (19 errors) ==== +==== tests/cases/compiler/propertiesAndIndexers.ts (22 errors) ==== interface X { } interface Y { n: number; @@ -36,60 +39,66 @@ tests/cases/compiler/propertiesAndIndexers.ts(50,5): error TS2412: Property '3' interface B extends A { [n: number]: string; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '1' of type 'Z' is not assignable to numeric index type 'string'. c: boolean; 3: boolean; ~~~~~~~~~~~ -!!! error TS2412: Property '3' of type 'boolean' is not assignable to numeric index type 'string'. +!!! error TS2412: Property '3' of type 'boolean' is not assignable to numeric index '[number]: string'. 6(): string; ~~~~~~~~~~~~ -!!! error TS2412: Property '6' of type '() => string' is not assignable to numeric index type 'string'. +!!! error TS2412: Property '6' of type '() => string' is not assignable to numeric index '[number]: string'. } interface B { + ~ +!!! error TS2412: Property '1' of type 'Z' is not assignable to numeric index '[number]: string'. 4: boolean; ~~~~~~~~~~~ -!!! error TS2412: Property '4' of type 'boolean' is not assignable to numeric index type 'string'. +!!! error TS2412: Property '4' of type 'boolean' is not assignable to numeric index '[number]: string'. 5: string; } interface C extends A { [s: string]: number; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '1' of type 'Z' is not assignable to string index type 'number'. +!!! error TS2411: Property '1' of type 'Z' is not assignable to string index '[string]: number'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'a' of type 'Y' is not assignable to string index type 'number'. +!!! error TS2411: Property 'a' of type 'Y' is not assignable to string index '[string]: number'. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'b' of type 'X' is not assignable to string index type 'number'. +!!! error TS2411: Property 'b' of type 'X' is not assignable to string index '[string]: number'. c: boolean; ~~~~~~~~~~~ -!!! error TS2411: Property 'c' of type 'boolean' is not assignable to string index type 'number'. +!!! error TS2411: Property 'c' of type 'boolean' is not assignable to string index '[string]: number'. 3: boolean; ~~~~~~~~~~~ -!!! error TS2411: Property '3' of type 'boolean' is not assignable to string index type 'number'. +!!! error TS2411: Property '3' of type 'boolean' is not assignable to string index '[string]: number'. } interface D extends B, C { ~ -!!! error TS2411: Property '4' of type 'boolean' is not assignable to string index type 'number'. +!!! error TS2411: Property '1' of type 'Z' is not assignable to string index '[string]: number'. + ~ +!!! error TS2411: Property '3' of type 'boolean' is not assignable to string index '[string]: number'. + ~ +!!! error TS2411: Property '4' of type 'boolean' is not assignable to string index '[string]: number'. ~ -!!! error TS2411: Property '5' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property '5' of type 'string' is not assignable to string index '[string]: number'. ~ -!!! error TS2411: Property '6' of type '() => string' is not assignable to string index type 'number'. +!!! error TS2411: Property '6' of type '() => string' is not assignable to string index '[string]: number'. ~ -!!! error TS2413: Numeric index type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property 'a' of type 'Y' is not assignable to string index '[string]: number'. + ~ +!!! error TS2411: Property 'b' of type 'X' is not assignable to string index '[string]: number'. + ~ +!!! error TS2411: Property 'c' of type 'boolean' is not assignable to string index '[string]: number'. + ~ +!!! error TS2413: Numeric index '[number]: string' is not assignable to string index '[string]: number'. 2: Z; ~~~~~ -!!! error TS2411: Property '2' of type 'Z' is not assignable to string index type 'number'. - ~~~~~ -!!! error TS2412: Property '2' of type 'Z' is not assignable to numeric index type 'string'. +!!! error TS2411: Property '2' of type 'Z' is not assignable to string index '[string]: number'. Infinity: number; - ~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property 'Infinity' of type 'number' is not assignable to numeric index type 'string'. zoo: string; ~~~~~~~~~~~~ -!!! error TS2411: Property 'zoo' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property 'zoo' of type 'string' is not assignable to string index '[string]: number'. } class P { @@ -99,7 +108,7 @@ tests/cases/compiler/propertiesAndIndexers.ts(50,5): error TS2412: Property '3' class Q extends P { t: number; ~~~~~~~~~~ -!!! error TS2411: Property 't' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property 't' of type 'number' is not assignable to string index '[string]: string'. } var c: { @@ -107,5 +116,5 @@ tests/cases/compiler/propertiesAndIndexers.ts(50,5): error TS2412: Property '3' c: boolean; 3: boolean; ~~~~~~~~~~~ -!!! error TS2412: Property '3' of type 'boolean' is not assignable to numeric index type 'string'. +!!! error TS2412: Property '3' of type 'boolean' is not assignable to numeric index '[number]: string'. }; \ No newline at end of file diff --git a/tests/baselines/reference/propertiesAndIndexers2.errors.txt b/tests/baselines/reference/propertiesAndIndexers2.errors.txt index e1ab8c9d13d90..c97e470d8be8e 100644 --- a/tests/baselines/reference/propertiesAndIndexers2.errors.txt +++ b/tests/baselines/reference/propertiesAndIndexers2.errors.txt @@ -1,19 +1,19 @@ -tests/cases/compiler/propertiesAndIndexers2.ts(2,5): error TS2413: Numeric index type 'string' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers2.ts(8,5): error TS2411: Property 'c' of type 'string' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers2.ts(9,5): error TS2411: Property '3' of type 'string' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers2.ts(10,5): error TS2411: Property 'Infinity' of type 'string' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers2.ts(11,5): error TS2411: Property '"-Infinity"' of type 'string' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers2.ts(12,5): error TS2411: Property 'NaN' of type 'string' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers2.ts(13,5): error TS2411: Property '"-NaN"' of type 'string' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers2.ts(14,5): error TS2411: Property '6' of type '() => string' is not assignable to string index type 'number'. -tests/cases/compiler/propertiesAndIndexers2.ts(14,5): error TS2412: Property '6' of type '() => string' is not assignable to numeric index type 'string'. +tests/cases/compiler/propertiesAndIndexers2.ts(2,5): error TS2413: Numeric index '[number]: string' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers2.ts(8,5): error TS2411: Property 'c' of type 'string' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers2.ts(9,5): error TS2411: Property '3' of type 'string' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers2.ts(10,5): error TS2411: Property 'Infinity' of type 'string' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers2.ts(11,5): error TS2411: Property '"-Infinity"' of type 'string' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers2.ts(12,5): error TS2411: Property 'NaN' of type 'string' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers2.ts(13,5): error TS2411: Property '"-NaN"' of type 'string' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers2.ts(14,5): error TS2411: Property '6' of type '() => string' is not assignable to string index '[string]: number'. +tests/cases/compiler/propertiesAndIndexers2.ts(14,5): error TS2412: Property '6' of type '() => string' is not assignable to numeric index '[number]: string'. ==== tests/cases/compiler/propertiesAndIndexers2.ts (9 errors) ==== interface A { [n: number]: string; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2413: Numeric index type 'string' is not assignable to string index type 'number'. +!!! error TS2413: Numeric index '[number]: string' is not assignable to string index '[string]: number'. [s: string]: number; } @@ -21,26 +21,26 @@ tests/cases/compiler/propertiesAndIndexers2.ts(14,5): error TS2412: Property '6' interface B extends A { c: string; ~~~~~~~~~~ -!!! error TS2411: Property 'c' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property 'c' of type 'string' is not assignable to string index '[string]: number'. 3: string; ~~~~~~~~~~ -!!! error TS2411: Property '3' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property '3' of type 'string' is not assignable to string index '[string]: number'. Infinity: string; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'Infinity' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property 'Infinity' of type 'string' is not assignable to string index '[string]: number'. "-Infinity": string; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property '"-Infinity"' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property '"-Infinity"' of type 'string' is not assignable to string index '[string]: number'. NaN: string; ~~~~~~~~~~~~ -!!! error TS2411: Property 'NaN' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property 'NaN' of type 'string' is not assignable to string index '[string]: number'. "-NaN": string; ~~~~~~~~~~~~~~~ -!!! error TS2411: Property '"-NaN"' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property '"-NaN"' of type 'string' is not assignable to string index '[string]: number'. 6(): string; ~~~~~~~~~~~~ -!!! error TS2411: Property '6' of type '() => string' is not assignable to string index type 'number'. +!!! error TS2411: Property '6' of type '() => string' is not assignable to string index '[string]: number'. ~~~~~~~~~~~~ -!!! error TS2412: Property '6' of type '() => string' is not assignable to numeric index type 'string'. +!!! error TS2412: Property '6' of type '() => string' is not assignable to numeric index '[number]: string'. } \ No newline at end of file diff --git a/tests/baselines/reference/propertiesAndIndexersForNumericNames.errors.txt b/tests/baselines/reference/propertiesAndIndexersForNumericNames.errors.txt index 01dcb61c70c56..ebccf12d4d6bd 100644 --- a/tests/baselines/reference/propertiesAndIndexersForNumericNames.errors.txt +++ b/tests/baselines/reference/propertiesAndIndexersForNumericNames.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(6,5): error TS2412: Property '"1"' of type 'string' is not assignable to numeric index type 'number'. -tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(7,5): error TS2412: Property '"-1"' of type 'string' is not assignable to numeric index type 'number'. -tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(8,5): error TS2412: Property '"-2.5"' of type 'string' is not assignable to numeric index type 'number'. -tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(9,5): error TS2412: Property '"3.141592"' of type 'string' is not assignable to numeric index type 'number'. -tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(10,5): error TS2412: Property '"1.2e-20"' of type 'string' is not assignable to numeric index type 'number'. -tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(11,5): error TS2412: Property '"Infinity"' of type 'string' is not assignable to numeric index type 'number'. -tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(12,5): error TS2412: Property '"-Infinity"' of type 'string' is not assignable to numeric index type 'number'. -tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(13,5): error TS2412: Property '"NaN"' of type 'string' is not assignable to numeric index type 'number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(6,5): error TS2412: Property '"1"' of type 'string' is not assignable to numeric index '[number]: number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(7,5): error TS2412: Property '"-1"' of type 'string' is not assignable to numeric index '[number]: number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(8,5): error TS2412: Property '"-2.5"' of type 'string' is not assignable to numeric index '[number]: number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(9,5): error TS2412: Property '"3.141592"' of type 'string' is not assignable to numeric index '[number]: number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(10,5): error TS2412: Property '"1.2e-20"' of type 'string' is not assignable to numeric index '[number]: number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(11,5): error TS2412: Property '"Infinity"' of type 'string' is not assignable to numeric index '[number]: number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(12,5): error TS2412: Property '"-Infinity"' of type 'string' is not assignable to numeric index '[number]: number'. +tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(13,5): error TS2412: Property '"NaN"' of type 'string' is not assignable to numeric index '[number]: number'. ==== tests/cases/compiler/propertiesAndIndexersForNumericNames.ts (8 errors) ==== @@ -16,28 +16,28 @@ tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(13,5): error TS2412 // because their types are not compatible with the numeric indexer. public "1": string = "number"; // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '"1"' of type 'string' is not assignable to numeric index type 'number'. +!!! error TS2412: Property '"1"' of type 'string' is not assignable to numeric index '[number]: number'. public "-1": string = "negative number"; // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '"-1"' of type 'string' is not assignable to numeric index type 'number'. +!!! error TS2412: Property '"-1"' of type 'string' is not assignable to numeric index '[number]: number'. public "-2.5": string = "negative number"; // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '"-2.5"' of type 'string' is not assignable to numeric index type 'number'. +!!! error TS2412: Property '"-2.5"' of type 'string' is not assignable to numeric index '[number]: number'. public "3.141592": string = "pi-sitive number"; // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '"3.141592"' of type 'string' is not assignable to numeric index type 'number'. +!!! error TS2412: Property '"3.141592"' of type 'string' is not assignable to numeric index '[number]: number'. public "1.2e-20": string = "really small number"; // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '"1.2e-20"' of type 'string' is not assignable to numeric index type 'number'. +!!! error TS2412: Property '"1.2e-20"' of type 'string' is not assignable to numeric index '[number]: number'. public "Infinity": string = "A gillion"; // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '"Infinity"' of type 'string' is not assignable to numeric index type 'number'. +!!! error TS2412: Property '"Infinity"' of type 'string' is not assignable to numeric index '[number]: number'. public "-Infinity": string = "Negative-a-gillion"; // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '"-Infinity"' of type 'string' is not assignable to numeric index type 'number'. +!!! error TS2412: Property '"-Infinity"' of type 'string' is not assignable to numeric index '[number]: number'. public "NaN": string = "not a number"; // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2412: Property '"NaN"' of type 'string' is not assignable to numeric index type 'number'. +!!! error TS2412: Property '"NaN"' of type 'string' is not assignable to numeric index '[number]: number'. // These all have *partially* numeric names, // but should really be treated as plain string literals. diff --git a/tests/baselines/reference/stringIndexerAndConstructor.errors.txt b/tests/baselines/reference/stringIndexerAndConstructor.errors.txt index d98f195f74ca0..0a3ea652d7c95 100644 --- a/tests/baselines/reference/stringIndexerAndConstructor.errors.txt +++ b/tests/baselines/reference/stringIndexerAndConstructor.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/stringIndexerAndConstructor.ts(11,5): error TS2411: Property '""' of type 'string' is not assignable to string index type 'number'. -tests/cases/compiler/stringIndexerAndConstructor.ts(12,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'number'. +tests/cases/compiler/stringIndexerAndConstructor.ts(11,5): error TS2411: Property '""' of type 'string' is not assignable to string index '[string]: number'. +tests/cases/compiler/stringIndexerAndConstructor.ts(12,5): error TS2411: Property 'd' of type 'string' is not assignable to string index '[string]: number'. ==== tests/cases/compiler/stringIndexerAndConstructor.ts (2 errors) ==== @@ -15,8 +15,8 @@ tests/cases/compiler/stringIndexerAndConstructor.ts(12,5): error TS2411: Propert new (): boolean; "": string; ~~~~~~~~~~~ -!!! error TS2411: Property '""' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property '""' of type 'string' is not assignable to string index '[string]: number'. d: string; ~~~~~~~~~~ -!!! error TS2411: Property 'd' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property 'd' of type 'string' is not assignable to string index '[string]: number'. } \ No newline at end of file diff --git a/tests/baselines/reference/stringIndexerAndConstructor1.errors.txt b/tests/baselines/reference/stringIndexerAndConstructor1.errors.txt index 2caf30e6fe525..b62dfe123c490 100644 --- a/tests/baselines/reference/stringIndexerAndConstructor1.errors.txt +++ b/tests/baselines/reference/stringIndexerAndConstructor1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/stringIndexerAndConstructor1.ts(3,5): error TS2411: Property '""' of type 'string' is not assignable to string index type 'number'. +tests/cases/compiler/stringIndexerAndConstructor1.ts(3,5): error TS2411: Property '""' of type 'string' is not assignable to string index '[string]: number'. ==== tests/cases/compiler/stringIndexerAndConstructor1.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/compiler/stringIndexerAndConstructor1.ts(3,5): error TS2411: Propert [s: string]: number; "": string; ~~~~~~~~~~~ -!!! error TS2411: Property '""' of type 'string' is not assignable to string index type 'number'. +!!! error TS2411: Property '""' of type 'string' is not assignable to string index '[string]: number'. } \ No newline at end of file diff --git a/tests/baselines/reference/stringIndexerAssignments1.errors.txt b/tests/baselines/reference/stringIndexerAssignments1.errors.txt index 908371bc7dd0e..1d6cabaa47fa7 100644 --- a/tests/baselines/reference/stringIndexerAssignments1.errors.txt +++ b/tests/baselines/reference/stringIndexerAssignments1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/stringIndexerAssignments1.ts(4,1): error TS2322: Type '{ one: string; }' is not assignable to type '{ [index: string]: string; one: string; }'. - Index signature is missing in type '{ one: string; }'. + Missing [string] index signature in type '{ one: string; }'. tests/cases/compiler/stringIndexerAssignments1.ts(5,1): error TS2322: Type '{ one: number; two: string; }' is not assignable to type '{ [index: string]: string; one: string; }'. Types of property 'one' are incompatible. Type 'number' is not assignable to type 'string'. @@ -12,7 +12,7 @@ tests/cases/compiler/stringIndexerAssignments1.ts(5,1): error TS2322: Type '{ on x = a; ~ !!! error TS2322: Type '{ one: string; }' is not assignable to type '{ [index: string]: string; one: string; }'. -!!! error TS2322: Index signature is missing in type '{ one: string; }'. +!!! error TS2322: Missing [string] index signature in type '{ one: string; }'. x = b; // error ~ !!! error TS2322: Type '{ one: number; two: string; }' is not assignable to type '{ [index: string]: string; one: string; }'. diff --git a/tests/baselines/reference/stringIndexerAssignments2.errors.txt b/tests/baselines/reference/stringIndexerAssignments2.errors.txt index 256a9820a0c44..b280eb599bd6a 100644 --- a/tests/baselines/reference/stringIndexerAssignments2.errors.txt +++ b/tests/baselines/reference/stringIndexerAssignments2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/stringIndexerAssignments2.ts(19,1): error TS2322: Type 'C2' is not assignable to type 'C1'. - Index signature is missing in type 'C2'. + Missing [string] index signature in type 'C2'. tests/cases/compiler/stringIndexerAssignments2.ts(20,1): error TS2322: Type 'C3' is not assignable to type 'C1'. Types of property 'one' are incompatible. Type 'number' is not assignable to type 'string'. @@ -27,7 +27,7 @@ tests/cases/compiler/stringIndexerAssignments2.ts(20,1): error TS2322: Type 'C3' x = a; ~ !!! error TS2322: Type 'C2' is not assignable to type 'C1'. -!!! error TS2322: Index signature is missing in type 'C2'. +!!! error TS2322: Missing [string] index signature in type 'C2'. x = b; ~ !!! error TS2322: Type 'C3' is not assignable to type 'C1'. diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index e3dfd6133c933..1121ec35ba235 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -1,29 +1,29 @@ -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(13,5): error TS2411: Property 'b' of type 'number' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(14,5): error TS2411: Property 'c' of type '() => {}' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(16,5): error TS2411: Property '"e"' of type 'number' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(18,5): error TS2411: Property '2.0' of type 'number' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(20,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(21,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(13,5): error TS2411: Property 'b' of type 'number' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(14,5): error TS2411: Property 'c' of type '() => {}' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(16,5): error TS2411: Property '"e"' of type 'number' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(18,5): error TS2411: Property '2.0' of type 'number' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(20,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(21,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index '[string]: string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(26,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(28,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(28,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index '[string]: string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(45,5): error TS2411: Property 'b' of type 'number' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(46,5): error TS2411: Property 'c' of type '() => {}' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(48,5): error TS2411: Property '"e"' of type 'number' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(50,5): error TS2411: Property '2.0' of type 'number' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(53,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(55,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(56,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(63,5): error TS2411: Property 'b' of type 'number' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(64,5): error TS2411: Property 'c' of type '() => {}' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(66,5): error TS2411: Property '"e"' of type 'number' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(68,5): error TS2411: Property '2.0' of type 'number' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(71,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(74,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(45,5): error TS2411: Property 'b' of type 'number' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(46,5): error TS2411: Property 'c' of type '() => {}' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(48,5): error TS2411: Property '"e"' of type 'number' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(50,5): error TS2411: Property '2.0' of type 'number' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(53,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(55,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(56,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(63,5): error TS2411: Property 'b' of type 'number' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(64,5): error TS2411: Property 'c' of type '() => {}' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(66,5): error TS2411: Property '"e"' of type 'number' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(68,5): error TS2411: Property '2.0' of type 'number' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(71,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(74,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index '[string]: string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | MyString | (() => void); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. - Index signatures are incompatible. + Index signatures '[string]: string | number | MyString | (() => void)' and '[string]: string' are incompatible. Type 'string | number | MyString | (() => void)' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -45,25 +45,25 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon a: string; // ok b: number; // error ~~~~~~~~~~ -!!! error TS2411: Property 'b' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property 'b' of type 'number' is not assignable to string index '[string]: string'. c: () => {} // error ~~~~~~~~~~~ -!!! error TS2411: Property 'c' of type '() => {}' is not assignable to string index type 'string'. +!!! error TS2411: Property 'c' of type '() => {}' is not assignable to string index '[string]: string'. "d": string; // ok "e": number; // error ~~~~~~~~~~~~ -!!! error TS2411: Property '"e"' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property '"e"' of type 'number' is not assignable to string index '[string]: string'. 1.0: string; // ok 2.0: number; // error ~~~~~~~~~~~~ -!!! error TS2411: Property '2.0' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property '2.0' of type 'number' is not assignable to string index '[string]: string'. "3.0": string; // ok "4.0": number; // error ~~~~~~~~~~~~~~ -!!! error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property '"4.0"' of type 'number' is not assignable to string index '[string]: string'. f: MyString; // error ~~~~~~~~~~~~ -!!! error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. +!!! error TS2411: Property 'f' of type 'MyString' is not assignable to string index '[string]: string'. get X() { // ok ~ @@ -80,7 +80,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon ~~~~~~~~~~~~~~~~~~ } ~~~~~ -!!! error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. +!!! error TS2411: Property 'foo' of type '() => string' is not assignable to string index '[string]: string'. static sa: number; // ok static sb: string; // ok @@ -99,30 +99,30 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon a: string; // ok b: number; // error ~~~~~~~~~~ -!!! error TS2411: Property 'b' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property 'b' of type 'number' is not assignable to string index '[string]: string'. c: () => {} // error ~~~~~~~~~~~ -!!! error TS2411: Property 'c' of type '() => {}' is not assignable to string index type 'string'. +!!! error TS2411: Property 'c' of type '() => {}' is not assignable to string index '[string]: string'. "d": string; // ok "e": number; // error ~~~~~~~~~~~~ -!!! error TS2411: Property '"e"' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property '"e"' of type 'number' is not assignable to string index '[string]: string'. 1.0: string; // ok 2.0: number; // error ~~~~~~~~~~~~ -!!! error TS2411: Property '2.0' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property '2.0' of type 'number' is not assignable to string index '[string]: string'. (): string; // ok (x): number // ok foo(): string; // error ~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. +!!! error TS2411: Property 'foo' of type '() => string' is not assignable to string index '[string]: string'. "3.0": string; // ok "4.0": number; // error ~~~~~~~~~~~~~~ -!!! error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property '"4.0"' of type 'number' is not assignable to string index '[string]: string'. f: MyString; // error ~~~~~~~~~~~~ -!!! error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. +!!! error TS2411: Property 'f' of type 'MyString' is not assignable to string index '[string]: string'. } var a: { @@ -131,37 +131,37 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon a: string; // ok b: number; // error ~~~~~~~~~~ -!!! error TS2411: Property 'b' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property 'b' of type 'number' is not assignable to string index '[string]: string'. c: () => {} // error ~~~~~~~~~~~ -!!! error TS2411: Property 'c' of type '() => {}' is not assignable to string index type 'string'. +!!! error TS2411: Property 'c' of type '() => {}' is not assignable to string index '[string]: string'. "d": string; // ok "e": number; // error ~~~~~~~~~~~~ -!!! error TS2411: Property '"e"' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property '"e"' of type 'number' is not assignable to string index '[string]: string'. 1.0: string; // ok 2.0: number; // error ~~~~~~~~~~~~ -!!! error TS2411: Property '2.0' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property '2.0' of type 'number' is not assignable to string index '[string]: string'. (): string; // ok (x): number // ok foo(): string; // error ~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. +!!! error TS2411: Property 'foo' of type '() => string' is not assignable to string index '[string]: string'. "3.0": string; // ok "4.0": number; // error ~~~~~~~~~~~~~~ -!!! error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. +!!! error TS2411: Property '"4.0"' of type 'number' is not assignable to string index '[string]: string'. f: MyString; // error ~~~~~~~~~~~~ -!!! error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. +!!! error TS2411: Property 'f' of type 'MyString' is not assignable to string index '[string]: string'. } // error var b: { [x: string]: string; } = { ~ !!! error TS2322: Type '{ [x: string]: string | number | MyString | (() => void); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: string | number | MyString | (() => void)' and '[string]: string' are incompatible. !!! error TS2322: Type 'string | number | MyString | (() => void)' is not assignable to type 'string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. a: '', diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt index faef790545368..4e9f0a095ef7a 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(15,5): error TS2411: Property 'c' of type 'number' is not assignable to string index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(23,5): error TS2411: Property 'c' of type 'number' is not assignable to string index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(24,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(31,5): error TS2411: Property 'c' of type 'number' is not assignable to string index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(32,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(15,5): error TS2411: Property 'c' of type 'number' is not assignable to string index '[string]: A'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2411: Property 'd' of type 'string' is not assignable to string index '[string]: A'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(23,5): error TS2411: Property 'c' of type 'number' is not assignable to string index '[string]: A'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(24,5): error TS2411: Property 'd' of type 'string' is not assignable to string index '[string]: A'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(31,5): error TS2411: Property 'c' of type 'number' is not assignable to string index '[string]: A'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(32,5): error TS2411: Property 'd' of type 'string' is not assignable to string index '[string]: A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(36,5): error TS2322: Type '{ [x: string]: typeof A; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. - Index signatures are incompatible. + Index signatures '[string]: typeof A' and '[string]: A' are incompatible. Type 'typeof A' is not assignable to type 'A'. Property 'foo' is missing in type 'typeof A'. @@ -27,10 +27,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon b: B; // ok c: number; // error ~~~~~~~~~~ -!!! error TS2411: Property 'c' of type 'number' is not assignable to string index type 'A'. +!!! error TS2411: Property 'c' of type 'number' is not assignable to string index '[string]: A'. d: string; // error ~~~~~~~~~~ -!!! error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. +!!! error TS2411: Property 'd' of type 'string' is not assignable to string index '[string]: A'. } interface Foo2 { @@ -39,10 +39,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon b: B; // ok c: number; // error ~~~~~~~~~~ -!!! error TS2411: Property 'c' of type 'number' is not assignable to string index type 'A'. +!!! error TS2411: Property 'c' of type 'number' is not assignable to string index '[string]: A'. d: string; // error ~~~~~~~~~~ -!!! error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. +!!! error TS2411: Property 'd' of type 'string' is not assignable to string index '[string]: A'. } var a: { @@ -51,17 +51,17 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon b: B; // ok c: number; // error ~~~~~~~~~~ -!!! error TS2411: Property 'c' of type 'number' is not assignable to string index type 'A'. +!!! error TS2411: Property 'c' of type 'number' is not assignable to string index '[string]: A'. d: string; // error ~~~~~~~~~~ -!!! error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. +!!! error TS2411: Property 'd' of type 'string' is not assignable to string index '[string]: A'. }; // error var b: { [x: string]: A } = { ~ !!! error TS2322: Type '{ [x: string]: typeof A; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: typeof A' and '[string]: A' are incompatible. !!! error TS2322: Type 'typeof A' is not assignable to type 'A'. !!! error TS2322: Property 'foo' is missing in type 'typeof A'. a: A, diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt index eeedf58ab7367..2aa568c7b7496 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt @@ -3,12 +3,12 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(12,10): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(14,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(14,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(17,7): error TS2415: Class 'D3' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(17,10): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(19,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(19,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(22,10): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(31,10): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(31,23): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. @@ -17,19 +17,19 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(36,10): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(36,23): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(38,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(38,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(41,7): error TS2415: Class 'D7' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(41,10): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(41,23): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(43,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(43,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(48,7): error TS2415: Class 'D8' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(48,10): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(48,23): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(50,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(50,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(53,10): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(53,23): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(58,7): error TS2415: Class 'D10' incorrectly extends base class 'C3'. @@ -37,19 +37,19 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf Type 'U' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(58,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(58,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(60,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(60,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(65,7): error TS2415: Class 'D11' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'V' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(65,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(65,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(67,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(67,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(70,7): error TS2415: Class 'D12' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'V' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(70,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(70,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(72,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(72,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(75,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(75,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(83,7): error TS2415: Class 'D14' incorrectly extends base class 'C3'. @@ -57,7 +57,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf Type 'T' is not assignable to type 'Date'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(83,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(83,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(85,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'Date'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(85,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: Date'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(88,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(88,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(93,7): error TS2415: Class 'D16' incorrectly extends base class 'C3'. @@ -65,25 +65,25 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(93,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(93,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(95,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(95,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(98,7): error TS2415: Class 'D17' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(98,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(98,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(100,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(100,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(105,7): error TS2415: Class 'D18' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'Date'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(105,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(105,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(107,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'Date'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(107,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: Date'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(110,7): error TS2415: Class 'D19' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(110,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(110,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(112,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(112,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(115,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(115,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(120,7): error TS2415: Class 'D21' incorrectly extends base class 'C3'. @@ -91,25 +91,25 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf Type 'U' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(120,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(120,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(122,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(122,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(127,7): error TS2415: Class 'D22' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'Date'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(127,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(127,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(129,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'Date'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(129,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: Date'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(132,7): error TS2415: Class 'D23' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'V' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(132,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(132,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(137,7): error TS2415: Class 'D24' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'V' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(137,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(137,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(142,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(142,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(149,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. @@ -119,19 +119,19 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(154,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(154,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(156,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(156,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index '[string]: T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(159,7): error TS2415: Class 'D28' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'Date' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(159,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(159,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(161,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(161,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index '[string]: U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(164,7): error TS2415: Class 'D29' incorrectly extends base class 'C3'. Types of property 'foo' are incompatible. Type 'Date' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(164,11): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(164,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(166,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(166,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index '[string]: V'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts (94 errors) ==== @@ -158,7 +158,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: U; foo: T; // ok ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. +!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: U'. } class D3 extends C3 { @@ -171,7 +171,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: U; // error ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: T'. } class D4 extends C3 { @@ -206,7 +206,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: U; foo: T; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. +!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: U'. } class D7 extends C3 { @@ -221,7 +221,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: V; foo: T; // ok ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. +!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: V'. } // test if U is a subtype of T, U, V @@ -238,7 +238,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: U; // error ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: T'. } class D9 extends C3 { @@ -262,7 +262,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: V; foo: U; // ok ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. +!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: V'. } // test if V is a subtype of T, U, V @@ -279,7 +279,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: V; // error ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: T'. } class D12 extends C3 { @@ -294,7 +294,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: U; foo: V; // error ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. +!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: U'. } class D13 extends C3 { @@ -321,7 +321,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: Date; foo: T; // ok ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'Date'. +!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: Date'. } class D15 extends C3 { @@ -345,7 +345,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: U; foo: T; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. +!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: U'. } class D17 extends C3 { @@ -360,7 +360,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: V; foo: T; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. +!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: V'. } // test if U is a subtype of T, U, V, Date @@ -377,7 +377,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: Date; foo: T; // ok ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'Date'. +!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: Date'. } class D19 extends C3 { @@ -392,7 +392,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: U; // error ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: T'. } class D20 extends C3 { @@ -416,7 +416,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: V; foo: U; ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. +!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: V'. } // test if V is a subtype of T, U, V, Date @@ -433,7 +433,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: Date; foo: T; // ok ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'Date'. +!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: Date'. } class D23 extends C3 { @@ -448,7 +448,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: V; // error ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: T'. } class D24 extends C3 { @@ -463,7 +463,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: U; foo: V; // error ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. +!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: U'. } class D25 extends C3 { @@ -498,7 +498,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: Date; // error ~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'Date' is not assignable to string index '[string]: T'. } class D28 extends C3 { @@ -513,7 +513,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: U; foo: Date; // error ~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'U'. +!!! error TS2411: Property 'foo' of type 'Date' is not assignable to string index '[string]: U'. } class D29 extends C3 { @@ -528,5 +528,5 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: V; foo: Date; // error ~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'V'. +!!! error TS2411: Property 'foo' of type 'Date' is not assignable to string index '[string]: V'. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt index a9b025ccc77e0..0f41c7df64c8e 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt @@ -2,23 +2,23 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf Types of property 'foo' are incompatible. Type 'V' is not assignable to type 'Foo'. Property 'foo' is missing in type '{}'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(47,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'Foo'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(47,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: Foo'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(55,7): error TS2415: Class 'D5' incorrectly extends base class 'B1'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(60,7): error TS2415: Class 'D6' incorrectly extends base class 'B1'. Types of property 'foo' are incompatible. Type 'V' is not assignable to type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(65,7): error TS2415: Class 'D7' incorrectly extends base class 'B1'. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(75,7): error TS2415: Class 'D9' incorrectly extends base class 'B1'. Types of property 'foo' are incompatible. Type 'V' is not assignable to type 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: U'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (10 errors) ==== @@ -75,7 +75,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: Foo; foo: V; // error ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'Foo'. +!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: Foo'. } class D4 extends B1 { @@ -91,7 +91,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: U; // error ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: T'. } class D6 extends B1 { @@ -102,7 +102,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: V; // error ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: T'. } class D7 extends B1 { @@ -113,7 +113,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: U; foo: T; // error ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. +!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: U'. } class D8 extends B1 { @@ -129,5 +129,5 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: U; foo: V; // error ~~~~~~~ -!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. +!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: U'. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt index 867b622cf1a3e..d50c60d44870b 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt @@ -10,21 +10,21 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(66,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(66,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(66,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(68,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(68,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(71,11): error TS2415: Class 'D3' incorrectly extends base class 'Base'. Types of property 'foo' are incompatible. Type 'V' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(71,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(71,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(71,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(73,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(73,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(76,11): error TS2415: Class 'D4' incorrectly extends base class 'Base'. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(76,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(76,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(76,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(78,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(78,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(81,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(81,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(81,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. @@ -34,21 +34,21 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(86,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(86,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(86,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(88,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(88,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(91,11): error TS2415: Class 'D7' incorrectly extends base class 'Base'. Types of property 'foo' are incompatible. Type 'T' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(91,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(91,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(91,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(93,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(93,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(96,11): error TS2415: Class 'D8' incorrectly extends base class 'Base'. Types of property 'foo' are incompatible. Type 'U' is not assignable to type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(96,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(96,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(96,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(98,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(98,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(101,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(101,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(101,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. @@ -58,30 +58,30 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(118,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(118,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(118,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(120,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(120,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(123,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(123,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(123,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(125,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(125,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(128,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(128,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(128,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(130,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(130,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(133,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(133,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(133,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(138,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(138,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(138,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(140,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(140,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(143,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(143,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(143,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(145,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(145,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(148,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(148,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(148,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(150,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(150,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(153,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(153,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(153,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list. @@ -179,7 +179,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: U ~~~~~~ -!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: T'. } class D3, U extends Foo, V extends Foo> extends Base { @@ -196,7 +196,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: V ~~~~~~ -!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: T'. } class D4, U extends Foo, V extends Foo> extends Base { @@ -213,7 +213,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: U; foo: T ~~~~~~ -!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. +!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: U'. } class D5, U extends Foo, V extends Foo> extends Base { @@ -241,7 +241,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: U; foo: V ~~~~~~ -!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. +!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: U'. } class D7, U extends Foo, V extends Foo> extends Base { @@ -258,7 +258,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: V; foo: T ~~~~~~ -!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. +!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: V'. } class D8, U extends Foo, V extends Foo> extends Base { @@ -275,7 +275,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: V; foo: U ~~~~~~ -!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. +!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: V'. } class D9, U extends Foo, V extends Foo> extends Base { @@ -317,7 +317,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: U ~~~~~~ -!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: T'. } class D3, U extends Foo, V extends Foo> extends Base2 { @@ -330,7 +330,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: T; foo: V ~~~~~~ -!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: T'. } class D4, U extends Foo, V extends Foo> extends Base2 { @@ -343,7 +343,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: U; foo: T ~~~~~~ -!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. +!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: U'. } class D5, U extends Foo, V extends Foo> extends Base2 { @@ -367,7 +367,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: U; foo: V ~~~~~~ -!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. +!!! error TS2411: Property 'foo' of type 'V' is not assignable to string index '[string]: U'. } class D7, U extends Foo, V extends Foo> extends Base2 { @@ -380,7 +380,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: V; foo: T ~~~~~~ -!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. +!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index '[string]: V'. } class D8, U extends Foo, V extends Foo> extends Base2 { @@ -393,7 +393,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf [x: string]: V; foo: U ~~~~~~ -!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. +!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index '[string]: V'. } class D9, U extends Foo, V extends Foo> extends Base2 { diff --git a/tests/baselines/reference/subtypesOfUnion.errors.txt b/tests/baselines/reference/subtypesOfUnion.errors.txt index fade5377814f4..fe59181a6d972 100644 --- a/tests/baselines/reference/subtypesOfUnion.errors.txt +++ b/tests/baselines/reference/subtypesOfUnion.errors.txt @@ -1,32 +1,32 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(16,5): error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(18,5): error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(19,5): error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(20,5): error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(21,5): error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(22,5): error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(23,5): error TS2411: Property 'foo11' of type 'A2' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(24,5): error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(25,5): error TS2411: Property 'foo13' of type '(x: T) => T' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(26,5): error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(27,5): error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(28,5): error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(29,5): error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(30,5): error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'string | number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(35,5): error TS2411: Property 'foo2' of type 'string' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(37,5): error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(39,5): error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(40,5): error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(41,5): error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(42,5): error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(43,5): error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(44,5): error TS2411: Property 'foo11' of type 'A2' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(45,5): error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(46,5): error TS2411: Property 'foo13' of type '(x: T) => T' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(47,5): error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(48,5): error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(49,5): error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(50,5): error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'number | E'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(51,5): error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(16,5): error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(18,5): error TS2411: Property 'foo6' of type 'Date' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(19,5): error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(20,5): error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(21,5): error TS2411: Property 'foo9' of type 'I8' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(22,5): error TS2411: Property 'foo10' of type 'A' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(23,5): error TS2411: Property 'foo11' of type 'A2' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(24,5): error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(25,5): error TS2411: Property 'foo13' of type '(x: T) => T' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(26,5): error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(27,5): error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(28,5): error TS2411: Property 'foo16' of type 'T' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(29,5): error TS2411: Property 'foo17' of type 'Object' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(30,5): error TS2411: Property 'foo18' of type '{}' is not assignable to string index '[string]: string | number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(35,5): error TS2411: Property 'foo2' of type 'string' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(37,5): error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(39,5): error TS2411: Property 'foo6' of type 'Date' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(40,5): error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(41,5): error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(42,5): error TS2411: Property 'foo9' of type 'I8' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(43,5): error TS2411: Property 'foo10' of type 'A' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(44,5): error TS2411: Property 'foo11' of type 'A2' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(45,5): error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(46,5): error TS2411: Property 'foo13' of type '(x: T) => T' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(47,5): error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(48,5): error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(49,5): error TS2411: Property 'foo16' of type 'T' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(50,5): error TS2411: Property 'foo17' of type 'Object' is not assignable to string index '[string]: number | E'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(51,5): error TS2411: Property 'foo18' of type '{}' is not assignable to string index '[string]: number | E'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts (29 errors) ==== @@ -47,96 +47,96 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf foo3: number; // ok foo4: boolean; // error ~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index '[string]: string | number'. foo5: E; // ok - subtype of number foo6: Date; // error ~~~~~~~~~~~ -!!! error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo6' of type 'Date' is not assignable to string index '[string]: string | number'. foo7: RegExp; // error ~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index '[string]: string | number'. foo8: { bar: number }; // error ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index '[string]: string | number'. foo9: I8; // error ~~~~~~~~~ -!!! error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo9' of type 'I8' is not assignable to string index '[string]: string | number'. foo10: A; // error ~~~~~~~~~ -!!! error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo10' of type 'A' is not assignable to string index '[string]: string | number'. foo11: A2; // error ~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo11' of type 'A2' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo11' of type 'A2' is not assignable to string index '[string]: string | number'. foo12: (x) => number; //error ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index '[string]: string | number'. foo13: (x: T) => T; // error ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo13' of type '(x: T) => T' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo13' of type '(x: T) => T' is not assignable to string index '[string]: string | number'. foo14: typeof f; // error ~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index '[string]: string | number'. foo15: typeof c; // error ~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index '[string]: string | number'. foo16: T; // error ~~~~~~~~~ -!!! error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo16' of type 'T' is not assignable to string index '[string]: string | number'. foo17: Object; // error ~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo17' of type 'Object' is not assignable to string index '[string]: string | number'. foo18: {}; // error ~~~~~~~~~~ -!!! error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'string | number'. +!!! error TS2411: Property 'foo18' of type '{}' is not assignable to string index '[string]: string | number'. } interface I2 { [x: string]: E | number; foo: any; // ok foo2: string; // error ~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'string' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo2' of type 'string' is not assignable to string index '[string]: number | E'. foo3: number; // ok foo4: boolean; // error ~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index '[string]: number | E'. foo5: E; // ok foo6: Date; // error ~~~~~~~~~~~ -!!! error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo6' of type 'Date' is not assignable to string index '[string]: number | E'. foo7: RegExp; // error ~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index '[string]: number | E'. foo8: { bar: number }; // error ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index '[string]: number | E'. foo9: I8; // error ~~~~~~~~~ -!!! error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo9' of type 'I8' is not assignable to string index '[string]: number | E'. foo10: A; // error ~~~~~~~~~ -!!! error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo10' of type 'A' is not assignable to string index '[string]: number | E'. foo11: A2; // error ~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo11' of type 'A2' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo11' of type 'A2' is not assignable to string index '[string]: number | E'. foo12: (x) => number; //error ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index '[string]: number | E'. foo13: (x: T) => T; // error ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo13' of type '(x: T) => T' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo13' of type '(x: T) => T' is not assignable to string index '[string]: number | E'. foo14: typeof f; // error ~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index '[string]: number | E'. foo15: typeof c; // error ~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index '[string]: number | E'. foo16: T; // error ~~~~~~~~~ -!!! error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo16' of type 'T' is not assignable to string index '[string]: number | E'. foo17: Object; // error ~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo17' of type 'Object' is not assignable to string index '[string]: number | E'. foo18: {}; // error ~~~~~~~~~~ -!!! error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'number | E'. +!!! error TS2411: Property 'foo18' of type '{}' is not assignable to string index '[string]: number | E'. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithNumericIndexer.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer.errors.txt index e5ff0d47ca305..3fdea39d23d06 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer.ts(32,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[number]: Derived' and '[number]: T' are incompatible. Type 'Derived' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer.ts(36,11): error TS2415: Class 'B4' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[number]: Derived2' and '[number]: T' are incompatible. Type 'Derived2' is not assignable to type 'T'. @@ -41,7 +41,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A { ~~ !!! error TS2415: Class 'B3' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[number]: Derived' and '[number]: T' are incompatible. !!! error TS2415: Type 'Derived' is not assignable to type 'T'. [x: number]: Derived; // error, BUG? } @@ -49,7 +49,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B4 extends A { ~~ !!! error TS2415: Class 'B4' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[number]: Derived2' and '[number]: T' are incompatible. !!! error TS2415: Type 'Derived2' is not assignable to type 'T'. [x: number]: Derived2; // error, BUG? } diff --git a/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt index 01b581b7306d0..2bab8b9afbf77 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt @@ -1,16 +1,16 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts(11,11): error TS2430: Interface 'B' incorrectly extends interface 'A'. - Index signatures are incompatible. + Index signatures '[number]: Base' and '[number]: Derived' are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts(24,25): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts(32,15): error TS2430: Interface 'B3' incorrectly extends interface 'A'. - Index signatures are incompatible. + Index signatures '[number]: Base' and '[number]: T' are incompatible. Type 'Base' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts(36,15): error TS2430: Interface 'B4' incorrectly extends interface 'A'. - Index signatures are incompatible. + Index signatures '[number]: Derived' and '[number]: T' are incompatible. Type 'Derived' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts(40,15): error TS2430: Interface 'B5' incorrectly extends interface 'A'. - Index signatures are incompatible. + Index signatures '[number]: Derived2' and '[number]: T' are incompatible. Type 'Derived2' is not assignable to type 'T'. @@ -28,7 +28,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface B extends A { ~ !!! error TS2430: Interface 'B' incorrectly extends interface 'A'. -!!! error TS2430: Index signatures are incompatible. +!!! error TS2430: Index signatures '[number]: Base' and '[number]: Derived' are incompatible. !!! error TS2430: Type 'Base' is not assignable to type 'Derived'. !!! error TS2430: Property 'bar' is missing in type 'Base'. [x: number]: Base; // error @@ -56,7 +56,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface B3 extends A { ~~ !!! error TS2430: Interface 'B3' incorrectly extends interface 'A'. -!!! error TS2430: Index signatures are incompatible. +!!! error TS2430: Index signatures '[number]: Base' and '[number]: T' are incompatible. !!! error TS2430: Type 'Base' is not assignable to type 'T'. [x: number]: Base; // error } @@ -64,7 +64,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface B4 extends A { ~~ !!! error TS2430: Interface 'B4' incorrectly extends interface 'A'. -!!! error TS2430: Index signatures are incompatible. +!!! error TS2430: Index signatures '[number]: Derived' and '[number]: T' are incompatible. !!! error TS2430: Type 'Derived' is not assignable to type 'T'. [x: number]: Derived; // error } @@ -72,7 +72,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface B5 extends A { ~~ !!! error TS2430: Interface 'B5' incorrectly extends interface 'A'. -!!! error TS2430: Index signatures are incompatible. +!!! error TS2430: Index signatures '[number]: Derived2' and '[number]: T' are incompatible. !!! error TS2430: Type 'Derived2' is not assignable to type 'T'. [x: number]: Derived2; // error } diff --git a/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt index 4da8bc0290ac0..188a024665f84 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt @@ -1,16 +1,16 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts(11,7): error TS2415: Class 'B' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[number]: Base' and '[number]: Derived' are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts(24,21): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts(32,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[number]: Base' and '[number]: T' are incompatible. Type 'Base' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts(36,11): error TS2415: Class 'B4' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[number]: Derived' and '[number]: T' are incompatible. Type 'Derived' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts(40,11): error TS2415: Class 'B5' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[number]: Derived2' and '[number]: T' are incompatible. Type 'Derived2' is not assignable to type 'T'. @@ -28,7 +28,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { ~ !!! error TS2415: Class 'B' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[number]: Base' and '[number]: Derived' are incompatible. !!! error TS2415: Type 'Base' is not assignable to type 'Derived'. !!! error TS2415: Property 'bar' is missing in type 'Base'. [x: number]: Base; // error @@ -56,7 +56,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A { ~~ !!! error TS2415: Class 'B3' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[number]: Base' and '[number]: T' are incompatible. !!! error TS2415: Type 'Base' is not assignable to type 'T'. [x: number]: Base; // error } @@ -64,7 +64,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B4 extends A { ~~ !!! error TS2415: Class 'B4' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[number]: Derived' and '[number]: T' are incompatible. !!! error TS2415: Type 'Derived' is not assignable to type 'T'. [x: number]: Derived; // error } @@ -72,7 +72,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B5 extends A { ~~ !!! error TS2415: Class 'B5' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[number]: Derived2' and '[number]: T' are incompatible. !!! error TS2415: Type 'Derived2' is not assignable to type 'T'. [x: number]: Derived2; // error } diff --git a/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt index f3c9cc25a1058..60a56250d63f9 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt @@ -1,15 +1,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(11,7): error TS2415: Class 'B' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[number]: string' and '[number]: Derived' are incompatible. Type 'string' is not assignable to type 'Derived'. Property 'bar' is missing in type 'String'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(20,11): error TS2415: Class 'B' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[number]: string' and '[number]: Base' are incompatible. Type 'string' is not assignable to type 'Base'. Property 'foo' is missing in type 'String'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(20,21): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(24,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[number]: string' and '[number]: T' are incompatible. Type 'string' is not assignable to type 'T'. @@ -27,7 +27,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { ~ !!! error TS2415: Class 'B' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[number]: string' and '[number]: Derived' are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'Derived'. !!! error TS2415: Property 'bar' is missing in type 'String'. [x: number]: string; // error @@ -41,7 +41,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { ~ !!! error TS2415: Class 'B' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[number]: string' and '[number]: Base' are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'Base'. !!! error TS2415: Property 'foo' is missing in type 'String'. ~~~~~~~ @@ -53,7 +53,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A { ~~ !!! error TS2415: Class 'B3' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[number]: string' and '[number]: T' are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'T'. [x: number]: string; // error } diff --git a/tests/baselines/reference/subtypingWithNumericIndexer5.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer5.errors.txt index be4afeafcde66..1cf0157e8e9d4 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer5.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer5.errors.txt @@ -1,16 +1,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer5.ts(11,7): error TS2420: Class 'B' incorrectly implements interface 'A'. - Index signatures are incompatible. - Type 'Base' is not assignable to type 'Derived'. - Property 'bar' is missing in type 'Base'. + Index signatures '[string]: Base' and '[number]: Derived' are incompatible. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer5.ts(32,11): error TS2420: Class 'B3' incorrectly implements interface 'A'. - Index signatures are incompatible. - Type 'Base' is not assignable to type 'T'. + Index signatures '[string]: Base' and '[number]: T' are incompatible. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer5.ts(36,11): error TS2420: Class 'B4' incorrectly implements interface 'A'. - Index signatures are incompatible. - Type 'Derived' is not assignable to type 'T'. + Index signatures '[string]: Derived' and '[number]: T' are incompatible. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer5.ts(40,11): error TS2420: Class 'B5' incorrectly implements interface 'A'. - Index signatures are incompatible. - Type 'Derived2' is not assignable to type 'T'. + Index signatures '[string]: Derived2' and '[number]: T' are incompatible. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer5.ts (4 errors) ==== @@ -27,9 +22,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B implements A { ~ !!! error TS2420: Class 'B' incorrectly implements interface 'A'. -!!! error TS2420: Index signatures are incompatible. -!!! error TS2420: Type 'Base' is not assignable to type 'Derived'. -!!! error TS2420: Property 'bar' is missing in type 'Base'. +!!! error TS2420: Index signatures '[string]: Base' and '[number]: Derived' are incompatible. [x: string]: Base; // error } @@ -53,24 +46,21 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 implements A { ~~ !!! error TS2420: Class 'B3' incorrectly implements interface 'A'. -!!! error TS2420: Index signatures are incompatible. -!!! error TS2420: Type 'Base' is not assignable to type 'T'. +!!! error TS2420: Index signatures '[string]: Base' and '[number]: T' are incompatible. [x: string]: Base; // error } class B4 implements A { ~~ !!! error TS2420: Class 'B4' incorrectly implements interface 'A'. -!!! error TS2420: Index signatures are incompatible. -!!! error TS2420: Type 'Derived' is not assignable to type 'T'. +!!! error TS2420: Index signatures '[string]: Derived' and '[number]: T' are incompatible. [x: string]: Derived; // error } class B5 implements A { ~~ !!! error TS2420: Class 'B5' incorrectly implements interface 'A'. -!!! error TS2420: Index signatures are incompatible. -!!! error TS2420: Type 'Derived2' is not assignable to type 'T'. +!!! error TS2420: Index signatures '[string]: Derived2' and '[number]: T' are incompatible. [x: string]: Derived2; // error } } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithStringIndexer.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer.errors.txt index 4ad0f6654255b..fdc5dc61a5247 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer.ts(32,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[string]: Derived' and '[string]: T' are incompatible. Type 'Derived' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer.ts(36,11): error TS2415: Class 'B4' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[string]: Derived2' and '[string]: T' are incompatible. Type 'Derived2' is not assignable to type 'T'. @@ -41,7 +41,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A { ~~ !!! error TS2415: Class 'B3' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[string]: Derived' and '[string]: T' are incompatible. !!! error TS2415: Type 'Derived' is not assignable to type 'T'. [x: string]: Derived; // error } @@ -49,7 +49,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B4 extends A { ~~ !!! error TS2415: Class 'B4' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[string]: Derived2' and '[string]: T' are incompatible. !!! error TS2415: Type 'Derived2' is not assignable to type 'T'. [x: string]: Derived2; // error } diff --git a/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt index cfe8f2b8e1d10..a5c9036c66024 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt @@ -1,16 +1,16 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts(11,11): error TS2430: Interface 'B' incorrectly extends interface 'A'. - Index signatures are incompatible. + Index signatures '[string]: Base' and '[string]: Derived' are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts(24,25): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts(32,15): error TS2430: Interface 'B3' incorrectly extends interface 'A'. - Index signatures are incompatible. + Index signatures '[string]: Base' and '[string]: T' are incompatible. Type 'Base' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts(36,15): error TS2430: Interface 'B4' incorrectly extends interface 'A'. - Index signatures are incompatible. + Index signatures '[string]: Derived' and '[string]: T' are incompatible. Type 'Derived' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts(40,15): error TS2430: Interface 'B5' incorrectly extends interface 'A'. - Index signatures are incompatible. + Index signatures '[string]: Derived2' and '[string]: T' are incompatible. Type 'Derived2' is not assignable to type 'T'. @@ -28,7 +28,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface B extends A { ~ !!! error TS2430: Interface 'B' incorrectly extends interface 'A'. -!!! error TS2430: Index signatures are incompatible. +!!! error TS2430: Index signatures '[string]: Base' and '[string]: Derived' are incompatible. !!! error TS2430: Type 'Base' is not assignable to type 'Derived'. !!! error TS2430: Property 'bar' is missing in type 'Base'. [x: string]: Base; // error @@ -56,7 +56,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface B3 extends A { ~~ !!! error TS2430: Interface 'B3' incorrectly extends interface 'A'. -!!! error TS2430: Index signatures are incompatible. +!!! error TS2430: Index signatures '[string]: Base' and '[string]: T' are incompatible. !!! error TS2430: Type 'Base' is not assignable to type 'T'. [x: string]: Base; // error } @@ -64,7 +64,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface B4 extends A { ~~ !!! error TS2430: Interface 'B4' incorrectly extends interface 'A'. -!!! error TS2430: Index signatures are incompatible. +!!! error TS2430: Index signatures '[string]: Derived' and '[string]: T' are incompatible. !!! error TS2430: Type 'Derived' is not assignable to type 'T'. [x: string]: Derived; // error } @@ -72,7 +72,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface B5 extends A { ~~ !!! error TS2430: Interface 'B5' incorrectly extends interface 'A'. -!!! error TS2430: Index signatures are incompatible. +!!! error TS2430: Index signatures '[string]: Derived2' and '[string]: T' are incompatible. !!! error TS2430: Type 'Derived2' is not assignable to type 'T'. [x: string]: Derived2; // error } diff --git a/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt index 91c9f7fd47ea9..b01c5ecba6db4 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt @@ -1,16 +1,16 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts(11,7): error TS2415: Class 'B' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[string]: Base' and '[string]: Derived' are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts(24,21): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts(32,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[string]: Base' and '[string]: T' are incompatible. Type 'Base' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts(36,11): error TS2415: Class 'B4' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[string]: Derived' and '[string]: T' are incompatible. Type 'Derived' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts(40,11): error TS2415: Class 'B5' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[string]: Derived2' and '[string]: T' are incompatible. Type 'Derived2' is not assignable to type 'T'. @@ -28,7 +28,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { ~ !!! error TS2415: Class 'B' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[string]: Base' and '[string]: Derived' are incompatible. !!! error TS2415: Type 'Base' is not assignable to type 'Derived'. !!! error TS2415: Property 'bar' is missing in type 'Base'. [x: string]: Base; // error @@ -56,7 +56,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A { ~~ !!! error TS2415: Class 'B3' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[string]: Base' and '[string]: T' are incompatible. !!! error TS2415: Type 'Base' is not assignable to type 'T'. [x: string]: Base; // error } @@ -64,7 +64,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B4 extends A { ~~ !!! error TS2415: Class 'B4' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[string]: Derived' and '[string]: T' are incompatible. !!! error TS2415: Type 'Derived' is not assignable to type 'T'. [x: string]: Derived; // error } @@ -72,7 +72,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B5 extends A { ~~ !!! error TS2415: Class 'B5' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[string]: Derived2' and '[string]: T' are incompatible. !!! error TS2415: Type 'Derived2' is not assignable to type 'T'. [x: string]: Derived2; // error } diff --git a/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt index 6df716791c2f0..7cdbc7792bc8d 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt @@ -1,15 +1,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(11,7): error TS2415: Class 'B' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[string]: string' and '[string]: Derived' are incompatible. Type 'string' is not assignable to type 'Derived'. Property 'bar' is missing in type 'String'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(20,11): error TS2415: Class 'B' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[string]: string' and '[string]: Base' are incompatible. Type 'string' is not assignable to type 'Base'. Property 'foo' is missing in type 'String'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(20,21): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(24,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. - Index signatures are incompatible. + Index signatures '[string]: string' and '[string]: T' are incompatible. Type 'string' is not assignable to type 'T'. @@ -27,7 +27,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { ~ !!! error TS2415: Class 'B' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[string]: string' and '[string]: Derived' are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'Derived'. !!! error TS2415: Property 'bar' is missing in type 'String'. [x: string]: string; // error @@ -41,7 +41,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { ~ !!! error TS2415: Class 'B' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[string]: string' and '[string]: Base' are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'Base'. !!! error TS2415: Property 'foo' is missing in type 'String'. ~~~~~~~ @@ -53,7 +53,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A { ~~ !!! error TS2415: Class 'B3' incorrectly extends base class 'A'. -!!! error TS2415: Index signatures are incompatible. +!!! error TS2415: Index signatures '[string]: string' and '[string]: T' are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'T'. [x: string]: string; // error } diff --git a/tests/baselines/reference/symbolProperty17.errors.txt b/tests/baselines/reference/symbolProperty17.errors.txt index 51f77646f0db7..eaddd404a3519 100644 --- a/tests/baselines/reference/symbolProperty17.errors.txt +++ b/tests/baselines/reference/symbolProperty17.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty17.ts(3,6): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/es6/Symbols/symbolProperty17.ts(3,6): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/es6/Symbols/symbolProperty17.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/conformance/es6/Symbols/symbolProperty17.ts(3,6): error TS1023: An i [Symbol.iterator]: number; [s: symbol]: string; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. "__@iterator": string; } diff --git a/tests/baselines/reference/symbolProperty29.errors.txt b/tests/baselines/reference/symbolProperty29.errors.txt index 1efaeb2b3bfb8..ca2ac64d9d080 100644 --- a/tests/baselines/reference/symbolProperty29.errors.txt +++ b/tests/baselines/reference/symbolProperty29.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty29.ts(5,6): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/es6/Symbols/symbolProperty29.ts(5,6): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/es6/Symbols/symbolProperty29.ts (1 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/es6/Symbols/symbolProperty29.ts(5,6): error TS1023: An i } [s: symbol]: () => { x: string }; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty30.errors.txt b/tests/baselines/reference/symbolProperty30.errors.txt index b839d11d1b803..8bf2d1eac56ee 100644 --- a/tests/baselines/reference/symbolProperty30.errors.txt +++ b/tests/baselines/reference/symbolProperty30.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty30.ts(5,6): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/es6/Symbols/symbolProperty30.ts(5,6): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/es6/Symbols/symbolProperty30.ts (1 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/es6/Symbols/symbolProperty30.ts(5,6): error TS1023: An i } [s: symbol]: () => { x: number }; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty31.errors.txt b/tests/baselines/reference/symbolProperty31.errors.txt index 39735c017b2ad..fb8fdfad8419c 100644 --- a/tests/baselines/reference/symbolProperty31.errors.txt +++ b/tests/baselines/reference/symbolProperty31.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty31.ts(7,6): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/es6/Symbols/symbolProperty31.ts(7,6): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/es6/Symbols/symbolProperty31.ts (1 errors) ==== @@ -10,5 +10,5 @@ tests/cases/conformance/es6/Symbols/symbolProperty31.ts(7,6): error TS1023: An i class C2 extends C1 { [s: symbol]: () => { x: string }; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty32.errors.txt b/tests/baselines/reference/symbolProperty32.errors.txt index 4051f8f91c84b..9dc9663fa71a7 100644 --- a/tests/baselines/reference/symbolProperty32.errors.txt +++ b/tests/baselines/reference/symbolProperty32.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty32.ts(7,6): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/es6/Symbols/symbolProperty32.ts(7,6): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/es6/Symbols/symbolProperty32.ts (1 errors) ==== @@ -10,5 +10,5 @@ tests/cases/conformance/es6/Symbols/symbolProperty32.ts(7,6): error TS1023: An i class C2 extends C1 { [s: symbol]: () => { x: number }; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty33.errors.txt b/tests/baselines/reference/symbolProperty33.errors.txt index 25a16b045abe6..57fb4cf0ea597 100644 --- a/tests/baselines/reference/symbolProperty33.errors.txt +++ b/tests/baselines/reference/symbolProperty33.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty33.ts(7,6): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/es6/Symbols/symbolProperty33.ts(7,6): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/es6/Symbols/symbolProperty33.ts (1 errors) ==== @@ -10,5 +10,5 @@ tests/cases/conformance/es6/Symbols/symbolProperty33.ts(7,6): error TS1023: An i class C2 { [s: symbol]: () => { x: string }; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty34.errors.txt b/tests/baselines/reference/symbolProperty34.errors.txt index 4339af94788c3..2d8b13f58016a 100644 --- a/tests/baselines/reference/symbolProperty34.errors.txt +++ b/tests/baselines/reference/symbolProperty34.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty34.ts(7,6): error TS1023: An index signature parameter type must be 'string' or 'number'. +tests/cases/conformance/es6/Symbols/symbolProperty34.ts(7,6): error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. ==== tests/cases/conformance/es6/Symbols/symbolProperty34.ts (1 errors) ==== @@ -10,5 +10,5 @@ tests/cases/conformance/es6/Symbols/symbolProperty34.ts(7,6): error TS1023: An i class C2 { [s: symbol]: () => { x: number }; ~ -!!! error TS1023: An index signature parameter type must be 'string' or 'number'. +!!! error TS1023: An index signature parameter type must be 'string', 'number', or an enum type. } \ No newline at end of file diff --git a/tests/baselines/reference/typeName1.errors.txt b/tests/baselines/reference/typeName1.errors.txt index 84c8be360bd16..4a33efcbe914d 100644 --- a/tests/baselines/reference/typeName1.errors.txt +++ b/tests/baselines/reference/typeName1.errors.txt @@ -12,7 +12,7 @@ tests/cases/compiler/typeName1.ts(14,5): error TS2322: Type 'number' is not assi tests/cases/compiler/typeName1.ts(15,5): error TS2322: Type 'number' is not assignable to type '(s: string) => boolean'. tests/cases/compiler/typeName1.ts(16,5): error TS2322: Type 'number' is not assignable to type '{ (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }'. Property 'z' is missing in type 'Number'. -tests/cases/compiler/typeName1.ts(16,10): error TS2411: Property 'z' of type 'I' is not assignable to string index type '{ x: any; y: any; }'. +tests/cases/compiler/typeName1.ts(16,10): error TS2411: Property 'z' of type 'I' is not assignable to string index '[string]: { x: any; y: any; }'. tests/cases/compiler/typeName1.ts(17,5): error TS2322: Type 'number' is not assignable to type 'I'. Property 'k' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(18,5): error TS2322: Type 'number' is not assignable to type 'I[][][][]'. @@ -21,7 +21,7 @@ tests/cases/compiler/typeName1.ts(19,5): error TS2322: Type 'number' is not assi Property 'length' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(20,5): error TS2322: Type 'number' is not assignable to type '{ z: I; x: boolean; y: (s: string) => boolean; w: { (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }; }[][]'. Property 'length' is missing in type 'Number'. -tests/cases/compiler/typeName1.ts(20,50): error TS2411: Property 'z' of type 'I' is not assignable to string index type '{ x: any; y: any; }'. +tests/cases/compiler/typeName1.ts(20,50): error TS2411: Property 'z' of type 'I' is not assignable to string index '[string]: { x: any; y: any; }'. tests/cases/compiler/typeName1.ts(21,5): error TS2322: Type 'number' is not assignable to type '{ (): {}; new (): number; new (n: number): number; x: string; w: { y: number; }; }'. Property 'x' is missing in type 'Number'. tests/cases/compiler/typeName1.ts(22,5): error TS2322: Type 'number' is not assignable to type '{ (): string; f(x: number): boolean; p: any; q: any; }'. @@ -69,7 +69,7 @@ tests/cases/compiler/typeName1.ts(23,5): error TS2322: Type 'typeof C' is not as !!! error TS2322: Type 'number' is not assignable to type '{ (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }'. !!! error TS2322: Property 'z' is missing in type 'Number'. ~~~~ -!!! error TS2411: Property 'z' of type 'I' is not assignable to string index type '{ x: any; y: any; }'. +!!! error TS2411: Property 'z' of type 'I' is not assignable to string index '[string]: { x: any; y: any; }'. var x9:I=3; ~~ !!! error TS2322: Type 'number' is not assignable to type 'I'. @@ -87,7 +87,7 @@ tests/cases/compiler/typeName1.ts(23,5): error TS2322: Type 'typeof C' is not as !!! error TS2322: Type 'number' is not assignable to type '{ z: I; x: boolean; y: (s: string) => boolean; w: { (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }; }[][]'. !!! error TS2322: Property 'length' is missing in type 'Number'. ~~~~ -!!! error TS2411: Property 'z' of type 'I' is not assignable to string index type '{ x: any; y: any; }'. +!!! error TS2411: Property 'z' of type 'I' is not assignable to string index '[string]: { x: any; y: any; }'. var x13:{ new(): number; new(n:number):number; x: string; w: {y: number;}; (): {}; } = 3; ~~~ !!! error TS2322: Type 'number' is not assignable to type '{ (): {}; new (): number; new (n: number): number; x: string; w: { y: number; }; }'. diff --git a/tests/baselines/reference/unionSubtypeIfEveryConstituentTypeIsSubtype.errors.txt b/tests/baselines/reference/unionSubtypeIfEveryConstituentTypeIsSubtype.errors.txt index 013b5d9a9909d..54490409671df 100644 --- a/tests/baselines/reference/unionSubtypeIfEveryConstituentTypeIsSubtype.errors.txt +++ b/tests/baselines/reference/unionSubtypeIfEveryConstituentTypeIsSubtype.errors.txt @@ -1,34 +1,34 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(15,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(21,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'string'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(22,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'string'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(28,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'boolean'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(29,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'boolean'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(35,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'Date'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(36,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'Date'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(42,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'RegExp'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(43,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'RegExp'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(49,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '{ bar: number; }'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(50,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type '{ bar: number; }'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(56,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'number[]'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(57,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'number[]'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(63,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'I8'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(64,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'I8'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(70,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'A'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(71,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'A'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(77,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'A2'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(78,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'A2'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(84,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '(x: any) => number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(85,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type '(x: any) => number'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(91,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '(x: T) => T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(92,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type '(x: T) => T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(99,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'E2'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(100,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'E2'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(110,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'typeof f'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(111,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'typeof f'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(121,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'typeof c'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(122,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'typeof c'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(128,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(129,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(15,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(21,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(22,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: string'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(28,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: boolean'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(29,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: boolean'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(35,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: Date'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(36,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: Date'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(42,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: RegExp'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(43,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: RegExp'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(49,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: { bar: number; }'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(50,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: { bar: number; }'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(56,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: number[]'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(57,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: number[]'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(63,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: I8'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(64,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: I8'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(70,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: A'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(71,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: A'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(77,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: A2'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(78,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: A2'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(84,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: (x: any) => number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(85,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: (x: any) => number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(91,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: (x: T) => T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(92,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: (x: T) => T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(99,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: E2'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(100,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: E2'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(110,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: typeof f'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(111,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: typeof f'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(121,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: typeof c'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(122,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: typeof c'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(128,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: T'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(129,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: T'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts (31 errors) ==== @@ -48,7 +48,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty // S is union type and each constituent type of S is a subtype of T foo: string | number; // error string is not subtype of number ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'number'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: number'. foo2: e | number; // ok e and number both subtype of number } @@ -56,10 +56,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: string; foo: string | number; // error numer is not subtype of string ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'string'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: string'. foo2: e | number; // error e and number both not subtype of string ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'string'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: string'. } // error cases @@ -67,10 +67,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: boolean; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'boolean'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: boolean'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'boolean'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: boolean'. } @@ -78,10 +78,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: Date; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'Date'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: Date'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'Date'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: Date'. } @@ -89,10 +89,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: RegExp; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'RegExp'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: RegExp'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'RegExp'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: RegExp'. } @@ -100,10 +100,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: { bar: number }; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '{ bar: number; }'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: { bar: number; }'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type '{ bar: number; }'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: { bar: number; }'. } @@ -111,10 +111,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: number[]; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'number[]'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: number[]'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'number[]'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: number[]'. } @@ -122,10 +122,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: I8; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'I8'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: I8'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'I8'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: I8'. } class A { foo: number; } @@ -133,10 +133,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: A; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'A'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: A'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'A'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: A'. } class A2 { foo: T; } @@ -144,10 +144,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: A2; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'A2'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: A2'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'A2'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: A2'. } @@ -155,10 +155,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: (x) => number; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '(x: any) => number'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: (x: any) => number'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type '(x: any) => number'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: (x: any) => number'. } @@ -166,10 +166,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: (x: T) => T; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '(x: T) => T'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: (x: T) => T'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type '(x: T) => T'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: (x: T) => T'. } @@ -178,10 +178,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: E2; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'E2'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: E2'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'E2'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: E2'. } @@ -193,10 +193,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: typeof f; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'typeof f'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: typeof f'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'typeof f'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: typeof f'. } @@ -208,10 +208,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: typeof c; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'typeof c'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: typeof c'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'typeof c'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: typeof c'. } @@ -219,10 +219,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty [x: string]: T; foo: string | number; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index '[string]: T'. foo2: e | number; ~~~~~~~~~~~~~~~~~ -!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'T'. +!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index '[string]: T'. } interface I19 { diff --git a/tests/baselines/reference/widenedTypes.errors.txt b/tests/baselines/reference/widenedTypes.errors.txt index 2277ef6eea75a..fa6d90513d859 100644 --- a/tests/baselines/reference/widenedTypes.errors.txt +++ b/tests/baselines/reference/widenedTypes.errors.txt @@ -7,7 +7,7 @@ tests/cases/compiler/widenedTypes.ts(18,1): error TS2322: Type 'string' is not a tests/cases/compiler/widenedTypes.ts(23,5): error TS2322: Type 'number[]' is not assignable to type 'string[]'. Type 'number' is not assignable to type 'string'. tests/cases/compiler/widenedTypes.ts(24,5): error TS2322: Type '{ [x: string]: number; x: number; y: null; }' is not assignable to type '{ [x: string]: string; }'. - Index signatures are incompatible. + Index signatures '[string]: number' and '[string]: string' are incompatible. Type 'number' is not assignable to type 'string'. @@ -53,5 +53,5 @@ tests/cases/compiler/widenedTypes.ts(24,5): error TS2322: Type '{ [x: string]: n var obj: { [x: string]: string; } = { x: 3, y: null }; // assignable because null is widened, and therefore BCT is any ~~~ !!! error TS2322: Type '{ [x: string]: number; x: number; y: null; }' is not assignable to type '{ [x: string]: string; }'. -!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Index signatures '[string]: number' and '[string]: string' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/cases/compiler/indexSignatureTypeCheck.ts b/tests/cases/compiler/indexSignatureTypeCheck.ts index fba7afb049639..28cbc93e48f51 100644 --- a/tests/cases/compiler/indexSignatureTypeCheck.ts +++ b/tests/cases/compiler/indexSignatureTypeCheck.ts @@ -1,18 +1,120 @@ interface IPropertySet { - [index: string]: any; - } - var ps: IPropertySet = null; var index: any = "hello"; ps[index] = 12; +enum Values { + a = 1, + b = 2 +} + +type Values2 = Values; +type Values3 = number; + +interface EnumMap { + [index: Values]: Values; +} + +interface EnumMap2 { + [index: Values2]: Values2; +} +interface NumberMap { + [index: Values3]: Values3; +} + +var pe: Values = null; + +pe[1] = null +pe[3] = null +pe[Values.b] = 5 + +pe[true] = null interface indexErrors { [p2?: string]; [...p3: any[]]; [p4: string, p5?: string]; [p6: string, ...p7: any[]]; -} \ No newline at end of file +} + +enum E { + A, B, C +} + +enum E2 { + A, B, C +} + +enum F { + H, I, J +} + +interface DuplicateAccess { + [index: Values]: Values; + [index: Values2]: Values2; +} + +interface DuplicateAccess2 { + [index: number]: Values; + [index: Values3]: Values3; +} + +var x: { [x: string]: string } +var xn: {[x: string]: number } +var y: { [x: number]: string } +var yn: { [x: number]: number } +var z: { [x: E]: number } + +x = x; +x = y; +x = z; + +y = x; +y = y; +y = z; + +z = x; // error +z = y; // error +z = z; +z = yn; // should error? + // var x: E = 5; // allowed to a assign a wider type (number) to an enum value (number.subset) +z = xn; +yn = z; + +type foo = string +var s: { [x: foo]: string } +var ss: { [x: string]: string } +var sn: { [x: number]: string } + +s = ss; +ss = s; + +sn = s; +s = sn; + +enum setOf_number1 { a, b, c } +enum setOf_number2 { d, e, f } + +type setOf_numbers = setOf_number1 | setOf_number2; + +var ssubset: { [x: setOf_numbers ]: string } + +/* + Subset types +type stringSet = "a" | "b" | "c"; +type numberSet = 1 | 2 | 3; + +// Union must flatten subset types into number.subset & string.subset +type mixedSet = stringSubset | numberSet | "d"; + +enum stringSubset { [x: stringSet]: string } +enum numberSubset { [x: numberSet]: string } + +// Special case, mixedSet creates numberIndex = [x: numberSubset] +// stringIndex = [x: stringSubset | "d"] +enum mixedSubset { [x: mixedSet]: string } + +*/ \ No newline at end of file