diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b198b827d0c2f..50ea133eb670c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3987,6 +3987,19 @@ namespace ts { return getIndexTypeOfStructuredType(getApparentType(type), kind); } + function getImplicitIndexTypeOfType(type: Type, kind: IndexKind): Type { + if (isObjectLiteralType(type)) { + const propTypes: Type[] = []; + for (const prop of getPropertiesOfType(type)) { + if (kind === IndexKind.String || isNumericLiteralName(prop.name)) { + propTypes.push(getTypeOfSymbol(prop)); + } + } + return getUnionType(propTypes); + } + return undefined; + } + function getTypeParametersFromJSDocTemplate(declaration: SignatureDeclaration): TypeParameter[] { if (declaration.flags & NodeFlags.JavaScriptFile) { const templateTag = getJSDocTemplateTag(declaration); @@ -5747,9 +5760,9 @@ namespace ts { if (result) { result &= signaturesRelatedTo(source, target, SignatureKind.Construct, reportErrors); if (result) { - result &= stringIndexTypesRelatedTo(source, originalSource, target, reportErrors); + result &= indexTypesRelatedTo(source, originalSource, target, IndexKind.String, reportErrors); if (result) { - result &= numberIndexTypesRelatedTo(source, originalSource, target, reportErrors); + result &= indexTypesRelatedTo(source, originalSource, target, IndexKind.Number, reportErrors); } } } @@ -5951,76 +5964,65 @@ namespace ts { return result; } - function stringIndexTypesRelatedTo(source: Type, originalSource: Type, target: Type, reportErrors: boolean): Ternary { - if (relation === identityRelation) { - return indexTypesIdenticalTo(IndexKind.String, source, target); - } - const targetInfo = getIndexInfoOfType(target, IndexKind.String); - if (targetInfo) { - if ((targetInfo.type.flags & TypeFlags.Any) && !(originalSource.flags & TypeFlags.Primitive)) { - // non-primitive assignment to any is always allowed, eg - // `var x: { [index: string]: any } = { property: 12 };` - return Ternary.True; - } - const sourceInfo = getIndexInfoOfType(source, IndexKind.String); - if (!sourceInfo) { - if (reportErrors) { - reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return Ternary.False; - } - const related = isRelatedTo(sourceInfo.type, targetInfo.type, reportErrors); - if (!related) { - if (reportErrors) { - reportError(Diagnostics.Index_signatures_are_incompatible); + function eachPropertyRelatedTo(source: Type, target: Type, kind: IndexKind, reportErrors: boolean): Ternary { + let result = Ternary.True; + for (const prop of getPropertiesOfObjectType(source)) { + if (kind === IndexKind.String || isNumericLiteralName(prop.name)) { + const related = isRelatedTo(getTypeOfSymbol(prop), target, reportErrors); + if (!related) { + if (reportErrors) { + reportError(Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); + } + return Ternary.False; } - return Ternary.False; + result &= related; } - return related; } - return Ternary.True; + return result; } - function numberIndexTypesRelatedTo(source: Type, originalSource: Type, target: Type, reportErrors: boolean): Ternary { + function indexInfoRelatedTo(sourceInfo: IndexInfo, targetInfo: IndexInfo, reportErrors: boolean) { + const related = isRelatedTo(sourceInfo.type, targetInfo.type, reportErrors); + if (!related && reportErrors) { + reportError(Diagnostics.Index_signatures_are_incompatible); + } + return related; + } + + function indexTypesRelatedTo(source: Type, originalSource: Type, target: Type, kind: IndexKind, reportErrors: boolean) { if (relation === identityRelation) { - return indexTypesIdenticalTo(IndexKind.Number, source, target); - } - const targetInfo = getIndexInfoOfType(target, IndexKind.Number); - if (targetInfo) { - if ((targetInfo.type.flags & TypeFlags.Any) && !(originalSource.flags & TypeFlags.Primitive)) { - // non-primitive assignment to any is always allowed, eg - // `var x: { [index: number]: any } = { property: 12 };` - return Ternary.True; - } - const sourceStringInfo = getIndexInfoOfType(source, IndexKind.String); - const sourceNumberInfo = getIndexInfoOfType(source, IndexKind.Number); - if (!(sourceStringInfo || sourceNumberInfo)) { - if (reportErrors) { - reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + return indexTypesIdenticalTo(source, target, kind); + } + const targetInfo = getIndexInfoOfType(target, kind); + if (!targetInfo || ((targetInfo.type.flags & TypeFlags.Any) && !(originalSource.flags & TypeFlags.Primitive))) { + // Index signature of type any permits assignment from everything but primitives + return Ternary.True; + } + const sourceInfo = getIndexInfoOfType(source, kind) || + kind === IndexKind.Number && getIndexInfoOfType(source, IndexKind.String); + if (sourceInfo) { + return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); + } + if (isObjectLiteralType(source)) { + let related = Ternary.True; + if (kind === IndexKind.String) { + const sourceNumberInfo = getIndexInfoOfType(source, IndexKind.Number); + if (sourceNumberInfo) { + related = indexInfoRelatedTo(sourceNumberInfo, targetInfo, reportErrors); } - return Ternary.False; } - let related: Ternary; - if (sourceStringInfo && sourceNumberInfo) { - // If we know for sure we're testing both string and numeric index types then only report errors from the second one - related = isRelatedTo(sourceStringInfo.type, targetInfo.type, /*reportErrors*/ false) || - isRelatedTo(sourceNumberInfo.type, targetInfo.type, reportErrors); - } - else { - related = isRelatedTo((sourceStringInfo || sourceNumberInfo).type, targetInfo.type, reportErrors); - } - if (!related) { - if (reportErrors) { - reportError(Diagnostics.Index_signatures_are_incompatible); - } - return Ternary.False; + if (related) { + related &= eachPropertyRelatedTo(source, targetInfo.type, kind, reportErrors); } return related; } - return Ternary.True; + if (reportErrors) { + reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + } + return Ternary.False; } - function indexTypesIdenticalTo(indexKind: IndexKind, source: Type, target: Type): Ternary { + function indexTypesIdenticalTo(source: Type, target: Type, indexKind: IndexKind): Ternary { const targetInfo = getIndexInfoOfType(target, indexKind); const sourceInfo = getIndexInfoOfType(source, indexKind); if (!sourceInfo && !targetInfo) { @@ -6263,6 +6265,16 @@ namespace ts { return !!(type.flags & TypeFlags.Tuple); } + /** + * Return true if type was inferred from an object literal or written as an object type literal + * with no call or construct signatures. + */ + function isObjectLiteralType(type: Type) { + return type.symbol && (type.symbol.flags & (SymbolFlags.ObjectLiteral | SymbolFlags.TypeLiteral)) !== 0 && + getSignaturesOfType(type, SignatureKind.Call).length === 0 && + getSignaturesOfType(type, SignatureKind.Construct).length === 0; + } + function getRegularTypeOfObjectLiteral(type: Type): Type { if (type.flags & TypeFlags.FreshObjectLiteral) { let regularType = (type).regularType; @@ -6610,9 +6622,7 @@ namespace ts { inferFromProperties(source, target); inferFromSignatures(source, target, SignatureKind.Call); inferFromSignatures(source, target, SignatureKind.Construct); - inferFromIndexTypes(source, target, IndexKind.String, IndexKind.String); - inferFromIndexTypes(source, target, IndexKind.Number, IndexKind.Number); - inferFromIndexTypes(source, target, IndexKind.String, IndexKind.Number); + inferFromIndexTypes(source, target); depth--; } } @@ -6644,12 +6654,22 @@ namespace ts { inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } - function inferFromIndexTypes(source: Type, target: Type, sourceKind: IndexKind, targetKind: IndexKind) { - const targetIndexType = getIndexTypeOfType(target, targetKind); - if (targetIndexType) { - const sourceIndexType = getIndexTypeOfType(source, sourceKind); + function inferFromIndexTypes(source: Type, target: Type) { + const targetStringIndexType = getIndexTypeOfType(target, IndexKind.String); + if (targetStringIndexType) { + const sourceIndexType = getIndexTypeOfType(source, IndexKind.String) || + getImplicitIndexTypeOfType(source, IndexKind.String); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetIndexType); + inferFromTypes(sourceIndexType, targetStringIndexType); + } + } + const targetNumberIndexType = getIndexTypeOfType(target, IndexKind.Number); + if (targetNumberIndexType) { + const sourceIndexType = getIndexTypeOfType(source, IndexKind.Number) || + getIndexTypeOfType(source, IndexKind.String) || + getImplicitIndexTypeOfType(source, IndexKind.Number); + if (sourceIndexType) { + inferFromTypes(sourceIndexType, targetNumberIndexType); } } } @@ -7824,11 +7844,6 @@ namespace ts { return !!(type.flags & TypeFlags.Union ? forEach((type).types, isTupleLikeType) : isTupleLikeType(type)); } - // 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 => getIndexInfoOfStructuredType(t, kind)) : getIndexInfoOfStructuredType(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 // exists. Otherwise, it is the type of the string index signature in T, if one exists. @@ -8224,6 +8239,17 @@ namespace ts { return links.resolvedType; } + function getObjectLiteralIndexInfo(node: ObjectLiteralExpression, properties: Symbol[], kind: IndexKind): IndexInfo { + const propTypes: Type[] = []; + for (let i = 0; i < properties.length; i++) { + if (kind === IndexKind.String || isNumericName(node.properties[i].name)) { + propTypes.push(getTypeOfSymbol(properties[i])); + } + } + const unionType = propTypes.length ? getUnionType(propTypes) : undefinedType; + return createIndexInfo(unionType, /*isReadonly*/ false); + } + function checkObjectLiteral(node: ObjectLiteralExpression, contextualMapper?: TypeMapper): Type { const inDestructuringPattern = isAssignmentTarget(node); // Grammar checking @@ -8235,8 +8261,10 @@ namespace ts { const contextualTypeHasPattern = contextualType && contextualType.pattern && (contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern || contextualType.pattern.kind === SyntaxKind.ObjectLiteralExpression); let typeFlags: TypeFlags = 0; - let patternWithComputedProperties = false; + let hasComputedStringProperty = false; + let hasComputedNumberProperty = false; + for (const memberDecl of node.properties) { let member = memberDecl.symbol; if (memberDecl.kind === SyntaxKind.PropertyAssignment || @@ -8300,7 +8328,15 @@ namespace ts { checkAccessorDeclaration(memberDecl); } - if (!hasDynamicName(memberDecl)) { + if (hasDynamicName(memberDecl)) { + if (isNumericName(memberDecl.name)) { + hasComputedNumberProperty = true; + } + else { + hasComputedStringProperty = true; + } + } + else { propertiesTable[member.name] = member; } propertiesArray.push(member); @@ -8321,8 +8357,8 @@ namespace ts { } } - const stringIndexInfo = getIndexInfo(IndexKind.String); - const numberIndexInfo = getIndexInfo(IndexKind.Number); + const stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, IndexKind.String) : undefined; + const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, IndexKind.Number) : undefined; const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshObjectLiteral; result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags) | (patternWithComputedProperties ? TypeFlags.ObjectLiteralPatternWithComputedProperties : 0); @@ -8330,29 +8366,6 @@ namespace ts { result.pattern = node; } return result; - - function getIndexInfo(kind: IndexKind) { - if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { - const propTypes: Type[] = []; - for (let i = 0; i < propertiesArray.length; i++) { - const propertyDecl = node.properties[i]; - if (kind === IndexKind.String || isNumericName(propertyDecl.name)) { - // Do not call getSymbolOfNode(propertyDecl), as that will get the - // original symbol for the node. We actually want to get the symbol - // created by checkObjectLiteral, since that will be appropriately - // contextually typed and resolved. - const type = getTypeOfSymbol(propertiesArray[i]); - if (!contains(propTypes, type)) { - propTypes.push(type); - } - } - } - const unionType = propTypes.length ? getUnionType(propTypes) : undefinedType; - typeFlags |= unionType.flags; - return createIndexInfo(unionType, /*isReadonly*/ false); - } - return undefined; - } } function checkJsxSelfClosingElement(node: JsxSelfClosingElement) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 5b93f61bb9042..2458e68f23c5c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1699,6 +1699,10 @@ "category": "Error", "code": 2529 }, + "Property '{0}' is incompatible with index signature.": { + "category": "Error", + "code": 2530 + }, "JSX element attributes type '{0}' may not be a union type.": { "category": "Error", "code": 2600 diff --git a/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.errors.txt b/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.errors.txt index eb5020e97f97e..e99cac7968cf8 100644 --- a/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.errors.txt +++ b/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.errors.txt @@ -1,10 +1,8 @@ -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 '{}'. 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'. -==== tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts (2 errors) ==== +==== tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts (1 errors) ==== interface Foo { a } interface Bar { b } @@ -20,9 +18,6 @@ tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignatur var f = () => { }; var v1: { - ~~ -!!! error TS2322: Type '{}' is not assignable to type '{ [n: number]: Foo; }'. -!!! error TS2322: Index signature is missing in type '{}'. [n: number]: Foo } = o; // Should be allowed diff --git a/tests/baselines/reference/badOverloadError.types b/tests/baselines/reference/badOverloadError.types index b8ae583a73cb8..198582af2db9e 100644 --- a/tests/baselines/reference/badOverloadError.types +++ b/tests/baselines/reference/badOverloadError.types @@ -6,6 +6,6 @@ function method() { >dictionary : { [index: string]: string; } ><{ [index: string]: string; }>{} : { [index: string]: string; } >index : string ->{} : { [x: string]: undefined; } +>{} : {} } diff --git a/tests/baselines/reference/bestCommonTypeWithContextualTyping.types b/tests/baselines/reference/bestCommonTypeWithContextualTyping.types index 628fe82012a8e..5baca43b75252 100644 --- a/tests/baselines/reference/bestCommonTypeWithContextualTyping.types +++ b/tests/baselines/reference/bestCommonTypeWithContextualTyping.types @@ -36,7 +36,7 @@ var obj: { [s: string]: Contextual } = { s: e }; // { s: Ellement; [s: string]: >obj : { [s: string]: Contextual; } >s : string >Contextual : Contextual ->{ s: e } : { [x: string]: Ellement; s: Ellement; } +>{ s: e } : { s: Ellement; } >s : Ellement >e : Ellement diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.errors.txt b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.errors.txt index fe608b143799c..2efaf2e5ae2f7 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.errors.txt +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.errors.txt @@ -1,70 +1,54 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(26,12): error TS2365: Operator '<' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(27,12): error TS2365: Operator '<' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(28,12): error TS2365: Operator '<' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(29,12): error TS2365: Operator '<' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(31,12): error TS2365: Operator '<' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(32,12): error TS2365: Operator '<' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(33,12): error TS2365: Operator '<' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(34,12): error TS2365: Operator '<' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(37,12): error TS2365: Operator '>' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(38,12): error TS2365: Operator '>' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(39,12): error TS2365: Operator '>' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(40,12): error TS2365: Operator '>' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(42,12): error TS2365: Operator '>' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(43,12): error TS2365: Operator '>' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(44,12): error TS2365: Operator '>' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(45,12): error TS2365: Operator '>' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(48,12): error TS2365: Operator '<=' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(49,12): error TS2365: Operator '<=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(50,12): error TS2365: Operator '<=' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(51,12): error TS2365: Operator '<=' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(53,12): error TS2365: Operator '<=' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(54,12): error TS2365: Operator '<=' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(55,12): error TS2365: Operator '<=' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(56,12): error TS2365: Operator '<=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(59,12): error TS2365: Operator '>=' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(60,12): error TS2365: Operator '>=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(61,12): error TS2365: Operator '>=' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(62,12): error TS2365: Operator '>=' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(64,12): error TS2365: Operator '>=' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(65,12): error TS2365: Operator '>=' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(66,12): error TS2365: Operator '>=' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(67,12): error TS2365: Operator '>=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(70,12): error TS2365: Operator '==' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(71,12): error TS2365: Operator '==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(72,12): error TS2365: Operator '==' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(73,12): error TS2365: Operator '==' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(75,12): error TS2365: Operator '==' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(76,12): error TS2365: Operator '==' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(77,12): error TS2365: Operator '==' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(78,12): error TS2365: Operator '==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(81,12): error TS2365: Operator '!=' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(82,12): error TS2365: Operator '!=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(83,12): error TS2365: Operator '!=' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(84,12): error TS2365: Operator '!=' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(86,12): error TS2365: Operator '!=' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(87,12): error TS2365: Operator '!=' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(88,12): error TS2365: Operator '!=' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(89,12): error TS2365: Operator '!=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(92,12): error TS2365: Operator '===' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(93,12): error TS2365: Operator '===' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(94,12): error TS2365: Operator '===' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(95,12): error TS2365: Operator '===' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(97,12): error TS2365: Operator '===' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(98,12): error TS2365: Operator '===' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(99,12): error TS2365: Operator '===' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(100,12): error TS2365: Operator '===' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(103,12): error TS2365: Operator '!==' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(104,12): error TS2365: Operator '!==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(105,12): error TS2365: Operator '!==' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(106,12): error TS2365: Operator '!==' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(108,12): error TS2365: Operator '!==' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(109,12): error TS2365: Operator '!==' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(110,12): error TS2365: Operator '!==' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(111,12): error TS2365: Operator '!==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. -==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts (64 errors) ==== +==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts (48 errors) ==== class Base { public a: string; } @@ -100,8 +84,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~ !!! error TS2365: Operator '<' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. var r1a4 = a4 < b4; - ~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. var r1b1 = b1 < a1; ~~~~~~~ @@ -113,8 +95,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~ !!! error TS2365: Operator '<' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. var r1b4 = b4 < a4; - ~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. // operator > var r2a1 = a1 > b1; @@ -127,8 +107,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~ !!! error TS2365: Operator '>' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. var r2a4 = a4 > b4; - ~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. var r2b1 = b1 > a1; ~~~~~~~ @@ -140,8 +118,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~ !!! error TS2365: Operator '>' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. var r2b4 = b4 > a4; - ~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. // operator <= var r3a1 = a1 <= b1; @@ -154,8 +130,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~~ !!! error TS2365: Operator '<=' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. var r3a4 = a4 <= b4; - ~~~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. var r3b1 = b1 <= a1; ~~~~~~~~ @@ -167,8 +141,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~~ !!! error TS2365: Operator '<=' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. var r3b4 = b4 <= a4; - ~~~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. // operator >= var r4a1 = a1 >= b1; @@ -181,8 +153,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~~ !!! error TS2365: Operator '>=' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. var r4a4 = a4 >= b4; - ~~~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. var r4b1 = b1 >= a1; ~~~~~~~~ @@ -194,8 +164,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~~ !!! error TS2365: Operator '>=' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. var r4b4 = b4 >= a4; - ~~~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. // operator == var r5a1 = a1 == b1; @@ -208,8 +176,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~~ !!! error TS2365: Operator '==' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. var r5a4 = a4 == b4; - ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. var r5b1 = b1 == a1; ~~~~~~~~ @@ -221,8 +187,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~~ !!! error TS2365: Operator '==' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. var r5b4 = b4 == a4; - ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. // operator != var r6a1 = a1 != b1; @@ -235,8 +199,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~~ !!! error TS2365: Operator '!=' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. var r6a4 = a4 != b4; - ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. var r6b1 = b1 != a1; ~~~~~~~~ @@ -248,8 +210,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~~ !!! error TS2365: Operator '!=' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. var r6b4 = b4 != a4; - ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. // operator === var r7a1 = a1 === b1; @@ -262,8 +222,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~~~ !!! error TS2365: Operator '===' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. var r7a4 = a4 === b4; - ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. var r7b1 = b1 === a1; ~~~~~~~~~ @@ -275,8 +233,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~~~ !!! error TS2365: Operator '===' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. var r7b4 = b4 === a4; - ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. // operator !== var r8a1 = a1 !== b1; @@ -289,8 +245,6 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso ~~~~~~~~~ !!! error TS2365: Operator '!==' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. var r8a4 = a4 !== b4; - ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'. var r8b1 = b1 !== a1; ~~~~~~~~~ @@ -301,6 +255,4 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r8b3 = b3 !== a3; ~~~~~~~~~ !!! error TS2365: Operator '!==' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. - var r8b4 = b4 !== a4; - ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'. \ No newline at end of file + var r8b4 = b4 !== a4; \ No newline at end of file diff --git a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types index 92835611c6dcc..e40422450b44f 100644 --- a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types +++ b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types @@ -98,7 +98,7 @@ x2 += E.a; x2 += {}; >x2 += {} : string >x2 : string ->{} : { [x: number]: undefined; } +>{} : {} x2 += null; >x2 += null : string diff --git a/tests/baselines/reference/computedPropertyNames10_ES5.types b/tests/baselines/reference/computedPropertyNames10_ES5.types index 9dea9cfca9390..b9d999397abf1 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES5.types +++ b/tests/baselines/reference/computedPropertyNames10_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [0](): void; [""](): void; } ->{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [0](): void; [""](): void; } +>v : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } +>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } [s]() { }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames10_ES6.types b/tests/baselines/reference/computedPropertyNames10_ES6.types index d2faa13898076..1883febb39b79 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES6.types +++ b/tests/baselines/reference/computedPropertyNames10_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [0](): void; [""](): void; } ->{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [0](): void; [""](): void; } +>v : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } +>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } [s]() { }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames11_ES5.types b/tests/baselines/reference/computedPropertyNames11_ES5.types index ae626ec3cba28..e15b46cc6c174 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES5.types +++ b/tests/baselines/reference/computedPropertyNames11_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { readonly [0]: number; [""]: any; } ->{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { readonly [0]: number; [""]: any; } +>v : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } +>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } get [s]() { return 0; }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames11_ES6.types b/tests/baselines/reference/computedPropertyNames11_ES6.types index 06dc26e984305..eb5fc105a7a82 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES6.types +++ b/tests/baselines/reference/computedPropertyNames11_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { readonly [0]: number; [""]: any; } ->{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { readonly [0]: number; [""]: any; } +>v : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } +>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } get [s]() { return 0; }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames18_ES5.types b/tests/baselines/reference/computedPropertyNames18_ES5.types index c60ab32d3f884..d6808a8edc001 100644 --- a/tests/baselines/reference/computedPropertyNames18_ES5.types +++ b/tests/baselines/reference/computedPropertyNames18_ES5.types @@ -3,8 +3,8 @@ function foo() { >foo : () => void var obj = { ->obj : {} ->{ [this.bar]: 0 } : {} +>obj : { [x: number]: number; } +>{ [this.bar]: 0 } : { [x: number]: number; } [this.bar]: 0 >this.bar : any diff --git a/tests/baselines/reference/computedPropertyNames18_ES6.types b/tests/baselines/reference/computedPropertyNames18_ES6.types index 33a15b6c5a9e4..11d58e48c6920 100644 --- a/tests/baselines/reference/computedPropertyNames18_ES6.types +++ b/tests/baselines/reference/computedPropertyNames18_ES6.types @@ -3,8 +3,8 @@ function foo() { >foo : () => void var obj = { ->obj : {} ->{ [this.bar]: 0 } : {} +>obj : { [x: number]: number; } +>{ [this.bar]: 0 } : { [x: number]: number; } [this.bar]: 0 >this.bar : any diff --git a/tests/baselines/reference/computedPropertyNames1_ES5.types b/tests/baselines/reference/computedPropertyNames1_ES5.types index 6c94c846f30a4..bcff3b34177f7 100644 --- a/tests/baselines/reference/computedPropertyNames1_ES5.types +++ b/tests/baselines/reference/computedPropertyNames1_ES5.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames1_ES5.ts === var v = { ->v : {} ->{ get [0 + 1]() { return 0 }, set [0 + 1](v: string) { } //No error} : {} +>v : { [x: number]: number | string; } +>{ get [0 + 1]() { return 0 }, set [0 + 1](v: string) { } //No error} : { [x: number]: number | string; } get [0 + 1]() { return 0 }, >0 + 1 : number diff --git a/tests/baselines/reference/computedPropertyNames1_ES6.types b/tests/baselines/reference/computedPropertyNames1_ES6.types index 95e5a011ea229..df2237a463f02 100644 --- a/tests/baselines/reference/computedPropertyNames1_ES6.types +++ b/tests/baselines/reference/computedPropertyNames1_ES6.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames1_ES6.ts === var v = { ->v : {} ->{ get [0 + 1]() { return 0 }, set [0 + 1](v: string) { } //No error} : {} +>v : { [x: number]: number | string; } +>{ get [0 + 1]() { return 0 }, set [0 + 1](v: string) { } //No error} : { [x: number]: number | string; } get [0 + 1]() { return 0 }, >0 + 1 : number diff --git a/tests/baselines/reference/computedPropertyNames20_ES5.types b/tests/baselines/reference/computedPropertyNames20_ES5.types index 91cc2c42963aa..65ee55be379fc 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES5.types +++ b/tests/baselines/reference/computedPropertyNames20_ES5.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames20_ES5.ts === var obj = { ->obj : {} ->{ [this.bar]: 0} : {} +>obj : { [x: number]: number; } +>{ [this.bar]: 0} : { [x: number]: number; } [this.bar]: 0 >this.bar : any diff --git a/tests/baselines/reference/computedPropertyNames20_ES6.types b/tests/baselines/reference/computedPropertyNames20_ES6.types index 4ef6f675cce6e..91e5c8d78433b 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES6.types +++ b/tests/baselines/reference/computedPropertyNames20_ES6.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames20_ES6.ts === var obj = { ->obj : {} ->{ [this.bar]: 0} : {} +>obj : { [x: number]: number; } +>{ [this.bar]: 0} : { [x: number]: number; } [this.bar]: 0 >this.bar : any diff --git a/tests/baselines/reference/computedPropertyNames22_ES5.types b/tests/baselines/reference/computedPropertyNames22_ES5.types index ca59250825c1d..eeec22d2e6129 100644 --- a/tests/baselines/reference/computedPropertyNames22_ES5.types +++ b/tests/baselines/reference/computedPropertyNames22_ES5.types @@ -6,8 +6,8 @@ class C { >bar : () => number var obj = { ->obj : {} ->{ [this.bar()]() { } } : {} +>obj : { [x: number]: () => void; } +>{ [this.bar()]() { } } : { [x: number]: () => void; } [this.bar()]() { } >this.bar() : number diff --git a/tests/baselines/reference/computedPropertyNames22_ES6.types b/tests/baselines/reference/computedPropertyNames22_ES6.types index d5fbce29f7ddd..af9ef9d3a317f 100644 --- a/tests/baselines/reference/computedPropertyNames22_ES6.types +++ b/tests/baselines/reference/computedPropertyNames22_ES6.types @@ -6,8 +6,8 @@ class C { >bar : () => number var obj = { ->obj : {} ->{ [this.bar()]() { } } : {} +>obj : { [x: number]: () => void; } +>{ [this.bar()]() { } } : { [x: number]: () => void; } [this.bar()]() { } >this.bar() : number diff --git a/tests/baselines/reference/computedPropertyNames25_ES5.types b/tests/baselines/reference/computedPropertyNames25_ES5.types index 6ca67cce4107b..f1acc296709a5 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES5.types +++ b/tests/baselines/reference/computedPropertyNames25_ES5.types @@ -17,8 +17,8 @@ class C extends Base { >foo : () => number var obj = { ->obj : {} ->{ [super.bar()]() { } } : {} +>obj : { [x: number]: () => void; } +>{ [super.bar()]() { } } : { [x: number]: () => void; } [super.bar()]() { } >super.bar() : number diff --git a/tests/baselines/reference/computedPropertyNames25_ES6.types b/tests/baselines/reference/computedPropertyNames25_ES6.types index 1c093ebc59f6f..26c3801390640 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES6.types +++ b/tests/baselines/reference/computedPropertyNames25_ES6.types @@ -17,8 +17,8 @@ class C extends Base { >foo : () => number var obj = { ->obj : {} ->{ [super.bar()]() { } } : {} +>obj : { [x: number]: () => void; } +>{ [super.bar()]() { } } : { [x: number]: () => void; } [super.bar()]() { } >super.bar() : number diff --git a/tests/baselines/reference/computedPropertyNames28_ES5.types b/tests/baselines/reference/computedPropertyNames28_ES5.types index 273dcd426d82f..89a2a7ac017e6 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES5.types +++ b/tests/baselines/reference/computedPropertyNames28_ES5.types @@ -12,8 +12,8 @@ class C extends Base { >super : typeof Base var obj = { ->obj : {} ->{ [(super(), "prop")]() { } } : {} +>obj : { [x: string]: () => void; } +>{ [(super(), "prop")]() { } } : { [x: string]: () => void; } [(super(), "prop")]() { } >(super(), "prop") : string diff --git a/tests/baselines/reference/computedPropertyNames28_ES6.types b/tests/baselines/reference/computedPropertyNames28_ES6.types index a34fb33f6c7d7..df020c9a5ff55 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES6.types +++ b/tests/baselines/reference/computedPropertyNames28_ES6.types @@ -12,8 +12,8 @@ class C extends Base { >super : typeof Base var obj = { ->obj : {} ->{ [(super(), "prop")]() { } } : {} +>obj : { [x: string]: () => void; } +>{ [(super(), "prop")]() { } } : { [x: string]: () => void; } [(super(), "prop")]() { } >(super(), "prop") : string diff --git a/tests/baselines/reference/computedPropertyNames29_ES5.types b/tests/baselines/reference/computedPropertyNames29_ES5.types index f3448f10857bf..d2f89ef6b18e8 100644 --- a/tests/baselines/reference/computedPropertyNames29_ES5.types +++ b/tests/baselines/reference/computedPropertyNames29_ES5.types @@ -9,8 +9,8 @@ class C { >() => { var obj = { [this.bar()]() { } // needs capture }; } : () => void var obj = { ->obj : {} ->{ [this.bar()]() { } // needs capture } : {} +>obj : { [x: number]: () => void; } +>{ [this.bar()]() { } // needs capture } : { [x: number]: () => void; } [this.bar()]() { } // needs capture >this.bar() : number diff --git a/tests/baselines/reference/computedPropertyNames29_ES6.types b/tests/baselines/reference/computedPropertyNames29_ES6.types index cd01d37556a3c..bb324b2b38250 100644 --- a/tests/baselines/reference/computedPropertyNames29_ES6.types +++ b/tests/baselines/reference/computedPropertyNames29_ES6.types @@ -9,8 +9,8 @@ class C { >() => { var obj = { [this.bar()]() { } // needs capture }; } : () => void var obj = { ->obj : {} ->{ [this.bar()]() { } // needs capture } : {} +>obj : { [x: number]: () => void; } +>{ [this.bar()]() { } // needs capture } : { [x: number]: () => void; } [this.bar()]() { } // needs capture >this.bar() : number diff --git a/tests/baselines/reference/computedPropertyNames31_ES5.types b/tests/baselines/reference/computedPropertyNames31_ES5.types index 6c0f2572a0680..832b2bc067a62 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES5.types +++ b/tests/baselines/reference/computedPropertyNames31_ES5.types @@ -20,8 +20,8 @@ class C extends Base { >() => { var obj = { [super.bar()]() { } // needs capture }; } : () => void var obj = { ->obj : {} ->{ [super.bar()]() { } // needs capture } : {} +>obj : { [x: number]: () => void; } +>{ [super.bar()]() { } // needs capture } : { [x: number]: () => void; } [super.bar()]() { } // needs capture >super.bar() : number diff --git a/tests/baselines/reference/computedPropertyNames31_ES6.types b/tests/baselines/reference/computedPropertyNames31_ES6.types index eaddc0368126f..4f59b1e8c6d34 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES6.types +++ b/tests/baselines/reference/computedPropertyNames31_ES6.types @@ -20,8 +20,8 @@ class C extends Base { >() => { var obj = { [super.bar()]() { } // needs capture }; } : () => void var obj = { ->obj : {} ->{ [super.bar()]() { } // needs capture } : {} +>obj : { [x: number]: () => void; } +>{ [super.bar()]() { } // needs capture } : { [x: number]: () => void; } [super.bar()]() { } // needs capture >super.bar() : number diff --git a/tests/baselines/reference/computedPropertyNames33_ES5.types b/tests/baselines/reference/computedPropertyNames33_ES5.types index f44ac3ca7695d..7031981481f62 100644 --- a/tests/baselines/reference/computedPropertyNames33_ES5.types +++ b/tests/baselines/reference/computedPropertyNames33_ES5.types @@ -12,8 +12,8 @@ class C { >bar : () => number var obj = { ->obj : {} ->{ [foo()]() { } } : {} +>obj : { [x: string]: () => void; } +>{ [foo()]() { } } : { [x: string]: () => void; } [foo()]() { } >foo() : string diff --git a/tests/baselines/reference/computedPropertyNames33_ES6.types b/tests/baselines/reference/computedPropertyNames33_ES6.types index 3081337c8bb3e..3c57daf2ace16 100644 --- a/tests/baselines/reference/computedPropertyNames33_ES6.types +++ b/tests/baselines/reference/computedPropertyNames33_ES6.types @@ -12,8 +12,8 @@ class C { >bar : () => number var obj = { ->obj : {} ->{ [foo()]() { } } : {} +>obj : { [x: string]: () => void; } +>{ [foo()]() { } } : { [x: string]: () => void; } [foo()]() { } >foo() : string diff --git a/tests/baselines/reference/computedPropertyNames46_ES5.types b/tests/baselines/reference/computedPropertyNames46_ES5.types index 394b22bd9042c..b8df0d56e1398 100644 --- a/tests/baselines/reference/computedPropertyNames46_ES5.types +++ b/tests/baselines/reference/computedPropertyNames46_ES5.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames46_ES5.ts === var o = { ->o : {} ->{ ["" || 0]: 0} : {} +>o : { [x: string]: number; } +>{ ["" || 0]: 0} : { [x: string]: number; } ["" || 0]: 0 >"" || 0 : string | number diff --git a/tests/baselines/reference/computedPropertyNames46_ES6.types b/tests/baselines/reference/computedPropertyNames46_ES6.types index 864fd81321d29..a786eca200c35 100644 --- a/tests/baselines/reference/computedPropertyNames46_ES6.types +++ b/tests/baselines/reference/computedPropertyNames46_ES6.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames46_ES6.ts === var o = { ->o : {} ->{ ["" || 0]: 0} : {} +>o : { [x: string]: number; } +>{ ["" || 0]: 0} : { [x: string]: number; } ["" || 0]: 0 >"" || 0 : string | number diff --git a/tests/baselines/reference/computedPropertyNames47_ES5.types b/tests/baselines/reference/computedPropertyNames47_ES5.types index 6aa841ffd62eb..cdc2c3301f66b 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES5.types +++ b/tests/baselines/reference/computedPropertyNames47_ES5.types @@ -8,8 +8,8 @@ enum E2 { x } >x : E2 var o = { ->o : {} ->{ [E1.x || E2.x]: 0} : {} +>o : { [x: number]: number; } +>{ [E1.x || E2.x]: 0} : { [x: number]: number; } [E1.x || E2.x]: 0 >E1.x || E2.x : E1 | E2 diff --git a/tests/baselines/reference/computedPropertyNames47_ES6.types b/tests/baselines/reference/computedPropertyNames47_ES6.types index f038b172ca173..a923e934d66d7 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES6.types +++ b/tests/baselines/reference/computedPropertyNames47_ES6.types @@ -8,8 +8,8 @@ enum E2 { x } >x : E2 var o = { ->o : {} ->{ [E1.x || E2.x]: 0} : {} +>o : { [x: number]: number; } +>{ [E1.x || E2.x]: 0} : { [x: number]: number; } [E1.x || E2.x]: 0 >E1.x || E2.x : E1 | E2 diff --git a/tests/baselines/reference/computedPropertyNames48_ES5.types b/tests/baselines/reference/computedPropertyNames48_ES5.types index 2b9131a11c8b0..12752d8abeb15 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES5.types +++ b/tests/baselines/reference/computedPropertyNames48_ES5.types @@ -39,9 +39,9 @@ extractIndexer({ }); // Should return string extractIndexer({ ->extractIndexer({ ["" || 0]: ""}) : any +>extractIndexer({ ["" || 0]: ""}) : string >extractIndexer : (p: { [n: number]: T; }) => T ->{ ["" || 0]: ""} : { [x: number]: undefined; } +>{ ["" || 0]: ""} : { [x: string]: string; } ["" || 0]: "" >"" || 0 : string | number diff --git a/tests/baselines/reference/computedPropertyNames48_ES6.types b/tests/baselines/reference/computedPropertyNames48_ES6.types index 2b803b19bd69b..832bc3c702557 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES6.types +++ b/tests/baselines/reference/computedPropertyNames48_ES6.types @@ -39,9 +39,9 @@ extractIndexer({ }); // Should return string extractIndexer({ ->extractIndexer({ ["" || 0]: ""}) : any +>extractIndexer({ ["" || 0]: ""}) : string >extractIndexer : (p: { [n: number]: T; }) => T ->{ ["" || 0]: ""} : { [x: number]: undefined; } +>{ ["" || 0]: ""} : { [x: string]: string; } ["" || 0]: "" >"" || 0 : string | number diff --git a/tests/baselines/reference/computedPropertyNames4_ES5.types b/tests/baselines/reference/computedPropertyNames4_ES5.types index 6984d2e69b8a4..3c5f884640fbe 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES5.types +++ b/tests/baselines/reference/computedPropertyNames4_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [0]: number; [""]: number; } ->{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [0]: number; [""]: number; } +>v : { [x: string]: number | string; [x: number]: number | string; [0]: number; [""]: number; } +>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: number | string; [x: number]: number | string; [0]: number; [""]: number; } [s]: 0, >s : string diff --git a/tests/baselines/reference/computedPropertyNames4_ES6.types b/tests/baselines/reference/computedPropertyNames4_ES6.types index 1fece561f5ae8..335c2415bd060 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES6.types +++ b/tests/baselines/reference/computedPropertyNames4_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [0]: number; [""]: number; } ->{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [0]: number; [""]: number; } +>v : { [x: string]: number | string; [x: number]: number | string; [0]: number; [""]: number; } +>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: number | string; [x: number]: number | string; [0]: number; [""]: number; } [s]: 0, >s : string diff --git a/tests/baselines/reference/computedPropertyNames7_ES5.types b/tests/baselines/reference/computedPropertyNames7_ES5.types index 8ebd4d75668b6..3411198b59070 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES5.types +++ b/tests/baselines/reference/computedPropertyNames7_ES5.types @@ -6,8 +6,8 @@ enum E { >member : E } var v = { ->v : {} ->{ [E.member]: 0} : {} +>v : { [x: number]: number; } +>{ [E.member]: 0} : { [x: number]: number; } [E.member]: 0 >E.member : E diff --git a/tests/baselines/reference/computedPropertyNames7_ES6.types b/tests/baselines/reference/computedPropertyNames7_ES6.types index 3a78b9c0ec6cd..eb72d546dbcd5 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES6.types +++ b/tests/baselines/reference/computedPropertyNames7_ES6.types @@ -6,8 +6,8 @@ enum E { >member : E } var v = { ->v : {} ->{ [E.member]: 0} : {} +>v : { [x: number]: number; } +>{ [E.member]: 0} : { [x: number]: number; } [E.member]: 0 >E.member : E diff --git a/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.types index bea7267d7d12d..09cad59462448 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.types @@ -14,7 +14,7 @@ interface I { var o: I = { >o : I >I : I ->{ ["" + 0](y) { return y.length; }, ["" + 1]: y => y.length} : { [x: string]: (y: string) => number; [x: number]: undefined; } +>{ ["" + 0](y) { return y.length; }, ["" + 1]: y => y.length} : { [x: string]: (y: string) => number; } ["" + 0](y) { return y.length; }, >"" + 0 : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType1_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType1_ES6.types index c8d0be6e833d2..d9e9970ebec6a 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType1_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType1_ES6.types @@ -14,7 +14,7 @@ interface I { var o: I = { >o : I >I : I ->{ ["" + 0](y) { return y.length; }, ["" + 1]: y => y.length} : { [x: string]: (y: string) => number; [x: number]: undefined; } +>{ ["" + 0](y) { return y.length; }, ["" + 1]: y => y.length} : { [x: string]: (y: string) => number; } ["" + 0](y) { return y.length; }, >"" + 0 : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.types index 52de216b803b1..5a5c48f253662 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.types @@ -14,7 +14,7 @@ interface I { var o: I = { >o : I >I : I ->{ [+"foo"](y) { return y.length; }, [+"bar"]: y => y.length} : { [x: string]: (y: string) => number; [x: number]: (y: string) => number; } +>{ [+"foo"](y) { return y.length; }, [+"bar"]: y => y.length} : { [x: number]: (y: string) => number; } [+"foo"](y) { return y.length; }, >+"foo" : number diff --git a/tests/baselines/reference/computedPropertyNamesContextualType2_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType2_ES6.types index cbbe0edc6a177..330351790ca04 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType2_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType2_ES6.types @@ -14,7 +14,7 @@ interface I { var o: I = { >o : I >I : I ->{ [+"foo"](y) { return y.length; }, [+"bar"]: y => y.length} : { [x: string]: (y: string) => number; [x: number]: (y: string) => number; } +>{ [+"foo"](y) { return y.length; }, [+"bar"]: y => y.length} : { [x: number]: (y: string) => number; } [+"foo"](y) { return y.length; }, >+"foo" : number diff --git a/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.types index 5f647fb4c1b70..faff27c9154ba 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.types @@ -10,7 +10,7 @@ interface I { var o: I = { >o : I >I : I ->{ [+"foo"](y) { return y.length; }, [+"bar"]: y => y.length} : { [x: string]: (y: string) => number; } +>{ [+"foo"](y) { return y.length; }, [+"bar"]: y => y.length} : { [x: number]: (y: string) => number; } [+"foo"](y) { return y.length; }, >+"foo" : number diff --git a/tests/baselines/reference/computedPropertyNamesContextualType3_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType3_ES6.types index e872df6f1b21c..18c3295794485 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType3_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType3_ES6.types @@ -10,7 +10,7 @@ interface I { var o: I = { >o : I >I : I ->{ [+"foo"](y) { return y.length; }, [+"bar"]: y => y.length} : { [x: string]: (y: string) => number; } +>{ [+"foo"](y) { return y.length; }, [+"bar"]: y => y.length} : { [x: number]: (y: string) => number; } [+"foo"](y) { return y.length; }, >+"foo" : number diff --git a/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.types index e5a57363ca060..6f75f1a363338 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.types @@ -12,7 +12,7 @@ interface I { var o: I = { >o : I >I : I ->{ [""+"foo"]: "", [""+"bar"]: 0} : { [x: string]: string | number; [x: number]: undefined; } +>{ [""+"foo"]: "", [""+"bar"]: 0} : { [x: string]: string | number; } [""+"foo"]: "", >""+"foo" : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType4_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType4_ES6.types index bdfa569752bab..9ee84176237af 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType4_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType4_ES6.types @@ -12,7 +12,7 @@ interface I { var o: I = { >o : I >I : I ->{ [""+"foo"]: "", [""+"bar"]: 0} : { [x: string]: string | number; [x: number]: undefined; } +>{ [""+"foo"]: "", [""+"bar"]: 0} : { [x: string]: string | number; } [""+"foo"]: "", >""+"foo" : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.types index e142fe937b998..38594f756ab61 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.types @@ -12,7 +12,7 @@ interface I { var o: I = { >o : I >I : I ->{ [+"foo"]: "", [+"bar"]: 0} : { [x: string]: string | number; [x: number]: string | number; } +>{ [+"foo"]: "", [+"bar"]: 0} : { [x: number]: string | number; } [+"foo"]: "", >+"foo" : number diff --git a/tests/baselines/reference/computedPropertyNamesContextualType5_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType5_ES6.types index 7b385b36770ec..a07b2e8cd95c1 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType5_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType5_ES6.types @@ -12,7 +12,7 @@ interface I { var o: I = { >o : I >I : I ->{ [+"foo"]: "", [+"bar"]: 0} : { [x: string]: string | number; [x: number]: string | number; } +>{ [+"foo"]: "", [+"bar"]: 0} : { [x: number]: string | number; } [+"foo"]: "", >+"foo" : number diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types index a3a393fba0cbd..b49724ccded92 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types @@ -19,7 +19,7 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | boolean | number | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; 0: () => void; p: string; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; [x: number]: (() => void) | number | number[]; 0: () => void; p: string; } p: "", >p : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types index 4abefe4484331..e88959d7cdc5f 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types @@ -19,7 +19,7 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | boolean | number | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; 0: () => void; p: string; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; [x: number]: (() => void) | number | number[]; 0: () => void; p: string; } p: "", >p : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types index ae1004c9819e6..083388ba975a1 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types @@ -19,7 +19,7 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: (() => void) | number | number[]; 0: () => void; p: string; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; [x: number]: (() => void) | number | number[]; 0: () => void; p: string; } p: "", >p : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types index e98e0fb8941d6..bc6ae72fb4fe7 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types @@ -19,7 +19,7 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: (() => void) | number | number[]; 0: () => void; p: string; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; [x: number]: (() => void) | number | number[]; 0: () => void; p: string; } p: "", >p : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt index 3376243e3707f..ee36609095a04 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt @@ -1,4 +1,4 @@ -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'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts(6,5): error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. Index signatures 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: string]: string | number; [x: number]: undefined; }' is not assignable to type 'I'. +!!! error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. !!! error TS2322: Type 'string' is not assignable to type 'boolean'. diff --git a/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt index e4540337ed4f0..1048fd2e119e7 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt @@ -1,4 +1,4 @@ -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'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES6.ts(6,5): error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. Index signatures 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: string]: string | number; [x: number]: undefined; }' is not assignable to type 'I'. +!!! error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. !!! error TS2322: Type 'string' is not assignable to type 'boolean'. diff --git a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.errors.txt index d4085a37e6053..e76b3a704dc6e 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.errors.txt @@ -1,4 +1,4 @@ -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'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType9_ES5.ts(6,5): error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. Index signatures 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: string]: string | number; [x: number]: string | number; }' is not assignable to type 'I'. +!!! error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. !!! error TS2322: Type 'string' is not assignable to type 'boolean'. diff --git a/tests/baselines/reference/computedPropertyNamesContextualType9_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType9_ES6.errors.txt index eca1360c26fff..468ad400c26cc 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType9_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType9_ES6.errors.txt @@ -1,4 +1,4 @@ -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'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType9_ES6.ts(6,5): error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. Index signatures 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: string]: string | number; [x: number]: string | number; }' is not assignable to type 'I'. +!!! error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. !!! error TS2322: Type 'string' is not assignable to type 'boolean'. diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js index e77eb79dc709e..f04ea61379d3e 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js @@ -26,4 +26,6 @@ var _a; //// [computedPropertyNamesDeclarationEmit5_ES5.d.ts] -declare var v: {}; +declare var v: { + [x: string]: any; +}; diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.types b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.types index 62faa5c2716a8..0653059b53598 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit5_ES5.ts === var v = { ->v : {} ->{ ["" + ""]: 0, ["" + ""]() { }, get ["" + ""]() { return 0; }, set ["" + ""](x) { }} : {} +>v : { [x: string]: any; } +>{ ["" + ""]: 0, ["" + ""]() { }, get ["" + ""]() { return 0; }, set ["" + ""](x) { }} : { [x: string]: any; } ["" + ""]: 0, >"" + "" : string diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES6.js b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES6.js index e19ac43656e56..de1f8c65d7f34 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES6.js +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES6.js @@ -16,4 +16,6 @@ var v = { //// [computedPropertyNamesDeclarationEmit5_ES6.d.ts] -declare var v: {}; +declare var v: { + [x: string]: any; +}; diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES6.types b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES6.types index 3eb313d268709..45d1e74f24a33 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES6.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit5_ES6.ts === var v = { ->v : {} ->{ ["" + ""]: 0, ["" + ""]() { }, get ["" + ""]() { return 0; }, set ["" + ""](x) { }} : {} +>v : { [x: string]: any; } +>{ ["" + ""]: 0, ["" + ""]() { }, get ["" + ""]() { return 0; }, set ["" + ""](x) { }} : { [x: string]: any; } ["" + ""]: 0, >"" + "" : string diff --git a/tests/baselines/reference/constEnumPropertyAccess1.types b/tests/baselines/reference/constEnumPropertyAccess1.types index 5ed2b932bd0da..f0e00fe771771 100644 --- a/tests/baselines/reference/constEnumPropertyAccess1.types +++ b/tests/baselines/reference/constEnumPropertyAccess1.types @@ -35,7 +35,7 @@ var o: { >idx : number } = { ->{ 1: true } : { [x: number]: boolean; 1: boolean; } +>{ 1: true } : { 1: boolean; } 1: true >true : boolean diff --git a/tests/baselines/reference/contextualTypeAny.errors.txt b/tests/baselines/reference/contextualTypeAny.errors.txt new file mode 100644 index 0000000000000..09970be986ddb --- /dev/null +++ b/tests/baselines/reference/contextualTypeAny.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/contextualTypeAny.ts(3,5): error TS2322: Type '{ p: string; q: any; }' is not assignable to type '{ [s: string]: number; }'. + Property 'p' is incompatible with index signature. + Type 'string' is not assignable to type 'number'. + + +==== tests/cases/compiler/contextualTypeAny.ts (1 errors) ==== + var x: any; + + var obj: { [s: string]: number } = { p: "", q: x }; + ~~~ +!!! error TS2322: Type '{ p: string; q: any; }' is not assignable to type '{ [s: string]: number; }'. +!!! error TS2322: Property 'p' is incompatible with index signature. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + + var arr: number[] = ["", x]; \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypeAny.symbols b/tests/baselines/reference/contextualTypeAny.symbols deleted file mode 100644 index 5132c948a2e27..0000000000000 --- a/tests/baselines/reference/contextualTypeAny.symbols +++ /dev/null @@ -1,15 +0,0 @@ -=== tests/cases/compiler/contextualTypeAny.ts === -var x: any; ->x : Symbol(x, Decl(contextualTypeAny.ts, 0, 3)) - -var obj: { [s: string]: number } = { p: "", q: x }; ->obj : Symbol(obj, Decl(contextualTypeAny.ts, 2, 3)) ->s : Symbol(s, Decl(contextualTypeAny.ts, 2, 12)) ->p : Symbol(p, Decl(contextualTypeAny.ts, 2, 36)) ->q : Symbol(q, Decl(contextualTypeAny.ts, 2, 43)) ->x : Symbol(x, Decl(contextualTypeAny.ts, 0, 3)) - -var arr: number[] = ["", x]; ->arr : Symbol(arr, Decl(contextualTypeAny.ts, 4, 3)) ->x : Symbol(x, Decl(contextualTypeAny.ts, 0, 3)) - diff --git a/tests/baselines/reference/contextualTypeAny.types b/tests/baselines/reference/contextualTypeAny.types deleted file mode 100644 index cace92d6567b8..0000000000000 --- a/tests/baselines/reference/contextualTypeAny.types +++ /dev/null @@ -1,19 +0,0 @@ -=== tests/cases/compiler/contextualTypeAny.ts === -var x: any; ->x : any - -var obj: { [s: string]: number } = { p: "", q: x }; ->obj : { [s: string]: number; } ->s : string ->{ p: "", q: x } : { [x: string]: any; p: string; q: any; } ->p : string ->"" : string ->q : any ->x : any - -var arr: number[] = ["", x]; ->arr : number[] ->["", x] : any[] ->"" : string ->x : any - diff --git a/tests/baselines/reference/contextualTypeArrayReturnType.types b/tests/baselines/reference/contextualTypeArrayReturnType.types index f270b33f568a3..6c91fd7b8b964 100644 --- a/tests/baselines/reference/contextualTypeArrayReturnType.types +++ b/tests/baselines/reference/contextualTypeArrayReturnType.types @@ -26,18 +26,18 @@ interface Transform3D { var style: IBookStyle = { >style : IBookStyle >IBookStyle : IBookStyle ->{ initialLeftPageTransforms: (width: number) => { return [ {'ry': null } ]; }} : { initialLeftPageTransforms: (width: number) => { [x: string]: any; 'ry': any; }[]; } +>{ initialLeftPageTransforms: (width: number) => { return [ {'ry': null } ]; }} : { initialLeftPageTransforms: (width: number) => { 'ry': any; }[]; } initialLeftPageTransforms: (width: number) => { ->initialLeftPageTransforms : (width: number) => { [x: string]: any; 'ry': any; }[] ->(width: number) => { return [ {'ry': null } ]; } : (width: number) => { [x: string]: any; 'ry': any; }[] +>initialLeftPageTransforms : (width: number) => { 'ry': any; }[] +>(width: number) => { return [ {'ry': null } ]; } : (width: number) => { 'ry': any; }[] >width : number return [ ->[ {'ry': null } ] : { [x: string]: null; 'ry': null; }[] +>[ {'ry': null } ] : { 'ry': null; }[] {'ry': null } ->{'ry': null } : { [x: string]: null; 'ry': null; } +>{'ry': null } : { 'ry': null; } >null : null ]; diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.types b/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.types index 2f24ad082274d..965e4d21d9998 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.types +++ b/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.types @@ -69,7 +69,7 @@ var x: IWithNoStringIndexSignature | IWithStringIndexSignature1 = { z: a => a }; >x : IWithNoStringIndexSignature | IWithStringIndexSignature1 >IWithNoStringIndexSignature : IWithNoStringIndexSignature >IWithStringIndexSignature1 : IWithStringIndexSignature1 ->{ z: a => a } : { [x: string]: (a: number) => number; z: (a: number) => number; } +>{ z: a => a } : { z: (a: number) => number; } >z : (a: number) => number >a => a : (a: number) => number >a : number @@ -79,7 +79,7 @@ var x: IWithNoStringIndexSignature | IWithStringIndexSignature1 = { foo: a => a >x : IWithNoStringIndexSignature | IWithStringIndexSignature1 >IWithNoStringIndexSignature : IWithNoStringIndexSignature >IWithStringIndexSignature1 : IWithStringIndexSignature1 ->{ foo: a => a } : { [x: string]: (a: any) => any; foo: (a: any) => any; } +>{ foo: a => a } : { foo: (a: any) => any; } >foo : (a: any) => any >a => a : (a: any) => any >a : any @@ -89,7 +89,7 @@ var x: IWithNoStringIndexSignature | IWithStringIndexSignature1 = { foo: "hello" >x : IWithNoStringIndexSignature | IWithStringIndexSignature1 >IWithNoStringIndexSignature : IWithNoStringIndexSignature >IWithStringIndexSignature1 : IWithStringIndexSignature1 ->{ foo: "hello" } : { [x: string]: string; foo: string; } +>{ foo: "hello" } : { foo: string; } >foo : string >"hello" : string @@ -97,7 +97,7 @@ var x2: IWithStringIndexSignature1 | IWithStringIndexSignature2 = { z: a => a.to >x2 : IWithStringIndexSignature1 | IWithStringIndexSignature2 >IWithStringIndexSignature1 : IWithStringIndexSignature1 >IWithStringIndexSignature2 : IWithStringIndexSignature2 ->{ z: a => a.toString() } : { [x: string]: (a: number) => string; z: (a: number) => string; } +>{ z: a => a.toString() } : { z: (a: number) => string; } >z : (a: number) => string >a => a.toString() : (a: number) => string >a : number @@ -110,7 +110,7 @@ var x2: IWithStringIndexSignature1 | IWithStringIndexSignature2 = { z: a => a }; >x2 : IWithStringIndexSignature1 | IWithStringIndexSignature2 >IWithStringIndexSignature1 : IWithStringIndexSignature1 >IWithStringIndexSignature2 : IWithStringIndexSignature2 ->{ z: a => a } : { [x: string]: (a: number) => number; z: (a: number) => number; } +>{ z: a => a } : { z: (a: number) => number; } >z : (a: number) => number >a => a : (a: number) => number >a : number @@ -124,7 +124,7 @@ var x3: IWithNoNumberIndexSignature | IWithNumberIndexSignature1 = { 1: a => a } >x3 : IWithNoNumberIndexSignature | IWithNumberIndexSignature1 >IWithNoNumberIndexSignature : IWithNoNumberIndexSignature >IWithNumberIndexSignature1 : IWithNumberIndexSignature1 ->{ 1: a => a } : { [x: number]: (a: number) => number; 1: (a: number) => number; } +>{ 1: a => a } : { 1: (a: number) => number; } >a => a : (a: number) => number >a : number >a : number @@ -133,7 +133,7 @@ var x3: IWithNoNumberIndexSignature | IWithNumberIndexSignature1 = { 0: a => a } >x3 : IWithNoNumberIndexSignature | IWithNumberIndexSignature1 >IWithNoNumberIndexSignature : IWithNoNumberIndexSignature >IWithNumberIndexSignature1 : IWithNumberIndexSignature1 ->{ 0: a => a } : { [x: number]: (a: any) => any; 0: (a: any) => any; } +>{ 0: a => a } : { 0: (a: any) => any; } >a => a : (a: any) => any >a : any >a : any @@ -142,14 +142,14 @@ var x3: IWithNoNumberIndexSignature | IWithNumberIndexSignature1 = { 0: "hello" >x3 : IWithNoNumberIndexSignature | IWithNumberIndexSignature1 >IWithNoNumberIndexSignature : IWithNoNumberIndexSignature >IWithNumberIndexSignature1 : IWithNumberIndexSignature1 ->{ 0: "hello" } : { [x: number]: string; 0: string; } +>{ 0: "hello" } : { 0: string; } >"hello" : string var x4: IWithNumberIndexSignature1 | IWithNumberIndexSignature2 = { 1: a => a.toString() }; // a should be number >x4 : IWithNumberIndexSignature1 | IWithNumberIndexSignature2 >IWithNumberIndexSignature1 : IWithNumberIndexSignature1 >IWithNumberIndexSignature2 : IWithNumberIndexSignature2 ->{ 1: a => a.toString() } : { [x: number]: (a: number) => string; 1: (a: number) => string; } +>{ 1: a => a.toString() } : { 1: (a: number) => string; } >a => a.toString() : (a: number) => string >a : number >a.toString() : string @@ -161,7 +161,7 @@ var x4: IWithNumberIndexSignature1 | IWithNumberIndexSignature2 = { 1: a => a }; >x4 : IWithNumberIndexSignature1 | IWithNumberIndexSignature2 >IWithNumberIndexSignature1 : IWithNumberIndexSignature1 >IWithNumberIndexSignature2 : IWithNumberIndexSignature2 ->{ 1: a => a } : { [x: number]: (a: number) => number; 1: (a: number) => number; } +>{ 1: a => a } : { 1: (a: number) => number; } >a => a : (a: number) => number >a : number >a : number diff --git a/tests/baselines/reference/contextualTypingOfObjectLiterals.errors.txt b/tests/baselines/reference/contextualTypingOfObjectLiterals.errors.txt deleted file mode 100644 index ac8063a4378fc..0000000000000 --- a/tests/baselines/reference/contextualTypingOfObjectLiterals.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -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; }'. -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; }'. - - -==== tests/cases/compiler/contextualTypingOfObjectLiterals.ts (2 errors) ==== - var obj1: { [x: string]: string; }; - var obj2 = {x: ""}; - obj1 = {}; // Ok - 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; }'. - - function f(x: { [s: string]: string }) { } - - f({}); // Ok - f(obj1); // Ok - 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 diff --git a/tests/baselines/reference/contextualTypingOfObjectLiterals.symbols b/tests/baselines/reference/contextualTypingOfObjectLiterals.symbols new file mode 100644 index 0000000000000..afa34cfe4818b --- /dev/null +++ b/tests/baselines/reference/contextualTypingOfObjectLiterals.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/contextualTypingOfObjectLiterals.ts === +var obj1: { [x: string]: string; }; +>obj1 : Symbol(obj1, Decl(contextualTypingOfObjectLiterals.ts, 0, 3)) +>x : Symbol(x, Decl(contextualTypingOfObjectLiterals.ts, 0, 13)) + +var obj2 = {x: ""}; +>obj2 : Symbol(obj2, Decl(contextualTypingOfObjectLiterals.ts, 1, 3)) +>x : Symbol(x, Decl(contextualTypingOfObjectLiterals.ts, 1, 12)) + +obj1 = {}; // Ok +>obj1 : Symbol(obj1, Decl(contextualTypingOfObjectLiterals.ts, 0, 3)) + +obj1 = obj2; // Error - indexer doesn't match +>obj1 : Symbol(obj1, Decl(contextualTypingOfObjectLiterals.ts, 0, 3)) +>obj2 : Symbol(obj2, Decl(contextualTypingOfObjectLiterals.ts, 1, 3)) + +function f(x: { [s: string]: string }) { } +>f : Symbol(f, Decl(contextualTypingOfObjectLiterals.ts, 3, 12)) +>x : Symbol(x, Decl(contextualTypingOfObjectLiterals.ts, 5, 11)) +>s : Symbol(s, Decl(contextualTypingOfObjectLiterals.ts, 5, 17)) + +f({}); // Ok +>f : Symbol(f, Decl(contextualTypingOfObjectLiterals.ts, 3, 12)) + +f(obj1); // Ok +>f : Symbol(f, Decl(contextualTypingOfObjectLiterals.ts, 3, 12)) +>obj1 : Symbol(obj1, Decl(contextualTypingOfObjectLiterals.ts, 0, 3)) + +f(obj2); // Error - indexer doesn't match +>f : Symbol(f, Decl(contextualTypingOfObjectLiterals.ts, 3, 12)) +>obj2 : Symbol(obj2, Decl(contextualTypingOfObjectLiterals.ts, 1, 3)) + diff --git a/tests/baselines/reference/contextualTypingOfObjectLiterals.types b/tests/baselines/reference/contextualTypingOfObjectLiterals.types new file mode 100644 index 0000000000000..a99fb2f39afe8 --- /dev/null +++ b/tests/baselines/reference/contextualTypingOfObjectLiterals.types @@ -0,0 +1,41 @@ +=== tests/cases/compiler/contextualTypingOfObjectLiterals.ts === +var obj1: { [x: string]: string; }; +>obj1 : { [x: string]: string; } +>x : string + +var obj2 = {x: ""}; +>obj2 : { x: string; } +>{x: ""} : { x: string; } +>x : string +>"" : string + +obj1 = {}; // Ok +>obj1 = {} : {} +>obj1 : { [x: string]: string; } +>{} : {} + +obj1 = obj2; // Error - indexer doesn't match +>obj1 = obj2 : { x: string; } +>obj1 : { [x: string]: string; } +>obj2 : { x: string; } + +function f(x: { [s: string]: string }) { } +>f : (x: { [s: string]: string; }) => void +>x : { [s: string]: string; } +>s : string + +f({}); // Ok +>f({}) : void +>f : (x: { [s: string]: string; }) => void +>{} : {} + +f(obj1); // Ok +>f(obj1) : void +>f : (x: { [s: string]: string; }) => void +>obj1 : { [x: string]: string; } + +f(obj2); // Error - indexer doesn't match +>f(obj2) : void +>f : (x: { [s: string]: string; }) => void +>obj2 : { x: string; } + diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 7c4671022ea4b..517eaafe4abbe 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -11,8 +11,8 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,13): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(67,9): error TS2461: Type '{ [x: number]: undefined; }' is not an array type. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(68,9): error TS2461: Type '{ [x: number]: number; 0: number; 1: number; }' is not an array type. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(67,9): error TS2461: Type '{}' is not an array type. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(68,9): error TS2461: Type '{ 0: number; 1: number; }' is not an array type. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,11): error TS2459: Type 'undefined[]' has no property 'a' and no string index signature. @@ -122,10 +122,10 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): function f9() { var [a, b] = {}; // Error, not array type ~~~~~~ -!!! error TS2461: Type '{ [x: number]: undefined; }' is not an array type. +!!! error TS2461: Type '{}' is not an array type. var [c, d] = { 0: 10, 1: 20 }; // Error, not array type ~~~~~~ -!!! error TS2461: Type '{ [x: number]: number; 0: number; 1: number; }' is not an array type. +!!! error TS2461: Type '{ 0: number; 1: number; }' is not an array type. var [e, f] = [10, 20]; } diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types index 476b5bee0cc5b..cb6052d93fd41 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types @@ -69,7 +69,7 @@ function foo(): F { >F : F return { ->{ 1: true } : { [x: number]: boolean; 1: boolean; } +>{ 1: true } : { 1: boolean; } 1: true >true : boolean @@ -82,7 +82,7 @@ function bar(): F { >F : F return { ->{ 2: true } : { [x: number]: boolean; 2: boolean; } +>{ 2: true } : { 2: boolean; } 2: true >true : boolean @@ -114,7 +114,7 @@ function foo1(): F1 { >F1 : F1 return { ->{ "prop1": 2 } : { [x: string]: number; "prop1": number; } +>{ "prop1": 2 } : { "prop1": number; } "prop1": 2 >2 : number diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types index 7a7f631eddfcf..2d77c20f65be8 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types @@ -69,7 +69,7 @@ function foo(): F { >F : F return { ->{ 1: true } : { [x: number]: boolean; 1: boolean; } +>{ 1: true } : { 1: boolean; } 1: true >true : boolean @@ -82,7 +82,7 @@ function bar(): F { >F : F return { ->{ 2: true } : { [x: number]: boolean; 2: boolean; } +>{ 2: true } : { 2: boolean; } 2: true >true : boolean @@ -114,7 +114,7 @@ function foo1(): F1 { >F1 : F1 return { ->{ "prop1": 2 } : { [x: string]: number; "prop1": number; } +>{ "prop1": 2 } : { "prop1": number; } "prop1": 2 >2 : number diff --git a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types index e1bfd195698d6..9825a75a220d6 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types @@ -26,7 +26,7 @@ var moduleMap: { [key: string]: IHasVisualizationModel } = { >moduleMap : { [key: string]: IHasVisualizationModel; } >key : string >IHasVisualizationModel : IHasVisualizationModel ->{ "moduleA": moduleA, "moduleB": moduleB} : { [x: string]: typeof moduleA; "moduleA": typeof moduleA; "moduleB": typeof moduleB; } +>{ "moduleA": moduleA, "moduleB": moduleB} : { "moduleA": typeof moduleA; "moduleB": typeof moduleB; } "moduleA": moduleA, >moduleA : typeof moduleA diff --git a/tests/baselines/reference/generatorTypeCheck41.types b/tests/baselines/reference/generatorTypeCheck41.types index 926aef95ce576..0bed082dc438d 100644 --- a/tests/baselines/reference/generatorTypeCheck41.types +++ b/tests/baselines/reference/generatorTypeCheck41.types @@ -3,8 +3,8 @@ function* g() { >g : () => IterableIterator let x = { ->x : {} ->{ [yield 0]: 0 } : {} +>x : { [x: number]: number; } +>{ [yield 0]: 0 } : { [x: number]: number; } [yield 0]: 0 >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck42.types b/tests/baselines/reference/generatorTypeCheck42.types index 855c4697f4099..7538b8f249985 100644 --- a/tests/baselines/reference/generatorTypeCheck42.types +++ b/tests/baselines/reference/generatorTypeCheck42.types @@ -3,8 +3,8 @@ function* g() { >g : () => IterableIterator let x = { ->x : {} ->{ [yield 0]() { } } : {} +>x : { [x: number]: () => void; } +>{ [yield 0]() { } } : { [x: number]: () => void; } [yield 0]() { >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck43.types b/tests/baselines/reference/generatorTypeCheck43.types index 50fc7e30c864a..a132dfcb01574 100644 --- a/tests/baselines/reference/generatorTypeCheck43.types +++ b/tests/baselines/reference/generatorTypeCheck43.types @@ -3,8 +3,8 @@ function* g() { >g : () => IterableIterator let x = { ->x : {} ->{ *[yield 0]() { } } : {} +>x : { [x: number]: () => IterableIterator; } +>{ *[yield 0]() { } } : { [x: number]: () => IterableIterator; } *[yield 0]() { >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck44.types b/tests/baselines/reference/generatorTypeCheck44.types index 2fc67f90556ba..5c432e41cbee2 100644 --- a/tests/baselines/reference/generatorTypeCheck44.types +++ b/tests/baselines/reference/generatorTypeCheck44.types @@ -3,8 +3,8 @@ function* g() { >g : () => IterableIterator let x = { ->x : {} ->{ get [yield 0]() { return 0; } } : {} +>x : { [x: number]: number; } +>{ get [yield 0]() { return 0; } } : { [x: number]: number; } get [yield 0]() { >yield 0 : any diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty2.types b/tests/baselines/reference/genericBaseClassLiteralProperty2.types index d7d512165f018..3e3208249256e 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty2.types +++ b/tests/baselines/reference/genericBaseClassLiteralProperty2.types @@ -14,11 +14,11 @@ class BaseCollection2 { constructor() { this._itemsByKey = {}; ->this._itemsByKey = {} : { [x: string]: undefined; } +>this._itemsByKey = {} : {} >this._itemsByKey : { [key: string]: TItem; } >this : this >_itemsByKey : { [key: string]: TItem; } ->{} : { [x: string]: undefined; } +>{} : {} } } diff --git a/tests/baselines/reference/genericCallWithTupleType.errors.txt b/tests/baselines/reference/genericCallWithTupleType.errors.txt index d03f8d5e68a31..bcf580320e53e 100644 --- a/tests/baselines/reference/genericCallWithTupleType.errors.txt +++ b/tests/baselines/reference/genericCallWithTupleType.errors.txt @@ -9,9 +9,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,1): error TS2322: Type '[number, string]' is not assignable to type '[string, number]'. Types of property '0' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,1): error TS2322: Type '[{ [x: number]: undefined; }, {}]' is not assignable to type '[string, number]'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,1): error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. Types of property '0' are incompatible. - Type '{ [x: number]: undefined; }' is not assignable to type 'string'. + Type '{}' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(24,1): error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. Property '1' is missing in type '[{}]'. @@ -55,9 +55,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup !!! error TS2322: Type 'number' is not assignable to type 'string'. i1.tuple1 = [{}, {}]; ~~~~~~~~~ -!!! error TS2322: Type '[{ [x: number]: undefined; }, {}]' is not assignable to type '[string, number]'. +!!! error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. !!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type '{ [x: number]: undefined; }' is not assignable to type 'string'. +!!! error TS2322: Type '{}' is not assignable to type 'string'. i2.tuple1 = [{}]; ~~~~~~~~~ !!! error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. diff --git a/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types b/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types index 337993dc2a69d..a316773e5c87f 100644 --- a/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types +++ b/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types @@ -8,7 +8,7 @@ class LazyArray { ><{ [objectId: string]: T; }>{} : { [objectId: string]: T; } >objectId : string >T : T ->{} : { [x: string]: undefined; } +>{} : {} array() { >array : () => { [objectId: string]: T; } diff --git a/tests/baselines/reference/implicitIndexSignatures.js b/tests/baselines/reference/implicitIndexSignatures.js new file mode 100644 index 0000000000000..6403f1f154345 --- /dev/null +++ b/tests/baselines/reference/implicitIndexSignatures.js @@ -0,0 +1,85 @@ +//// [implicitIndexSignatures.ts] +type StringMap = { [x: string]: string }; + +const empty1 = {}; +let empty2: {}; +const names1 = { a: "foo", b: "bar" }; +let names2: { a: string, b: string }; +let map: StringMap; +map = { x: "xxx", y: "yyy" }; +map = empty1; +map = empty2; +map = names1; +map = names2; + +declare function getStringIndexValue(map: { [x: string]: T }): T; +declare function getNumberIndexValue(map: { [x: number]: T }): T; + +function f1() { + const o1 = { a: 1, b: 2 }; + let o2: { a: number, b: number }; + const v1 = getStringIndexValue(o1); + const v2 = getStringIndexValue(o2); +} + +function f2() { + const o1 = { a: "1", b: "2" }; + let o2: { a: string, b: string }; + const v1 = getStringIndexValue(o1); + const v2 = getStringIndexValue(o2); +} + +function f3() { + const o1 = { a: 1, b: "2" }; + let o2: { a: number, b: string }; + const v1 = getStringIndexValue(o1); + const v2 = getStringIndexValue(o2); +} + +function f4() { + const o1 = { 0: "0", 1: "1", count: 2 }; + let o2: { 0: string, 1: string, count: number }; + const v1 = getStringIndexValue(o1); + const v2 = getStringIndexValue(o2); + const v3 = getNumberIndexValue(o1); + const v4 = getNumberIndexValue(o2); +} + + +//// [implicitIndexSignatures.js] +var empty1 = {}; +var empty2; +var names1 = { a: "foo", b: "bar" }; +var names2; +var map; +map = { x: "xxx", y: "yyy" }; +map = empty1; +map = empty2; +map = names1; +map = names2; +function f1() { + var o1 = { a: 1, b: 2 }; + var o2; + var v1 = getStringIndexValue(o1); + var v2 = getStringIndexValue(o2); +} +function f2() { + var o1 = { a: "1", b: "2" }; + var o2; + var v1 = getStringIndexValue(o1); + var v2 = getStringIndexValue(o2); +} +function f3() { + var o1 = { a: 1, b: "2" }; + var o2; + var v1 = getStringIndexValue(o1); + var v2 = getStringIndexValue(o2); +} +function f4() { + var o1 = { 0: "0", 1: "1", count: 2 }; + var o2; + var v1 = getStringIndexValue(o1); + var v2 = getStringIndexValue(o2); + var v3 = getNumberIndexValue(o1); + var v4 = getNumberIndexValue(o2); +} diff --git a/tests/baselines/reference/implicitIndexSignatures.symbols b/tests/baselines/reference/implicitIndexSignatures.symbols new file mode 100644 index 0000000000000..a014e7e942c2c --- /dev/null +++ b/tests/baselines/reference/implicitIndexSignatures.symbols @@ -0,0 +1,166 @@ +=== tests/cases/compiler/implicitIndexSignatures.ts === +type StringMap = { [x: string]: string }; +>StringMap : Symbol(StringMap, Decl(implicitIndexSignatures.ts, 0, 0)) +>x : Symbol(x, Decl(implicitIndexSignatures.ts, 0, 20)) + +const empty1 = {}; +>empty1 : Symbol(empty1, Decl(implicitIndexSignatures.ts, 2, 5)) + +let empty2: {}; +>empty2 : Symbol(empty2, Decl(implicitIndexSignatures.ts, 3, 3)) + +const names1 = { a: "foo", b: "bar" }; +>names1 : Symbol(names1, Decl(implicitIndexSignatures.ts, 4, 5)) +>a : Symbol(a, Decl(implicitIndexSignatures.ts, 4, 16)) +>b : Symbol(b, Decl(implicitIndexSignatures.ts, 4, 26)) + +let names2: { a: string, b: string }; +>names2 : Symbol(names2, Decl(implicitIndexSignatures.ts, 5, 3)) +>a : Symbol(a, Decl(implicitIndexSignatures.ts, 5, 13)) +>b : Symbol(b, Decl(implicitIndexSignatures.ts, 5, 24)) + +let map: StringMap; +>map : Symbol(map, Decl(implicitIndexSignatures.ts, 6, 3)) +>StringMap : Symbol(StringMap, Decl(implicitIndexSignatures.ts, 0, 0)) + +map = { x: "xxx", y: "yyy" }; +>map : Symbol(map, Decl(implicitIndexSignatures.ts, 6, 3)) +>x : Symbol(x, Decl(implicitIndexSignatures.ts, 7, 7)) +>y : Symbol(y, Decl(implicitIndexSignatures.ts, 7, 17)) + +map = empty1; +>map : Symbol(map, Decl(implicitIndexSignatures.ts, 6, 3)) +>empty1 : Symbol(empty1, Decl(implicitIndexSignatures.ts, 2, 5)) + +map = empty2; +>map : Symbol(map, Decl(implicitIndexSignatures.ts, 6, 3)) +>empty2 : Symbol(empty2, Decl(implicitIndexSignatures.ts, 3, 3)) + +map = names1; +>map : Symbol(map, Decl(implicitIndexSignatures.ts, 6, 3)) +>names1 : Symbol(names1, Decl(implicitIndexSignatures.ts, 4, 5)) + +map = names2; +>map : Symbol(map, Decl(implicitIndexSignatures.ts, 6, 3)) +>names2 : Symbol(names2, Decl(implicitIndexSignatures.ts, 5, 3)) + +declare function getStringIndexValue(map: { [x: string]: T }): T; +>getStringIndexValue : Symbol(getStringIndexValue, Decl(implicitIndexSignatures.ts, 11, 13)) +>T : Symbol(T, Decl(implicitIndexSignatures.ts, 13, 37)) +>map : Symbol(map, Decl(implicitIndexSignatures.ts, 13, 40)) +>x : Symbol(x, Decl(implicitIndexSignatures.ts, 13, 48)) +>T : Symbol(T, Decl(implicitIndexSignatures.ts, 13, 37)) +>T : Symbol(T, Decl(implicitIndexSignatures.ts, 13, 37)) + +declare function getNumberIndexValue(map: { [x: number]: T }): T; +>getNumberIndexValue : Symbol(getNumberIndexValue, Decl(implicitIndexSignatures.ts, 13, 68)) +>T : Symbol(T, Decl(implicitIndexSignatures.ts, 14, 37)) +>map : Symbol(map, Decl(implicitIndexSignatures.ts, 14, 40)) +>x : Symbol(x, Decl(implicitIndexSignatures.ts, 14, 48)) +>T : Symbol(T, Decl(implicitIndexSignatures.ts, 14, 37)) +>T : Symbol(T, Decl(implicitIndexSignatures.ts, 14, 37)) + +function f1() { +>f1 : Symbol(f1, Decl(implicitIndexSignatures.ts, 14, 68)) + + const o1 = { a: 1, b: 2 }; +>o1 : Symbol(o1, Decl(implicitIndexSignatures.ts, 17, 9)) +>a : Symbol(a, Decl(implicitIndexSignatures.ts, 17, 16)) +>b : Symbol(b, Decl(implicitIndexSignatures.ts, 17, 22)) + + let o2: { a: number, b: number }; +>o2 : Symbol(o2, Decl(implicitIndexSignatures.ts, 18, 7)) +>a : Symbol(a, Decl(implicitIndexSignatures.ts, 18, 13)) +>b : Symbol(b, Decl(implicitIndexSignatures.ts, 18, 24)) + + const v1 = getStringIndexValue(o1); +>v1 : Symbol(v1, Decl(implicitIndexSignatures.ts, 19, 9)) +>getStringIndexValue : Symbol(getStringIndexValue, Decl(implicitIndexSignatures.ts, 11, 13)) +>o1 : Symbol(o1, Decl(implicitIndexSignatures.ts, 17, 9)) + + const v2 = getStringIndexValue(o2); +>v2 : Symbol(v2, Decl(implicitIndexSignatures.ts, 20, 9)) +>getStringIndexValue : Symbol(getStringIndexValue, Decl(implicitIndexSignatures.ts, 11, 13)) +>o2 : Symbol(o2, Decl(implicitIndexSignatures.ts, 18, 7)) +} + +function f2() { +>f2 : Symbol(f2, Decl(implicitIndexSignatures.ts, 21, 1)) + + const o1 = { a: "1", b: "2" }; +>o1 : Symbol(o1, Decl(implicitIndexSignatures.ts, 24, 9)) +>a : Symbol(a, Decl(implicitIndexSignatures.ts, 24, 16)) +>b : Symbol(b, Decl(implicitIndexSignatures.ts, 24, 24)) + + let o2: { a: string, b: string }; +>o2 : Symbol(o2, Decl(implicitIndexSignatures.ts, 25, 7)) +>a : Symbol(a, Decl(implicitIndexSignatures.ts, 25, 13)) +>b : Symbol(b, Decl(implicitIndexSignatures.ts, 25, 24)) + + const v1 = getStringIndexValue(o1); +>v1 : Symbol(v1, Decl(implicitIndexSignatures.ts, 26, 9)) +>getStringIndexValue : Symbol(getStringIndexValue, Decl(implicitIndexSignatures.ts, 11, 13)) +>o1 : Symbol(o1, Decl(implicitIndexSignatures.ts, 24, 9)) + + const v2 = getStringIndexValue(o2); +>v2 : Symbol(v2, Decl(implicitIndexSignatures.ts, 27, 9)) +>getStringIndexValue : Symbol(getStringIndexValue, Decl(implicitIndexSignatures.ts, 11, 13)) +>o2 : Symbol(o2, Decl(implicitIndexSignatures.ts, 25, 7)) +} + +function f3() { +>f3 : Symbol(f3, Decl(implicitIndexSignatures.ts, 28, 1)) + + const o1 = { a: 1, b: "2" }; +>o1 : Symbol(o1, Decl(implicitIndexSignatures.ts, 31, 9)) +>a : Symbol(a, Decl(implicitIndexSignatures.ts, 31, 16)) +>b : Symbol(b, Decl(implicitIndexSignatures.ts, 31, 22)) + + let o2: { a: number, b: string }; +>o2 : Symbol(o2, Decl(implicitIndexSignatures.ts, 32, 7)) +>a : Symbol(a, Decl(implicitIndexSignatures.ts, 32, 13)) +>b : Symbol(b, Decl(implicitIndexSignatures.ts, 32, 24)) + + const v1 = getStringIndexValue(o1); +>v1 : Symbol(v1, Decl(implicitIndexSignatures.ts, 33, 9)) +>getStringIndexValue : Symbol(getStringIndexValue, Decl(implicitIndexSignatures.ts, 11, 13)) +>o1 : Symbol(o1, Decl(implicitIndexSignatures.ts, 31, 9)) + + const v2 = getStringIndexValue(o2); +>v2 : Symbol(v2, Decl(implicitIndexSignatures.ts, 34, 9)) +>getStringIndexValue : Symbol(getStringIndexValue, Decl(implicitIndexSignatures.ts, 11, 13)) +>o2 : Symbol(o2, Decl(implicitIndexSignatures.ts, 32, 7)) +} + +function f4() { +>f4 : Symbol(f4, Decl(implicitIndexSignatures.ts, 35, 1)) + + const o1 = { 0: "0", 1: "1", count: 2 }; +>o1 : Symbol(o1, Decl(implicitIndexSignatures.ts, 38, 9)) +>count : Symbol(count, Decl(implicitIndexSignatures.ts, 38, 32)) + + let o2: { 0: string, 1: string, count: number }; +>o2 : Symbol(o2, Decl(implicitIndexSignatures.ts, 39, 7)) +>count : Symbol(count, Decl(implicitIndexSignatures.ts, 39, 35)) + + const v1 = getStringIndexValue(o1); +>v1 : Symbol(v1, Decl(implicitIndexSignatures.ts, 40, 9)) +>getStringIndexValue : Symbol(getStringIndexValue, Decl(implicitIndexSignatures.ts, 11, 13)) +>o1 : Symbol(o1, Decl(implicitIndexSignatures.ts, 38, 9)) + + const v2 = getStringIndexValue(o2); +>v2 : Symbol(v2, Decl(implicitIndexSignatures.ts, 41, 9)) +>getStringIndexValue : Symbol(getStringIndexValue, Decl(implicitIndexSignatures.ts, 11, 13)) +>o2 : Symbol(o2, Decl(implicitIndexSignatures.ts, 39, 7)) + + const v3 = getNumberIndexValue(o1); +>v3 : Symbol(v3, Decl(implicitIndexSignatures.ts, 42, 9)) +>getNumberIndexValue : Symbol(getNumberIndexValue, Decl(implicitIndexSignatures.ts, 13, 68)) +>o1 : Symbol(o1, Decl(implicitIndexSignatures.ts, 38, 9)) + + const v4 = getNumberIndexValue(o2); +>v4 : Symbol(v4, Decl(implicitIndexSignatures.ts, 43, 9)) +>getNumberIndexValue : Symbol(getNumberIndexValue, Decl(implicitIndexSignatures.ts, 13, 68)) +>o2 : Symbol(o2, Decl(implicitIndexSignatures.ts, 39, 7)) +} + diff --git a/tests/baselines/reference/implicitIndexSignatures.types b/tests/baselines/reference/implicitIndexSignatures.types new file mode 100644 index 0000000000000..7d335c0049107 --- /dev/null +++ b/tests/baselines/reference/implicitIndexSignatures.types @@ -0,0 +1,201 @@ +=== tests/cases/compiler/implicitIndexSignatures.ts === +type StringMap = { [x: string]: string }; +>StringMap : { [x: string]: string; } +>x : string + +const empty1 = {}; +>empty1 : {} +>{} : {} + +let empty2: {}; +>empty2 : {} + +const names1 = { a: "foo", b: "bar" }; +>names1 : { a: string; b: string; } +>{ a: "foo", b: "bar" } : { a: string; b: string; } +>a : string +>"foo" : string +>b : string +>"bar" : string + +let names2: { a: string, b: string }; +>names2 : { a: string; b: string; } +>a : string +>b : string + +let map: StringMap; +>map : { [x: string]: string; } +>StringMap : { [x: string]: string; } + +map = { x: "xxx", y: "yyy" }; +>map = { x: "xxx", y: "yyy" } : { x: string; y: string; } +>map : { [x: string]: string; } +>{ x: "xxx", y: "yyy" } : { x: string; y: string; } +>x : string +>"xxx" : string +>y : string +>"yyy" : string + +map = empty1; +>map = empty1 : {} +>map : { [x: string]: string; } +>empty1 : {} + +map = empty2; +>map = empty2 : {} +>map : { [x: string]: string; } +>empty2 : {} + +map = names1; +>map = names1 : { a: string; b: string; } +>map : { [x: string]: string; } +>names1 : { a: string; b: string; } + +map = names2; +>map = names2 : { a: string; b: string; } +>map : { [x: string]: string; } +>names2 : { a: string; b: string; } + +declare function getStringIndexValue(map: { [x: string]: T }): T; +>getStringIndexValue : (map: { [x: string]: T; }) => T +>T : T +>map : { [x: string]: T; } +>x : string +>T : T +>T : T + +declare function getNumberIndexValue(map: { [x: number]: T }): T; +>getNumberIndexValue : (map: { [x: number]: T; }) => T +>T : T +>map : { [x: number]: T; } +>x : number +>T : T +>T : T + +function f1() { +>f1 : () => void + + const o1 = { a: 1, b: 2 }; +>o1 : { a: number; b: number; } +>{ a: 1, b: 2 } : { a: number; b: number; } +>a : number +>1 : number +>b : number +>2 : number + + let o2: { a: number, b: number }; +>o2 : { a: number; b: number; } +>a : number +>b : number + + const v1 = getStringIndexValue(o1); +>v1 : number +>getStringIndexValue(o1) : number +>getStringIndexValue : (map: { [x: string]: T; }) => T +>o1 : { a: number; b: number; } + + const v2 = getStringIndexValue(o2); +>v2 : number +>getStringIndexValue(o2) : number +>getStringIndexValue : (map: { [x: string]: T; }) => T +>o2 : { a: number; b: number; } +} + +function f2() { +>f2 : () => void + + const o1 = { a: "1", b: "2" }; +>o1 : { a: string; b: string; } +>{ a: "1", b: "2" } : { a: string; b: string; } +>a : string +>"1" : string +>b : string +>"2" : string + + let o2: { a: string, b: string }; +>o2 : { a: string; b: string; } +>a : string +>b : string + + const v1 = getStringIndexValue(o1); +>v1 : string +>getStringIndexValue(o1) : string +>getStringIndexValue : (map: { [x: string]: T; }) => T +>o1 : { a: string; b: string; } + + const v2 = getStringIndexValue(o2); +>v2 : string +>getStringIndexValue(o2) : string +>getStringIndexValue : (map: { [x: string]: T; }) => T +>o2 : { a: string; b: string; } +} + +function f3() { +>f3 : () => void + + const o1 = { a: 1, b: "2" }; +>o1 : { a: number; b: string; } +>{ a: 1, b: "2" } : { a: number; b: string; } +>a : number +>1 : number +>b : string +>"2" : string + + let o2: { a: number, b: string }; +>o2 : { a: number; b: string; } +>a : number +>b : string + + const v1 = getStringIndexValue(o1); +>v1 : number | string +>getStringIndexValue(o1) : number | string +>getStringIndexValue : (map: { [x: string]: T; }) => T +>o1 : { a: number; b: string; } + + const v2 = getStringIndexValue(o2); +>v2 : number | string +>getStringIndexValue(o2) : number | string +>getStringIndexValue : (map: { [x: string]: T; }) => T +>o2 : { a: number; b: string; } +} + +function f4() { +>f4 : () => void + + const o1 = { 0: "0", 1: "1", count: 2 }; +>o1 : { 0: string; 1: string; count: number; } +>{ 0: "0", 1: "1", count: 2 } : { 0: string; 1: string; count: number; } +>"0" : string +>"1" : string +>count : number +>2 : number + + let o2: { 0: string, 1: string, count: number }; +>o2 : { 0: string; 1: string; count: number; } +>count : number + + const v1 = getStringIndexValue(o1); +>v1 : string | number +>getStringIndexValue(o1) : string | number +>getStringIndexValue : (map: { [x: string]: T; }) => T +>o1 : { 0: string; 1: string; count: number; } + + const v2 = getStringIndexValue(o2); +>v2 : string | number +>getStringIndexValue(o2) : string | number +>getStringIndexValue : (map: { [x: string]: T; }) => T +>o2 : { 0: string; 1: string; count: number; } + + const v3 = getNumberIndexValue(o1); +>v3 : string +>getNumberIndexValue(o1) : string +>getNumberIndexValue : (map: { [x: number]: T; }) => T +>o1 : { 0: string; 1: string; count: number; } + + const v4 = getNumberIndexValue(o2); +>v4 : string +>getNumberIndexValue(o2) : string +>getNumberIndexValue : (map: { [x: number]: T; }) => T +>o2 : { 0: string; 1: string; count: number; } +} + diff --git a/tests/baselines/reference/indexSignaturesInferentialTyping.types b/tests/baselines/reference/indexSignaturesInferentialTyping.types index 328dbc18e4ff3..8545a7d4ca967 100644 --- a/tests/baselines/reference/indexSignaturesInferentialTyping.types +++ b/tests/baselines/reference/indexSignaturesInferentialTyping.types @@ -21,15 +21,15 @@ var x1 = foo({ 0: 0, 1: 1 }); // type should be number >x1 : number >foo({ 0: 0, 1: 1 }) : number >foo : (items: { [index: number]: T; }) => T ->{ 0: 0, 1: 1 } : { [x: number]: number; 0: number; 1: number; } +>{ 0: 0, 1: 1 } : { 0: number; 1: number; } >0 : number >1 : number var x2 = foo({ zero: 0, one: 1 }); ->x2 : any ->foo({ zero: 0, one: 1 }) : any +>x2 : {} +>foo({ zero: 0, one: 1 }) : {} >foo : (items: { [index: number]: T; }) => T ->{ zero: 0, one: 1 } : { [x: number]: undefined; zero: number; one: number; } +>{ zero: 0, one: 1 } : { zero: number; one: number; } >zero : number >0 : number >one : number @@ -39,7 +39,7 @@ var x3 = bar({ 0: 0, 1: 1 }); >x3 : number >bar({ 0: 0, 1: 1 }) : number >bar : (items: { [index: string]: T; }) => T ->{ 0: 0, 1: 1 } : { [x: string]: number; 0: number; 1: number; } +>{ 0: 0, 1: 1 } : { 0: number; 1: number; } >0 : number >1 : number @@ -47,7 +47,7 @@ var x4 = bar({ zero: 0, one: 1 }); // type should be number >x4 : number >bar({ zero: 0, one: 1 }) : number >bar : (items: { [index: string]: T; }) => T ->{ zero: 0, one: 1 } : { [x: string]: number; zero: number; one: number; } +>{ zero: 0, one: 1 } : { zero: number; one: number; } >zero : number >0 : number >one : number diff --git a/tests/baselines/reference/indexer.types b/tests/baselines/reference/indexer.types index a0142bb93830e..f24c90f6ea142 100644 --- a/tests/baselines/reference/indexer.types +++ b/tests/baselines/reference/indexer.types @@ -17,7 +17,7 @@ interface JQuery { var jq:JQuery={ 0: { id : "a" }, 1: { id : "b" } }; >jq : JQuery >JQuery : JQuery ->{ 0: { id : "a" }, 1: { id : "b" } } : { [x: number]: { id: string; }; 0: { id: string; }; 1: { id: string; }; } +>{ 0: { id : "a" }, 1: { id : "b" } } : { 0: { id: string; }; 1: { id: string; }; } >{ id : "a" } : { id: string; } >id : string >"a" : string diff --git a/tests/baselines/reference/indexer2.types b/tests/baselines/reference/indexer2.types index 7f1ccd41cb59f..ff82707edd311 100644 --- a/tests/baselines/reference/indexer2.types +++ b/tests/baselines/reference/indexer2.types @@ -17,5 +17,5 @@ var directChildrenMap = {}; >directChildrenMap : IDirectChildrenMap >{} : IDirectChildrenMap >IDirectChildrenMap : IDirectChildrenMap ->{} : { [x: number]: undefined; } +>{} : {} diff --git a/tests/baselines/reference/indexer3.types b/tests/baselines/reference/indexer3.types index 8f0582f782ae8..28bcd9cab0c93 100644 --- a/tests/baselines/reference/indexer3.types +++ b/tests/baselines/reference/indexer3.types @@ -3,7 +3,7 @@ var dateMap: { [x: string]: Date; } = {} >dateMap : { [x: string]: Date; } >x : string >Date : Date ->{} : { [x: string]: undefined; } +>{} : {} var r: Date = dateMap["hello"] // result type includes indexer using BCT >r : Date diff --git a/tests/baselines/reference/indexerA.types b/tests/baselines/reference/indexerA.types index c6ff81b3a26ad..ee6351eae33ac 100644 --- a/tests/baselines/reference/indexerA.types +++ b/tests/baselines/reference/indexerA.types @@ -17,7 +17,7 @@ class JQuery { var jq:JQuery={ 0: { id : "a" }, 1: { id : "b" } }; >jq : JQuery >JQuery : JQuery ->{ 0: { id : "a" }, 1: { id : "b" } } : { [x: number]: { id: string; }; 0: { id: string; }; 1: { id: string; }; } +>{ 0: { id : "a" }, 1: { id : "b" } } : { 0: { id: string; }; 1: { id: string; }; } >{ id : "a" } : { id: string; } >id : string >"a" : string diff --git a/tests/baselines/reference/indexerAssignability.errors.txt b/tests/baselines/reference/indexerAssignability.errors.txt deleted file mode 100644 index 44c2184517eca..0000000000000 --- a/tests/baselines/reference/indexerAssignability.errors.txt +++ /dev/null @@ -1,28 +0,0 @@ -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; }'. -tests/cases/compiler/indexerAssignability.ts(6,1): error TS2322: Type '{}' is not assignable to type '{ [s: string]: string; }'. - Index signature is missing 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 '{}'. - - -==== tests/cases/compiler/indexerAssignability.ts (3 errors) ==== - var a: { [s: string]: string; }; - var b: { [n: number]: string; }; - var c: {}; - - 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; }'. - a = c; - ~ -!!! error TS2322: Type '{}' is not assignable to type '{ [s: string]: string; }'. -!!! error TS2322: Index signature is missing 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 '{}'. - c = a; - c = b; \ No newline at end of file diff --git a/tests/baselines/reference/indexerAssignability.symbols b/tests/baselines/reference/indexerAssignability.symbols new file mode 100644 index 0000000000000..379a2885e2cbf --- /dev/null +++ b/tests/baselines/reference/indexerAssignability.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/indexerAssignability.ts === +var a: { [s: string]: string; }; +>a : Symbol(a, Decl(indexerAssignability.ts, 0, 3)) +>s : Symbol(s, Decl(indexerAssignability.ts, 0, 10)) + +var b: { [n: number]: string; }; +>b : Symbol(b, Decl(indexerAssignability.ts, 1, 3)) +>n : Symbol(n, Decl(indexerAssignability.ts, 1, 10)) + +var c: {}; +>c : Symbol(c, Decl(indexerAssignability.ts, 2, 3)) + +a = b; +>a : Symbol(a, Decl(indexerAssignability.ts, 0, 3)) +>b : Symbol(b, Decl(indexerAssignability.ts, 1, 3)) + +a = c; +>a : Symbol(a, Decl(indexerAssignability.ts, 0, 3)) +>c : Symbol(c, Decl(indexerAssignability.ts, 2, 3)) + +b = a; +>b : Symbol(b, Decl(indexerAssignability.ts, 1, 3)) +>a : Symbol(a, Decl(indexerAssignability.ts, 0, 3)) + +b = c; +>b : Symbol(b, Decl(indexerAssignability.ts, 1, 3)) +>c : Symbol(c, Decl(indexerAssignability.ts, 2, 3)) + +c = a; +>c : Symbol(c, Decl(indexerAssignability.ts, 2, 3)) +>a : Symbol(a, Decl(indexerAssignability.ts, 0, 3)) + +c = b; +>c : Symbol(c, Decl(indexerAssignability.ts, 2, 3)) +>b : Symbol(b, Decl(indexerAssignability.ts, 1, 3)) + diff --git a/tests/baselines/reference/indexerAssignability.types b/tests/baselines/reference/indexerAssignability.types new file mode 100644 index 0000000000000..bd301b59224ef --- /dev/null +++ b/tests/baselines/reference/indexerAssignability.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/indexerAssignability.ts === +var a: { [s: string]: string; }; +>a : { [s: string]: string; } +>s : string + +var b: { [n: number]: string; }; +>b : { [n: number]: string; } +>n : number + +var c: {}; +>c : {} + +a = b; +>a = b : { [n: number]: string; } +>a : { [s: string]: string; } +>b : { [n: number]: string; } + +a = c; +>a = c : {} +>a : { [s: string]: string; } +>c : {} + +b = a; +>b = a : { [s: string]: string; } +>b : { [n: number]: string; } +>a : { [s: string]: string; } + +b = c; +>b = c : {} +>b : { [n: number]: string; } +>c : {} + +c = a; +>c = a : { [s: string]: string; } +>c : {} +>a : { [s: string]: string; } + +c = b; +>c = b : { [n: number]: string; } +>c : {} +>b : { [n: number]: string; } + diff --git a/tests/baselines/reference/inferentialTypingObjectLiteralMethod2.types b/tests/baselines/reference/inferentialTypingObjectLiteralMethod2.types index be937410cef0f..f70305739b896 100644 --- a/tests/baselines/reference/inferentialTypingObjectLiteralMethod2.types +++ b/tests/baselines/reference/inferentialTypingObjectLiteralMethod2.types @@ -30,13 +30,13 @@ foo("", { method(p1) { return p1.length } }, { method(p2) { return undefined } } >foo("", { method(p1) { return p1.length } }, { method(p2) { return undefined } }) : string >foo : (x: T, y: Int, z: Int) => T >"" : string ->{ method(p1) { return p1.length } } : { [x: string]: (p1: string) => number; method(p1: string): number; } +>{ method(p1) { return p1.length } } : { method(p1: string): number; } >method : (p1: string) => number >p1 : string >p1.length : number >p1 : string >length : number ->{ method(p2) { return undefined } } : { [x: string]: (p2: number) => any; method(p2: number): any; } +>{ method(p2) { return undefined } } : { method(p2: number): any; } >method : (p2: number) => any >p2 : number >undefined : undefined diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType3.types b/tests/baselines/reference/inferentialTypingUsingApparentType3.types index 9e0a4ceaea6de..e375fe981e89a 100644 --- a/tests/baselines/reference/inferentialTypingUsingApparentType3.types +++ b/tests/baselines/reference/inferentialTypingUsingApparentType3.types @@ -49,10 +49,10 @@ class ObjectField }> { } var person = new ObjectField({ ->person : ObjectField<{}, { [x: string]: NumberField | CharField; id: NumberField; name: CharField; }> ->new ObjectField({ id: new NumberField(), name: new CharField()}) : ObjectField<{}, { [x: string]: NumberField | CharField; id: NumberField; name: CharField; }> +>person : ObjectField<{}, { id: NumberField; name: CharField; }> +>new ObjectField({ id: new NumberField(), name: new CharField()}) : ObjectField<{}, { id: NumberField; name: CharField; }> >ObjectField : typeof ObjectField ->{ id: new NumberField(), name: new CharField()} : { [x: string]: NumberField | CharField; id: NumberField; name: CharField; } +>{ id: new NumberField(), name: new CharField()} : { id: NumberField; name: CharField; } id: new NumberField(), >id : NumberField @@ -68,8 +68,8 @@ var person = new ObjectField({ person.fields.id; >person.fields.id : NumberField ->person.fields : { [x: string]: NumberField | CharField; id: NumberField; name: CharField; } ->person : ObjectField<{}, { [x: string]: NumberField | CharField; id: NumberField; name: CharField; }> ->fields : { [x: string]: NumberField | CharField; id: NumberField; name: CharField; } +>person.fields : { id: NumberField; name: CharField; } +>person : ObjectField<{}, { id: NumberField; name: CharField; }> +>fields : { id: NumberField; name: CharField; } >id : NumberField diff --git a/tests/baselines/reference/interfaceContextualType.types b/tests/baselines/reference/interfaceContextualType.types index e827f9a9d9b1e..0e835a2f1f955 100644 --- a/tests/baselines/reference/interfaceContextualType.types +++ b/tests/baselines/reference/interfaceContextualType.types @@ -27,11 +27,11 @@ class Bug { >ok : () => void this.values = {}; ->this.values = {} : { [x: string]: undefined; } +>this.values = {} : {} >this.values : IMap >this : this >values : IMap ->{} : { [x: string]: undefined; } +>{} : {} this.values['comments'] = { italic: true }; >this.values['comments'] = { italic: true } : { italic: boolean; } @@ -48,11 +48,11 @@ class Bug { >shouldBeOK : () => void this.values = { ->this.values = { comments: { italic: true } } : { [x: string]: { italic: boolean; }; comments: { italic: boolean; }; } +>this.values = { comments: { italic: true } } : { comments: { italic: boolean; }; } >this.values : IMap >this : this >values : IMap ->{ comments: { italic: true } } : { [x: string]: { italic: boolean; }; comments: { italic: boolean; }; } +>{ comments: { italic: true } } : { comments: { italic: boolean; }; } comments: { italic: true } >comments : { italic: boolean; } diff --git a/tests/baselines/reference/noErrorsInCallback.errors.txt b/tests/baselines/reference/noErrorsInCallback.errors.txt index 90fdbbd77a55f..f0bfe00199eb0 100644 --- a/tests/baselines/reference/noErrorsInCallback.errors.txt +++ b/tests/baselines/reference/noErrorsInCallback.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/noErrorsInCallback.ts(4,19): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. -tests/cases/compiler/noErrorsInCallback.ts(6,23): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. +tests/cases/compiler/noErrorsInCallback.ts(4,19): error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. +tests/cases/compiler/noErrorsInCallback.ts(6,23): error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/noErrorsInCallback.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/noErrorsInCallback.ts(6,23): error TS2345: Argument of type } var one = new Bar({}); // Error ~~ -!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. [].forEach(() => { var two = new Bar({}); // No error? ~~ -!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'string'. }); \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types b/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types index b7b21bf8f9258..d82b37e0f9e5b 100644 --- a/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types +++ b/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types @@ -87,7 +87,7 @@ interface MyMap { var m: MyMap = { >m : MyMap >MyMap : MyMap ->{ "0": 0, "1": 1, "2": 2, "Okay that's enough for today.": NaN} : { [x: string]: number; "0": number; "1": number; "2": number; "Okay that's enough for today.": number; } +>{ "0": 0, "1": 1, "2": 2, "Okay that's enough for today.": NaN} : { "0": number; "1": number; "2": number; "Okay that's enough for today.": number; } "0": 0, >0 : number diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt index 35673eb3072a1..bb01b2fe1251b 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt @@ -5,10 +5,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo 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(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. - 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(78,5): error TS2322: Type '{ 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; }'. + Property '2.0' is incompatible with index signature. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(88,9): error TS2304: Cannot find name 'Myn'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -108,10 +107,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo // error 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: Type 'string | number' is not assignable to type 'string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '{ 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: Property '2.0' is incompatible with index signature. +!!! error TS2322: Type 'number' is not assignable to type 'string'. a: '', b: 1, c: () => { }, diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt index ff18160e9a50e..332b356c732e1 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt @@ -1,10 +1,9 @@ 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(39,5): error TS2322: Type '{ [x: number]: A | number; 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. - Type 'A | number' is not assignable to type 'A'. - Type 'number' is not assignable to type 'A'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. + Property '3.0' is incompatible with index signature. + Type 'number' is not assignable to type 'A'. ==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts (4 errors) ==== @@ -54,10 +53,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo // error var b: { [x: number]: A } = { ~ -!!! error TS2322: Type '{ [x: number]: A | number; 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: Type 'A | number' is not assignable to type 'A'. -!!! error TS2322: Type 'number' is not assignable to type 'A'. +!!! error TS2322: Type '{ 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: Property '3.0' is incompatible with index signature. +!!! error TS2322: Type 'number' is not assignable to type 'A'. 1.0: new A(), 2.0: new B(), "2.5": new B(), diff --git a/tests/baselines/reference/numericIndexerConstraint2.errors.txt b/tests/baselines/reference/numericIndexerConstraint2.errors.txt index 385efbcead2ab..5c0337acc3247 100644 --- a/tests/baselines/reference/numericIndexerConstraint2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstraint2.errors.txt @@ -1,5 +1,6 @@ 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; }'. + Property 'one' is incompatible with index signature. + Type 'number' is not assignable to type 'Foo'. ==== tests/cases/compiler/numericIndexerConstraint2.ts (1 errors) ==== @@ -9,4 +10,5 @@ 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: Property 'one' is incompatible with index signature. +!!! error TS2322: Type 'number' is not assignable to type 'Foo'. \ No newline at end of file diff --git a/tests/baselines/reference/numericIndexerConstraint4.types b/tests/baselines/reference/numericIndexerConstraint4.types index 97e72b5088d93..c8af4d54a9a75 100644 --- a/tests/baselines/reference/numericIndexerConstraint4.types +++ b/tests/baselines/reference/numericIndexerConstraint4.types @@ -22,7 +22,7 @@ var x: { >A : A } = { data: new B() } ->{ data: new B() } : { [x: number]: undefined; data: B; } +>{ data: new B() } : { data: B; } >data : B >new B() : B >B : typeof B diff --git a/tests/baselines/reference/numericIndexerConstraint5.errors.txt b/tests/baselines/reference/numericIndexerConstraint5.errors.txt index 98acc65eeb73c..cb888de08c4ec 100644 --- a/tests/baselines/reference/numericIndexerConstraint5.errors.txt +++ b/tests/baselines/reference/numericIndexerConstraint5.errors.txt @@ -1,5 +1,6 @@ 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; }'. + Property '0' is incompatible with index signature. + Type 'Date' is not assignable to type 'string'. ==== tests/cases/compiler/numericIndexerConstraint5.ts (1 errors) ==== @@ -7,4 +8,5 @@ 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: Property '0' is incompatible with index signature. +!!! error TS2322: Type 'Date' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/numericIndexingResults.types b/tests/baselines/reference/numericIndexingResults.types index 560bbdc74a8e7..9a060b388e363 100644 --- a/tests/baselines/reference/numericIndexingResults.types +++ b/tests/baselines/reference/numericIndexingResults.types @@ -151,7 +151,7 @@ var r6 = a[3]; var b: { [x: number]: string } = { 1: '', "2": '' } >b : { [x: number]: string; } >x : number ->{ 1: '', "2": '' } : { [x: number]: string; 1: string; "2": string; } +>{ 1: '', "2": '' } : { 1: string; "2": string; } >'' : string >'' : string @@ -194,7 +194,7 @@ var r6 = b[3]; var b2: { [x: number]: string; 1: string; "2": string; } = { 1: '', "2": '' } >b2 : { [x: number]: string; 1: string; "2": string; } >x : number ->{ 1: '', "2": '' } : { [x: number]: string; 1: string; "2": string; } +>{ 1: '', "2": '' } : { 1: string; "2": string; } >'' : string >'' : string diff --git a/tests/baselines/reference/objectIndexer.types b/tests/baselines/reference/objectIndexer.types index 3dcd7bcb77e96..b11c475a3863d 100644 --- a/tests/baselines/reference/objectIndexer.types +++ b/tests/baselines/reference/objectIndexer.types @@ -23,11 +23,11 @@ class Emitter { constructor () { this.listeners = {}; ->this.listeners = {} : { [x: string]: undefined; } +>this.listeners = {} : {} >this.listeners : IMap >this : this >listeners : IMap ->{} : { [x: string]: undefined; } +>{} : {} } } diff --git a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt index f825c41631149..9d5ff7ea0a2ba 100644 --- a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt @@ -1,10 +1,13 @@ -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. +tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. + Property '0' is incompatible with index signature. Type 'A' is not assignable to type 'B'. Property 'y' is missing in type 'A'. +tests/cases/compiler/objectLiteralIndexerErrors.ts(14,1): error TS2322: Type '{ 0: A; x: any; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. + Property '0' is incompatible with index signature. + Type 'A' is not assignable to type 'B'. -==== tests/cases/compiler/objectLiteralIndexerErrors.ts (1 errors) ==== +==== tests/cases/compiler/objectLiteralIndexerErrors.ts (2 errors) ==== interface A { x: number; } @@ -19,8 +22,12 @@ 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: Type '{ 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +!!! error TS2322: Property '0' is incompatible with index signature. !!! error TS2322: Type 'A' is not assignable to type 'B'. !!! error TS2322: Property 'y' is missing in type 'A'. - o1 = { x: c, 0: a }; // string indexer is any, number indexer is A \ No newline at end of file + o1 = { x: c, 0: a }; // string indexer is any, number indexer is A + ~~ +!!! error TS2322: Type '{ 0: A; x: any; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +!!! error TS2322: Property '0' is incompatible with index signature. +!!! error TS2322: Type 'A' is not assignable to type 'B'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralIndexerNoImplicitAny.types b/tests/baselines/reference/objectLiteralIndexerNoImplicitAny.types index a49f76d02e91e..b0ddd9f60d0e9 100644 --- a/tests/baselines/reference/objectLiteralIndexerNoImplicitAny.types +++ b/tests/baselines/reference/objectLiteralIndexerNoImplicitAny.types @@ -9,7 +9,7 @@ interface I { var x: I = { >x : I >I : I ->{ p: null} : { [x: string]: null; p: null; } +>{ p: null} : { p: null; } p: null >p : null diff --git a/tests/baselines/reference/objectLiteralIndexers.types b/tests/baselines/reference/objectLiteralIndexers.types index d5add00ebafb6..9e3aa4bac49c3 100644 --- a/tests/baselines/reference/objectLiteralIndexers.types +++ b/tests/baselines/reference/objectLiteralIndexers.types @@ -31,23 +31,23 @@ var o1: { [s: string]: A;[n: number]: B; } = { x: a, 0: b }; // string indexer i >A : A >n : number >B : B ->{ x: a, 0: b } : { [x: string]: A; [x: number]: B; 0: B; x: A; } +>{ x: a, 0: b } : { 0: B; x: A; } >x : A >a : A >b : B o1 = { x: b, 0: c }; // both indexers are any ->o1 = { x: b, 0: c } : { [x: string]: any; [x: number]: any; 0: any; x: B; } +>o1 = { x: b, 0: c } : { 0: any; x: B; } >o1 : { [s: string]: A; [n: number]: B; } ->{ x: b, 0: c } : { [x: string]: any; [x: number]: any; 0: any; x: B; } +>{ x: b, 0: c } : { 0: any; x: B; } >x : B >b : B >c : any o1 = { x: c, 0: b }; // string indexer is any, number indexer is B ->o1 = { x: c, 0: b } : { [x: string]: any; [x: number]: B; 0: B; x: any; } +>o1 = { x: c, 0: b } : { 0: B; x: any; } >o1 : { [s: string]: A; [n: number]: B; } ->{ x: c, 0: b } : { [x: string]: any; [x: number]: B; 0: B; x: any; } +>{ x: c, 0: b } : { 0: B; x: any; } >x : any >c : any >b : B diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.types b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.types index 2284d06ffbd0f..c5de5c7b9b453 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.types +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.types @@ -50,7 +50,7 @@ var a: { var b: { [x: number]: string; } = { foo: '' }; >b : { [x: number]: string; } >x : number ->{ foo: '' } : { [x: number]: undefined; foo: string; } +>{ foo: '' } : { foo: string; } >foo : string >'' : string diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.types b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.types index 1a580297b1b3e..17fc6a07a005a 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.types +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.types @@ -64,7 +64,7 @@ var b: { [x: number]: Derived; } = { foo: null }; >b : { [x: number]: Derived; } >x : number >Derived : Derived ->{ foo: null } : { [x: number]: undefined; foo: Derived; } +>{ foo: null } : { foo: Derived; } >foo : Derived >null : Derived >Derived : Derived diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.types b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.types index ae384bbb4db36..99e6b8c86326e 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.types +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.types @@ -50,7 +50,7 @@ var a: { var b: { [x: number]: string; } = { foo: '' }; >b : { [x: number]: string; } >x : number ->{ foo: '' } : { [x: number]: undefined; foo: string; } +>{ foo: '' } : { foo: string; } >foo : string >'' : string diff --git a/tests/baselines/reference/objectTypesIdentityWithStringIndexers.types b/tests/baselines/reference/objectTypesIdentityWithStringIndexers.types index a7eeb67250477..8393eaf68a0dd 100644 --- a/tests/baselines/reference/objectTypesIdentityWithStringIndexers.types +++ b/tests/baselines/reference/objectTypesIdentityWithStringIndexers.types @@ -50,7 +50,7 @@ var a: { var b: { [x: string]: string; } = { foo: '' }; >b : { [x: string]: string; } >x : string ->{ foo: '' } : { [x: string]: string; foo: string; } +>{ foo: '' } : { foo: string; } >foo : string >'' : string diff --git a/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.types b/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.types index d13942521170d..814d0c91814f6 100644 --- a/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.types +++ b/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.types @@ -64,7 +64,7 @@ var b: { [x: string]: Derived; } = { foo: null }; >b : { [x: string]: Derived; } >x : string >Derived : Derived ->{ foo: null } : { [x: string]: Derived; foo: Derived; } +>{ foo: null } : { foo: Derived; } >foo : Derived >null : Derived >Derived : Derived diff --git a/tests/baselines/reference/operatorsAndIntersectionTypes.types b/tests/baselines/reference/operatorsAndIntersectionTypes.types index 70611776fc1cd..6b5987d3a69da 100644 --- a/tests/baselines/reference/operatorsAndIntersectionTypes.types +++ b/tests/baselines/reference/operatorsAndIntersectionTypes.types @@ -28,7 +28,7 @@ function createSerialNo() { let map1: { [x: string]: number } = {}; >map1 : { [x: string]: number; } >x : string ->{} : { [x: string]: undefined; } +>{} : {} let guid = createGuid(); >guid : string & { $Guid: any; } @@ -45,7 +45,7 @@ map1[guid] = 123; // Can with tagged string let map2: { [x: number]: string } = {}; >map2 : { [x: number]: string; } >x : number ->{} : { [x: number]: undefined; } +>{} : {} let serialNo = createSerialNo(); >serialNo : number & { $SerialNo: any; } diff --git a/tests/baselines/reference/restElementWithNullInitializer.errors.txt b/tests/baselines/reference/restElementWithNullInitializer.errors.txt index 7beb7b9a642ff..4658acc5ff40a 100644 --- a/tests/baselines/reference/restElementWithNullInitializer.errors.txt +++ b/tests/baselines/reference/restElementWithNullInitializer.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/destructuring/restElementWithNullInitializer.ts(1,15): error TS2461: Type 'null' is not an array type. tests/cases/conformance/es6/destructuring/restElementWithNullInitializer.ts(4,15): error TS2461: Type 'undefined' is not an array type. -tests/cases/conformance/es6/destructuring/restElementWithNullInitializer.ts(7,15): error TS2461: Type '{ [x: number]: undefined; }' is not an array type. +tests/cases/conformance/es6/destructuring/restElementWithNullInitializer.ts(7,15): error TS2461: Type '{}' is not an array type. ==== tests/cases/conformance/es6/destructuring/restElementWithNullInitializer.ts (3 errors) ==== @@ -16,7 +16,7 @@ tests/cases/conformance/es6/destructuring/restElementWithNullInitializer.ts(7,15 function foo3([...r] = {}) { ~~~~~~ -!!! error TS2461: Type '{ [x: number]: undefined; }' is not an array type. +!!! error TS2461: Type '{}' is not an array type. } function foo4([...r] = []) { diff --git a/tests/baselines/reference/stringIndexerAssignments1.errors.txt b/tests/baselines/reference/stringIndexerAssignments1.errors.txt index 908371bc7dd0e..ac99b239779af 100644 --- a/tests/baselines/reference/stringIndexerAssignments1.errors.txt +++ b/tests/baselines/reference/stringIndexerAssignments1.errors.txt @@ -1,18 +1,13 @@ -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; }'. 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'. -==== tests/cases/compiler/stringIndexerAssignments1.ts (2 errors) ==== +==== tests/cases/compiler/stringIndexerAssignments1.ts (1 errors) ==== var x: { [index: string]: string; one: string; }; var a: { one: string; }; var b: { one: number; two: string; }; 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; }'. 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/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index 08881be2a8617..8f4bbe2025a52 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -22,10 +22,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon 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(78,5): error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString; 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. - Type 'string | number | (() => void) | MyString' is not assignable to type 'string'. - Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ 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; }'. + Property '2.0' is incompatible with index signature. + 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. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -158,10 +157,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: string; } = { ~ -!!! error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString; 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: Type 'string | number | (() => void) | MyString' is not assignable to type 'string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '{ 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: Property '2.0' is incompatible with index signature. +!!! error TS2322: Type 'number' is not assignable to type 'string'. a: '', b: 1, c: () => { }, diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt index faef790545368..dacfb1a522d77 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt @@ -4,8 +4,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon 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(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. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(36,5): error TS2322: Type '{ a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. + Property 'a' is incompatible with index signature. Type 'typeof A' is not assignable to type 'A'. Property 'foo' is missing in type 'typeof A'. @@ -60,8 +60,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // 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: Type '{ a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. +!!! error TS2322: Property 'a' is incompatible with index signature. !!! 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/stringIndexingResults.types b/tests/baselines/reference/stringIndexingResults.types index 9f613312e5a7c..1fdc580b1a2cd 100644 --- a/tests/baselines/reference/stringIndexingResults.types +++ b/tests/baselines/reference/stringIndexingResults.types @@ -95,7 +95,7 @@ var r9 = a[1]; var b: { [x: string]: string } = { y: '' } >b : { [x: string]: string; } >x : string ->{ y: '' } : { [x: string]: string; y: string; } +>{ y: '' } : { y: string; } >y : string >'' : string diff --git a/tests/baselines/reference/symbolProperty1.types b/tests/baselines/reference/symbolProperty1.types index f39d98853d2b1..667e51fda8aaa 100644 --- a/tests/baselines/reference/symbolProperty1.types +++ b/tests/baselines/reference/symbolProperty1.types @@ -3,8 +3,8 @@ var s: symbol; >s : symbol var x = { ->x : {} ->{ [s]: 0, [s]() { }, get [s]() { return 0; }} : {} +>x : { [x: string]: number | (() => void); } +>{ [s]: 0, [s]() { }, get [s]() { return 0; }} : { [x: string]: number | (() => void); } [s]: 0, >s : symbol diff --git a/tests/baselines/reference/symbolProperty2.types b/tests/baselines/reference/symbolProperty2.types index df49130520a2e..7584c6461e8ec 100644 --- a/tests/baselines/reference/symbolProperty2.types +++ b/tests/baselines/reference/symbolProperty2.types @@ -5,8 +5,8 @@ var s = Symbol(); >Symbol : SymbolConstructor var x = { ->x : {} ->{ [s]: 0, [s]() { }, get [s]() { return 0; }} : {} +>x : { [x: string]: number | (() => void); } +>{ [s]: 0, [s]() { }, get [s]() { return 0; }} : { [x: string]: number | (() => void); } [s]: 0, >s : symbol diff --git a/tests/baselines/reference/symbolProperty4.types b/tests/baselines/reference/symbolProperty4.types index 93b4417b8ae1b..7bcf3f2339769 100644 --- a/tests/baselines/reference/symbolProperty4.types +++ b/tests/baselines/reference/symbolProperty4.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/Symbols/symbolProperty4.ts === var x = { ->x : {} ->{ [Symbol()]: 0, [Symbol()]() { }, get [Symbol()]() { return 0; }} : {} +>x : { [x: string]: number | (() => void); } +>{ [Symbol()]: 0, [Symbol()]() { }, get [Symbol()]() { return 0; }} : { [x: string]: number | (() => void); } [Symbol()]: 0, >Symbol() : symbol diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index e6910840d3992..94ab502864775 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. - Property 'raw' is missing in type '{ [x: number]: undefined; }'. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. + Property 'raw' is missing in type '{}'. ==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2 f({}, 10, 10); ~~ -!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. -!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'. +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. +!!! error TS2345: Property 'raw' is missing in type '{}'. f `abcdef${ 1234 }${ 5678 }ghijkl`; \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.errors.txt index e8bf38c104861..1201c82f4d07b 100644 --- a/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(5,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. - Property 'raw' is missing in type '{ [x: number]: undefined; }'. +tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(5,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. + Property 'raw' is missing in type '{}'. ==== tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(5,3): error TS f({}, 10, 10); ~~ -!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. -!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'. +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. +!!! error TS2345: Property 'raw' is missing in type '{}'. f `abcdef${ 1234 }${ 5678 }ghijkl`; \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt index ac30556a23551..f410d40848231 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. - Property 'raw' is missing in type '{ [x: number]: undefined; }'. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. + Property 'raw' is missing in type '{}'. ==== tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error T f({}, 10, 10); ~~ -!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. -!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'. +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. +!!! error TS2345: Property 'raw' is missing in type '{}'. f `abcdef${ 1234 }${ 5678 }ghijkl`; \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterFixingWithConstraints.types b/tests/baselines/reference/typeParameterFixingWithConstraints.types index 22d294f9d2edb..1e71f439e5e2b 100644 --- a/tests/baselines/reference/typeParameterFixingWithConstraints.types +++ b/tests/baselines/reference/typeParameterFixingWithConstraints.types @@ -31,17 +31,17 @@ var foo: IFoo; >IFoo : IFoo foo.foo({ bar: null }, bar => null, bar => null); ->foo.foo({ bar: null }, bar => null, bar => null) : { [x: string]: any; bar: any; } +>foo.foo({ bar: null }, bar => null, bar => null) : { bar: any; } >foo.foo : (bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar >foo : IFoo >foo : (bar: TBar, bar1: (bar: TBar) => TBar, bar2: (bar: TBar) => TBar) => TBar ->{ bar: null } : { [x: string]: null; bar: null; } +>{ bar: null } : { bar: null; } >bar : null >null : null ->bar => null : (bar: { [x: string]: any; bar: any; }) => any ->bar : { [x: string]: any; bar: any; } +>bar => null : (bar: { bar: any; }) => any +>bar : { bar: any; } >null : null ->bar => null : (bar: { [x: string]: any; bar: any; }) => any ->bar : { [x: string]: any; bar: any; } +>bar => null : (bar: { bar: any; }) => any +>bar : { bar: any; } >null : null diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 4d8a05a5c381e..37f3bdb12ab13 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -31,7 +31,7 @@ _.each({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => alert(valu >_.each : { (list: T[], iterator: Iterator, context?: any): void; (list: Dictionary, iterator: Iterator, context?: any): void; } >_ : Underscore.Static >each : { (list: T[], iterator: Iterator, context?: any): void; (list: Dictionary, iterator: Iterator, context?: any): void; } ->{ one: 1, two: 2, three: 3 } : { [x: string]: number; one: number; two: number; three: number; } +>{ one: 1, two: 2, three: 3 } : { one: number; two: number; three: number; } >one : number >1 : number >two : number @@ -68,7 +68,7 @@ _.map({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => value * 3); >_.map : { (list: T[], iterator: Iterator, context?: any): U[]; (list: Dictionary, iterator: Iterator, context?: any): U[]; } >_ : Underscore.Static >map : { (list: T[], iterator: Iterator, context?: any): U[]; (list: Dictionary, iterator: Iterator, context?: any): U[]; } ->{ one: 1, two: 2, three: 3 } : { [x: string]: number; one: number; two: number; three: number; } +>{ one: 1, two: 2, three: 3 } : { one: number; two: number; three: number; } >one : number >1 : number >two : number @@ -449,7 +449,7 @@ _.size({ one: 1, two: 2, three: 3 }); >_.size : { (list: T[]): number; (list: Dictionary): number; } >_ : Underscore.Static >size : { (list: T[]): number; (list: Dictionary): number; } ->{ one: 1, two: 2, three: 3 } : { [x: string]: number; one: number; two: number; three: number; } +>{ one: 1, two: 2, three: 3 } : { one: number; two: number; three: number; } >one : number >1 : number >two : number diff --git a/tests/baselines/reference/widenedTypes.errors.txt b/tests/baselines/reference/widenedTypes.errors.txt index 2277ef6eea75a..beda634c2a6da 100644 --- a/tests/baselines/reference/widenedTypes.errors.txt +++ b/tests/baselines/reference/widenedTypes.errors.txt @@ -6,8 +6,8 @@ tests/cases/compiler/widenedTypes.ts(11,1): error TS2322: Type 'string' is not a tests/cases/compiler/widenedTypes.ts(18,1): error TS2322: Type 'string' is not assignable to type 'number'. 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. +tests/cases/compiler/widenedTypes.ts(24,5): error TS2322: Type '{ x: number; y: null; }' is not assignable to type '{ [x: string]: string; }'. + Property 'x' is incompatible with index signature. Type 'number' is not assignable to type 'string'. @@ -52,6 +52,6 @@ tests/cases/compiler/widenedTypes.ts(24,5): error TS2322: Type '{ [x: string]: n !!! error TS2322: Type 'number' is not assignable to type 'string'. 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: Type '{ x: number; y: null; }' is not assignable to type '{ [x: string]: string; }'. +!!! error TS2322: Property 'x' is incompatible with index signature. !!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt b/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt index 60602351b465c..47e8e6ff4f295 100644 --- a/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt +++ b/tests/baselines/reference/wrappedAndRecursiveConstraints4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,12): error TS2345: Argument of type '{ [x: number]: undefined; length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,12): error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. ==== tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts (1 errors) ==== @@ -16,4 +16,4 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursi var r = c.foo(''); var r2 = r({ length: 3, charAt: (x: number) => { '' } }); // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ [x: number]: undefined; length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. \ No newline at end of file +!!! error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'. \ No newline at end of file diff --git a/tests/cases/compiler/implicitIndexSignatures.ts b/tests/cases/compiler/implicitIndexSignatures.ts new file mode 100644 index 0000000000000..2e36a91badab3 --- /dev/null +++ b/tests/cases/compiler/implicitIndexSignatures.ts @@ -0,0 +1,45 @@ +type StringMap = { [x: string]: string }; + +const empty1 = {}; +let empty2: {}; +const names1 = { a: "foo", b: "bar" }; +let names2: { a: string, b: string }; +let map: StringMap; +map = { x: "xxx", y: "yyy" }; +map = empty1; +map = empty2; +map = names1; +map = names2; + +declare function getStringIndexValue(map: { [x: string]: T }): T; +declare function getNumberIndexValue(map: { [x: number]: T }): T; + +function f1() { + const o1 = { a: 1, b: 2 }; + let o2: { a: number, b: number }; + const v1 = getStringIndexValue(o1); + const v2 = getStringIndexValue(o2); +} + +function f2() { + const o1 = { a: "1", b: "2" }; + let o2: { a: string, b: string }; + const v1 = getStringIndexValue(o1); + const v2 = getStringIndexValue(o2); +} + +function f3() { + const o1 = { a: 1, b: "2" }; + let o2: { a: number, b: string }; + const v1 = getStringIndexValue(o1); + const v2 = getStringIndexValue(o2); +} + +function f4() { + const o1 = { 0: "0", 1: "1", count: 2 }; + let o2: { 0: string, 1: string, count: number }; + const v1 = getStringIndexValue(o1); + const v2 = getStringIndexValue(o2); + const v3 = getNumberIndexValue(o1); + const v4 = getNumberIndexValue(o2); +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy