Merge pull request #7029 from Microsoft/implicitIndexSignatures

Implicit index signatures
This commit is contained in:
Anders Hejlsberg
2016-02-16 15:37:18 -08:00
129 changed files with 1053 additions and 507 deletions
+117 -104
View File
@@ -3996,6 +3996,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);
@@ -5752,9 +5765,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);
}
}
}
@@ -5956,76 +5969,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);
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;
}
result &= related;
}
}
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 result;
}
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(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;
}
const related = isRelatedTo(sourceInfo.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 numberIndexTypesRelatedTo(source: Type, originalSource: Type, target: Type, reportErrors: boolean): Ternary {
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 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;
}
return related;
}
return Ternary.True;
}
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) {
@@ -6268,6 +6270,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 = (<FreshObjectLiteralType>type).regularType;
@@ -6607,9 +6619,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--;
}
}
@@ -6647,12 +6657,22 @@ namespace ts {
}
}
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);
}
}
}
@@ -7865,11 +7885,6 @@ namespace ts {
return !!(type.flags & TypeFlags.Union ? forEach((<UnionType>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((<UnionType>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.
@@ -8265,6 +8280,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
@@ -8276,8 +8302,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 ||
@@ -8341,7 +8369,15 @@ namespace ts {
checkAccessorDeclaration(<AccessorDeclaration>memberDecl);
}
if (!hasDynamicName(memberDecl)) {
if (hasDynamicName(memberDecl)) {
if (isNumericName(memberDecl.name)) {
hasComputedNumberProperty = true;
}
else {
hasComputedStringProperty = true;
}
}
else {
propertiesTable[member.name] = member;
}
propertiesArray.push(member);
@@ -8362,8 +8398,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);
@@ -8371,29 +8407,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) {
+4
View File
@@ -1703,6 +1703,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
@@ -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
@@ -6,6 +6,6 @@ function method() {
>dictionary : { [index: string]: string; }
><{ [index: string]: string; }>{} : { [index: string]: string; }
>index : string
>{} : { [x: string]: undefined; }
>{} : {}
}
@@ -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
@@ -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; }'.
var r8b4 = b4 !== a4;
@@ -98,7 +98,7 @@ x2 += E.a;
x2 += {};
>x2 += {} : string
>x2 : string
>{} : { [x: number]: undefined; }
>{} : {}
x2 += null;
>x2 += null : string
@@ -9,8 +9,8 @@ var a: any;
>a : any
var v = {
>v : { [0](): void; [""](): void; }
>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [<any>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]() { }, [<any>true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; }
[s]() { },
>s : string
@@ -9,8 +9,8 @@ var a: any;
>a : any
var v = {
>v : { [0](): void; [""](): void; }
>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [<any>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]() { }, [<any>true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; }
[s]() { },
>s : string
@@ -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 [<any>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 [<any>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
@@ -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 [<any>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 [<any>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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -12,8 +12,8 @@ class C<T> {
>bar : () => number
var obj = {
>obj : {}
>{ [foo<T>()]() { } } : {}
>obj : { [x: string]: () => void; }
>{ [foo<T>()]() { } } : { [x: string]: () => void; }
[foo<T>()]() { }
>foo<T>() : string
@@ -12,8 +12,8 @@ class C<T> {
>bar : () => number
var obj = {
>obj : {}
>{ [foo<T>()]() { } } : {}
>obj : { [x: string]: () => void; }
>{ [foo<T>()]() { } } : { [x: string]: () => void; }
[foo<T>()]() { }
>foo<T>() : string
@@ -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
@@ -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
@@ -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
@@ -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
@@ -39,9 +39,9 @@ extractIndexer({
}); // Should return string
extractIndexer({
>extractIndexer({ ["" || 0]: ""}) : any
>extractIndexer({ ["" || 0]: ""}) : string
>extractIndexer : <T>(p: { [n: number]: T; }) => T
>{ ["" || 0]: ""} : { [x: number]: undefined; }
>{ ["" || 0]: ""} : { [x: string]: string; }
["" || 0]: ""
>"" || 0 : string | number
@@ -39,9 +39,9 @@ extractIndexer({
}); // Should return string
extractIndexer({
>extractIndexer({ ["" || 0]: ""}) : any
>extractIndexer({ ["" || 0]: ""}) : string
>extractIndexer : <T>(p: { [n: number]: T; }) => T
>{ ["" || 0]: ""} : { [x: number]: undefined; }
>{ ["" || 0]: ""} : { [x: string]: string; }
["" || 0]: ""
>"" || 0 : string | number
@@ -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, [<any>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, [<any>true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: number | string; [x: number]: number | string; [0]: number; [""]: number; }
[s]: 0,
>s : string
@@ -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, [<any>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, [<any>true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: number | string; [x: number]: number | string; [0]: number; [""]: number; }
[s]: 0,
>s : string
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -19,7 +19,7 @@ declare function foo<T>(obj: I<T>): T
foo({
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | boolean | number | number[]
>foo : <T>(obj: I<T>) => 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
@@ -19,7 +19,7 @@ declare function foo<T>(obj: I<T>): T
foo({
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | boolean | number | number[]
>foo : <T>(obj: I<T>) => 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
@@ -19,7 +19,7 @@ declare function foo<T>(obj: I<T>): T
foo({
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[]
>foo : <T>(obj: I<T>) => 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
@@ -19,7 +19,7 @@ declare function foo<T>(obj: I<T>): T
foo({
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[]
>foo : <T>(obj: I<T>) => 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
@@ -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'.
@@ -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'.
@@ -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'.
@@ -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'.
@@ -26,4 +26,6 @@ var _a;
//// [computedPropertyNamesDeclarationEmit5_ES5.d.ts]
declare var v: {};
declare var v: {
[x: string]: any;
};
@@ -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
@@ -16,4 +16,6 @@ var v = {
//// [computedPropertyNamesDeclarationEmit5_ES6.d.ts]
declare var v: {};
declare var v: {
[x: string]: any;
};
@@ -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
@@ -35,7 +35,7 @@ var o: {
>idx : number
} = {
>{ 1: true } : { [x: number]: boolean; 1: boolean; }
>{ 1: true } : { 1: boolean; }
1: true
>true : boolean
@@ -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];
@@ -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))
@@ -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
@@ -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
];
@@ -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
@@ -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; }'.
@@ -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))
@@ -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; }
@@ -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];
}
@@ -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
@@ -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
@@ -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
@@ -3,8 +3,8 @@ function* g() {
>g : () => IterableIterator<number>
let x = {
>x : {}
>{ [yield 0]: 0 } : {}
>x : { [x: number]: number; }
>{ [yield 0]: 0 } : { [x: number]: number; }
[yield 0]: 0
>yield 0 : any
@@ -3,8 +3,8 @@ function* g() {
>g : () => IterableIterator<number>
let x = {
>x : {}
>{ [yield 0]() { } } : {}
>x : { [x: number]: () => void; }
>{ [yield 0]() { } } : { [x: number]: () => void; }
[yield 0]() {
>yield 0 : any
@@ -3,8 +3,8 @@ function* g() {
>g : () => IterableIterator<number>
let x = {
>x : {}
>{ *[yield 0]() { } } : {}
>x : { [x: number]: () => IterableIterator<any>; }
>{ *[yield 0]() { } } : { [x: number]: () => IterableIterator<any>; }
*[yield 0]() {
>yield 0 : any
@@ -3,8 +3,8 @@ function* g() {
>g : () => IterableIterator<number>
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
@@ -14,11 +14,11 @@ class BaseCollection2<TItem extends CollectionItem2> {
constructor() {
this._itemsByKey = {};
>this._itemsByKey = {} : { [x: string]: undefined; }
>this._itemsByKey = {} : {}
>this._itemsByKey : { [key: string]: TItem; }
>this : this
>_itemsByKey : { [key: string]: TItem; }
>{} : { [x: string]: undefined; }
>{} : {}
}
}
@@ -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 '[{}, {}]'.
@@ -8,7 +8,7 @@ class LazyArray<T> {
><{ [objectId: string]: T; }>{} : { [objectId: string]: T; }
>objectId : string
>T : T
>{} : { [x: string]: undefined; }
>{} : {}
array() {
>array : () => { [objectId: string]: T; }
@@ -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<T>(map: { [x: string]: T }): T;
declare function getNumberIndexValue<T>(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);
}
@@ -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<T>(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<T>(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))
}
@@ -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<T>(map: { [x: string]: T }): T;
>getStringIndexValue : <T>(map: { [x: string]: T; }) => T
>T : T
>map : { [x: string]: T; }
>x : string
>T : T
>T : T
declare function getNumberIndexValue<T>(map: { [x: number]: T }): T;
>getNumberIndexValue : <T>(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 : <T>(map: { [x: string]: T; }) => T
>o1 : { a: number; b: number; }
const v2 = getStringIndexValue(o2);
>v2 : number
>getStringIndexValue(o2) : number
>getStringIndexValue : <T>(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 : <T>(map: { [x: string]: T; }) => T
>o1 : { a: string; b: string; }
const v2 = getStringIndexValue(o2);
>v2 : string
>getStringIndexValue(o2) : string
>getStringIndexValue : <T>(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 : <T>(map: { [x: string]: T; }) => T
>o1 : { a: number; b: string; }
const v2 = getStringIndexValue(o2);
>v2 : number | string
>getStringIndexValue(o2) : number | string
>getStringIndexValue : <T>(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 : <T>(map: { [x: string]: T; }) => T
>o1 : { 0: string; 1: string; count: number; }
const v2 = getStringIndexValue(o2);
>v2 : string | number
>getStringIndexValue(o2) : string | number
>getStringIndexValue : <T>(map: { [x: string]: T; }) => T
>o2 : { 0: string; 1: string; count: number; }
const v3 = getNumberIndexValue(o1);
>v3 : string
>getNumberIndexValue(o1) : string
>getNumberIndexValue : <T>(map: { [x: number]: T; }) => T
>o1 : { 0: string; 1: string; count: number; }
const v4 = getNumberIndexValue(o2);
>v4 : string
>getNumberIndexValue(o2) : string
>getNumberIndexValue : <T>(map: { [x: number]: T; }) => T
>o2 : { 0: string; 1: string; count: number; }
}
@@ -21,15 +21,15 @@ var x1 = foo({ 0: 0, 1: 1 }); // type should be number
>x1 : number
>foo({ 0: 0, 1: 1 }) : number
>foo : <T>(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 : <T>(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 : <T>(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 : <T>(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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -17,5 +17,5 @@ var directChildrenMap = <IDirectChildrenMap>{};
>directChildrenMap : IDirectChildrenMap
><IDirectChildrenMap>{} : IDirectChildrenMap
>IDirectChildrenMap : IDirectChildrenMap
>{} : { [x: number]: undefined; }
>{} : {}
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
@@ -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;
@@ -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))
@@ -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; }
@@ -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 : <T, U>(x: T, y: Int<T, U>, z: Int<U, T>) => 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
@@ -49,10 +49,10 @@ class ObjectField<A, T extends { [name: string]: Field<any> }> {
}
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
@@ -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; }
@@ -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'.
});
@@ -87,7 +87,7 @@ interface MyMap<T> {
var m: MyMap<number> = {
>m : MyMap<number>
>MyMap : MyMap<T>
>{ "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
@@ -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: () => { },
@@ -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(),
@@ -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; }'.
!!! error TS2322: Property 'one' is incompatible with index signature.
!!! error TS2322: Type 'number' is not assignable to type 'Foo'.

Some files were not shown because too many files have changed in this diff Show More