Merge branch 'master' into destructuring

Move downlevel vs. ES6 emit branching into individual emit functions
This commit is contained in:
Anders Hejlsberg
2014-12-08 14:42:38 -08:00
209 changed files with 5518 additions and 3480 deletions
+12 -5
View File
@@ -366,7 +366,7 @@ desc("Builds the test infrastructure using the built compiler");
task("tests", ["local", run].concat(libraryTargets));
function exec(cmd, completeHandler) {
var ex = jake.createExec([cmd]);
var ex = jake.createExec([cmd], {windowsVerbatimArguments: true});
// Add listeners for output and error
ex.addListener("stdout", function(output) {
process.stdout.write(output);
@@ -488,18 +488,25 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function(
exec(cmd);
}, {async: true});
function getDiffTool() {
var program = process.env['DIFF']
if (!program) {
fail("Add the 'DIFF' environment variable to the path of the program you want to use.")
}
return program;
}
// Baseline Diff
desc("Diffs the compiler baselines using the diff tool specified by the %DIFF% environment variable");
desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable");
task('diff', function () {
var cmd = "%DIFF% " + refBaseline + ' ' + localBaseline;
var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline;
console.log(cmd)
exec(cmd);
}, {async: true});
desc("Diffs the RWC baselines using the diff tool specified by the %DIFF% environment variable");
desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable");
task('diff-rwc', function () {
var cmd = "%DIFF% " + refRwcBaseline + ' ' + localRwcBaseline;
var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline;
console.log(cmd)
exec(cmd);
}, {async: true});
+6 -1
View File
@@ -423,7 +423,12 @@ module ts {
bindDeclaration(<Declaration>node, SymbolFlags.Signature, 0, /*isBlockScopeContainer*/ false);
break;
case SyntaxKind.Method:
bindDeclaration(<Declaration>node, SymbolFlags.Method | ((<MethodDeclaration>node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.MethodExcludes, /*isBlockScopeContainer*/ true);
// If this is an ObjectLiteralExpression method, then it sits in the same space
// as other properties in the object literal. So we use SymbolFlags.PropertyExcludes
// so that it will conflict with any other object literal members with the same
// name.
bindDeclaration(<Declaration>node, SymbolFlags.Method | ((<MethodDeclaration>node).questionToken ? SymbolFlags.Optional : 0),
isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes, /*isBlockScopeContainer*/ true);
break;
case SyntaxKind.FunctionDeclaration:
bindDeclaration(<Declaration>node, SymbolFlags.Function, SymbolFlags.FunctionExcludes, /*isBlockScopeContainer*/ true);
+186 -101
View File
@@ -85,8 +85,7 @@ module ts {
getDiagnostics,
getDeclarationDiagnostics,
getGlobalDiagnostics,
getParentOfSymbol,
getNarrowedTypeOfSymbol,
getTypeOfSymbolAtLocation,
getDeclaredTypeOfSymbol,
getPropertiesOfType,
getPropertyOfType,
@@ -94,9 +93,9 @@ module ts {
getIndexTypeOfType,
getReturnTypeOfSignature,
getSymbolsInScope,
getSymbolInfo,
getSymbolAtLocation,
getShorthandAssignmentValueSymbol,
getTypeOfNode,
getTypeAtLocation,
typeToString,
getSymbolDisplayBuilder,
symbolToString,
@@ -1004,7 +1003,7 @@ module ts {
var symbol = resolveName(enclosingDeclaration, (<Identifier>firstIdentifier).text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined);
// Verify if the symbol is accessible
return hasVisibleDeclarations(symbol) || <SymbolVisibilityResult>{
return (symbol && hasVisibleDeclarations(symbol)) || <SymbolVisibilityResult>{
accessibility: SymbolAccessibility.NotAccessible,
errorSymbolName: getTextOfNode(firstIdentifier),
errorNode: firstIdentifier
@@ -1024,10 +1023,6 @@ module ts {
writer.writePunctuation(tokenToString(kind));
}
function writeOperator(writer: SymbolWriter, kind: SyntaxKind) {
writer.writeOperator(tokenToString(kind));
}
function writeSpace(writer: SymbolWriter) {
writer.writeSpace(" ");
}
@@ -1303,6 +1298,17 @@ module ts {
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Value);
}
function getIndexerParameterName(type: ObjectType, indexKind: IndexKind, fallbackName: string): string {
var declaration = <SignatureDeclaration>getIndexDeclarationOfSymbol(type.symbol, indexKind);
if (!declaration) {
// declaration might not be found if indexer was added from the contextual type.
// in this case use fallback name
return fallbackName;
}
Debug.assert(declaration.parameters.length !== 0);
return declarationNameToString(declaration.parameters[0].name);
}
function writeLiteralType(type: ObjectType, flags: TypeFormatFlags) {
var resolved = resolveObjectOrUnionTypeMembers(type);
if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) {
@@ -1355,7 +1361,7 @@ module ts {
if (resolved.stringIndexType) {
// [x: string]:
writePunctuation(writer, SyntaxKind.OpenBracketToken);
writer.writeParameter("x");
writer.writeParameter(getIndexerParameterName(resolved, IndexKind.String, /*fallbackName*/"x"));
writePunctuation(writer, SyntaxKind.ColonToken);
writeSpace(writer);
writeKeyword(writer, SyntaxKind.StringKeyword);
@@ -1369,7 +1375,7 @@ module ts {
if (resolved.numberIndexType) {
// [x: number]:
writePunctuation(writer, SyntaxKind.OpenBracketToken);
writer.writeParameter("x");
writer.writeParameter(getIndexerParameterName(resolved, IndexKind.Number, /*fallbackName*/"x"));
writePunctuation(writer, SyntaxKind.ColonToken);
writeSpace(writer);
writeKeyword(writer, SyntaxKind.NumberKeyword);
@@ -2933,7 +2939,7 @@ module ts {
// The expression is processed as an identifier expression (section 4.3)
// or property access expression(section 4.10),
// the widened type(section 3.9) of which becomes the result.
links.resolvedType = getWidenedType(checkExpression(node.exprName));
links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName));
}
return links.resolvedType;
}
@@ -3334,26 +3340,35 @@ module ts {
// Returns true if the given expression contains (at any level of nesting) a function or arrow expression
// that is subject to contextual typing.
function isContextSensitiveExpression(node: Expression): boolean {
function isContextSensitive(node: Expression | MethodDeclaration | ObjectLiteralElement): boolean {
Debug.assert(node.kind !== SyntaxKind.Method || isObjectLiteralMethod(node));
switch (node.kind) {
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
return !(<FunctionExpression>node).typeParameters && !forEach((<FunctionExpression>node).parameters, p => p.type);
return isContextSensitiveFunctionLikeDeclaration(<FunctionExpression>node);
case SyntaxKind.ObjectLiteralExpression:
return forEach((<ObjectLiteralExpression>node).properties, p =>
p.kind === SyntaxKind.PropertyAssignment && isContextSensitiveExpression((<PropertyDeclaration>p).initializer));
return forEach((<ObjectLiteralExpression>node).properties, isContextSensitive);
case SyntaxKind.ArrayLiteralExpression:
return forEach((<ArrayLiteralExpression>node).elements, e => isContextSensitiveExpression(e));
return forEach((<ArrayLiteralExpression>node).elements, isContextSensitive);
case SyntaxKind.ConditionalExpression:
return isContextSensitiveExpression((<ConditionalExpression>node).whenTrue) ||
isContextSensitiveExpression((<ConditionalExpression>node).whenFalse);
return isContextSensitive((<ConditionalExpression>node).whenTrue) ||
isContextSensitive((<ConditionalExpression>node).whenFalse);
case SyntaxKind.BinaryExpression:
return (<BinaryExpression>node).operator === SyntaxKind.BarBarToken &&
(isContextSensitiveExpression((<BinaryExpression>node).left) || isContextSensitiveExpression((<BinaryExpression>node).right));
(isContextSensitive((<BinaryExpression>node).left) || isContextSensitive((<BinaryExpression>node).right));
case SyntaxKind.PropertyAssignment:
return isContextSensitive((<PropertyAssignment>node).initializer);
case SyntaxKind.Method:
return isContextSensitiveFunctionLikeDeclaration(<MethodDeclaration>node);
}
return false;
}
function isContextSensitiveFunctionLikeDeclaration(node: FunctionLikeDeclaration) {
return !node.typeParameters && !forEach(node.parameters, p => p.type);
}
function getTypeWithoutConstructors(type: Type): Type {
if (type.flags & TypeFlags.ObjectType) {
var resolved = resolveObjectOrUnionTypeMembers(<ObjectType>type);
@@ -4555,6 +4570,47 @@ module ts {
}
}
function resolveLocation(node: Node) {
// Resolve location from top down towards node if it is a context sensitive expression
// That helps in making sure not assigning types as any when resolved out of order
var containerNodes: Node[] = [];
for (var parent = node.parent; parent; parent = parent.parent) {
if ((isExpression(parent) || isObjectLiteralMethod(node)) &&
isContextSensitive(<Expression>parent)) {
containerNodes.unshift(parent);
}
}
ts.forEach(containerNodes, node => { getTypeOfNode(node); });
}
function getSymbolAtLocation(node: Node): Symbol {
resolveLocation(node);
return getSymbolInfo(node);
}
function getTypeAtLocation(node: Node): Type {
resolveLocation(node);
return getTypeOfNode(node);
}
function getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type {
resolveLocation(node);
// Get the narrowed type of symbol at given location instead of just getting
// the type of the symbol.
// eg.
// function foo(a: string | number) {
// if (typeof a === "string") {
// a/**/
// }
// }
// getTypeOfSymbol for a would return type of parameter symbol string | number
// Unless we provide location /**/, checker wouldn't know how to narrow the type
// By using getNarrowedTypeOfSymbol would return string since it would be able to narrow
// it by typeguard in the if true condition
return getNarrowedTypeOfSymbol(symbol, node);
}
// Get the narrowed type of a given symbol at a given location
function getNarrowedTypeOfSymbol(symbol: Symbol, node: Node) {
var type = getTypeOfSymbol(symbol);
@@ -4918,7 +4974,7 @@ module ts {
function getContextuallyTypedParameterType(parameter: ParameterDeclaration): Type {
if (isFunctionExpressionOrArrowFunction(parameter.parent)) {
var func = <FunctionExpression>parameter.parent;
if (isContextSensitiveExpression(func)) {
if (isContextSensitive(func)) {
var contextualSignature = getContextualSignature(func);
if (contextualSignature) {
@@ -5065,12 +5121,21 @@ module ts {
// 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.
function getContextualTypeForPropertyExpression(node: Expression): Type {
var declaration = <PropertyDeclaration>node.parent;
var objectLiteral = <ObjectLiteralExpression>declaration.parent;
function getContextualTypeForObjectLiteralMethod(node: MethodDeclaration): Type {
Debug.assert(isObjectLiteralMethod(node));
if (isInsideWithStatementBody(node)) {
// We cannot answer semantic questions within a with block, do not proceed any further
return undefined;
}
return getContextualTypeForObjectLiteralElement(node);
}
function getContextualTypeForObjectLiteralElement(element: ObjectLiteralElement) {
var objectLiteral = <ObjectLiteralExpression>element.parent;
var type = getContextualType(objectLiteral);
// TODO(jfreeman): Handle this case for computed names and symbols
var name = (<Identifier>declaration.name).text;
var name = (<Identifier>element.name).text;
if (type && name) {
return getTypeOfPropertyOfContextualType(type, name) ||
isNumericName(name) && getIndexTypeOfContextualType(type, IndexKind.Number) ||
@@ -5126,7 +5191,7 @@ module ts {
case SyntaxKind.BinaryExpression:
return getContextualTypeForBinaryOperand(node);
case SyntaxKind.PropertyAssignment:
return getContextualTypeForPropertyExpression(node);
return getContextualTypeForObjectLiteralElement(<ObjectLiteralElement>parent);
case SyntaxKind.ArrayLiteralExpression:
return getContextualTypeForElementExpression(node);
case SyntaxKind.ConditionalExpression:
@@ -5161,8 +5226,11 @@ module ts {
// If the contextual type is a union type, get the signature from each type possible and if they are
// all identical ignoring their return type, the result is same signature but with return type as
// union type of return types from these signatures
function getContextualSignature(node: FunctionExpression): Signature {
var type = getContextualType(node);
function getContextualSignature(node: FunctionExpression | MethodDeclaration): Signature {
Debug.assert(node.kind !== SyntaxKind.Method || isObjectLiteralMethod(node));
var type = isObjectLiteralMethod(node)
? getContextualTypeForObjectLiteralMethod(<MethodDeclaration>node)
: getContextualType(<FunctionExpression>node);
if (!type) {
return undefined;
}
@@ -5276,16 +5344,17 @@ module ts {
for (var id in members) {
if (hasProperty(members, id)) {
var member = members[id];
if (member.flags & SymbolFlags.Property) {
// TODO(andersh): Use PropertyAssignment for both
// var type = checkExpression((<PropertyDeclaration>member.declarations[0]).initializer, contextualMapper);
var memberDecl = <PropertyDeclaration>member.declarations[0];
if (member.flags & SymbolFlags.Property || isObjectLiteralMethod(member.declarations[0])) {
var memberDecl = <ObjectLiteralElement>member.declarations[0];
if (memberDecl.kind === SyntaxKind.PropertyAssignment) {
var type = checkExpression(memberDecl.initializer, contextualMapper);
var type = checkExpression((<PropertyAssignment>memberDecl).initializer, contextualMapper);
}
else if (memberDecl.kind === SyntaxKind.Method) {
var type = checkObjectLiteralMethod(<MethodDeclaration>memberDecl, contextualMapper);
}
else {
Debug.assert(memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment);
type = memberDecl.name.kind === SyntaxKind.ComputedPropertyName
var type = memberDecl.name.kind === SyntaxKind.ComputedPropertyName
? unknownType
: checkExpression(<Identifier>memberDecl.name, contextualMapper);
}
@@ -5293,7 +5362,10 @@ module ts {
var prop = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name);
prop.declarations = member.declarations;
prop.parent = member.parent;
if (member.valueDeclaration) prop.valueDeclaration = member.valueDeclaration;
if (member.valueDeclaration) {
prop.valueDeclaration = member.valueDeclaration;
}
prop.type = type;
prop.target = member;
member = prop;
@@ -5399,7 +5471,7 @@ module ts {
}
function checkPropertyAccessExpressionOrQualifiedName(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, right: Identifier) {
var type = checkExpression(left);
var type = checkExpressionOrQualifiedName(left);
if (type === unknownType) return type;
if (type !== anyType) {
var apparentType = getApparentType(getWidenedType(type));
@@ -5440,7 +5512,7 @@ module ts {
? (<PropertyAccessExpression>node).expression
: (<QualifiedName>node).left;
var type = checkExpression(left);
var type = checkExpressionOrQualifiedName(left);
if (type !== unknownType && type !== anyType) {
var prop = getPropertyOfType(getWidenedType(type), propertyName);
if (prop && prop.parent && prop.parent.flags & SymbolFlags.Class) {
@@ -5796,7 +5868,7 @@ module ts {
// because it represents a TemplateStringsArray.
var excludeArgument: boolean[];
for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) {
if (isContextSensitiveExpression(args[i])) {
if (isContextSensitive(args[i])) {
if (!excludeArgument) {
excludeArgument = new Array(args.length);
}
@@ -6219,7 +6291,7 @@ module ts {
function getReturnTypeFromBody(func: FunctionLikeDeclaration, contextualMapper?: TypeMapper): Type {
var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
if (func.body.kind !== SyntaxKind.FunctionBlock) {
if (func.body.kind !== SyntaxKind.Block) {
var type = checkExpressionCached(<Expression>func.body, contextualMapper);
}
else {
@@ -6284,7 +6356,7 @@ module ts {
}
// If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check.
if (!func.body || func.body.kind !== SyntaxKind.FunctionBlock) {
if (!func.body || func.body.kind !== SyntaxKind.Block) {
return;
}
@@ -6306,7 +6378,9 @@ module ts {
error(func.type, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement);
}
function checkFunctionExpression(node: FunctionExpression, contextualMapper?: TypeMapper): Type {
function checkFunctionExpressionOrObjectLiteralMethod(node: FunctionExpression | MethodDeclaration, contextualMapper?: TypeMapper): Type {
Debug.assert(node.kind !== SyntaxKind.Method || isObjectLiteralMethod(node));
// The identityMapper object is used to indicate that function expressions are wildcards
if (contextualMapper === identityMapper) {
return anyFunctionType;
@@ -6323,7 +6397,7 @@ module ts {
links.flags |= NodeCheckFlags.ContextChecked;
if (contextualSignature) {
var signature = getSignaturesOfType(type, SignatureKind.Call)[0];
if (isContextSensitiveExpression(node)) {
if (isContextSensitive(node)) {
assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper);
}
if (!node.type) {
@@ -6338,27 +6412,31 @@ module ts {
}
}
if (fullTypeCheck) {
checkCollisionWithCapturedSuperVariable(node, node.name);
checkCollisionWithCapturedThisVariable(node, node.name);
if (fullTypeCheck && node.kind !== SyntaxKind.Method) {
checkCollisionWithCapturedSuperVariable(node, (<FunctionExpression>node).name);
checkCollisionWithCapturedThisVariable(node,(<FunctionExpression>node).name);
}
return type;
}
function checkFunctionExpressionBody(node: FunctionExpression) {
function checkFunctionExpressionOrObjectLiteralMethodBody(node: FunctionExpression | MethodDeclaration) {
Debug.assert(node.kind !== SyntaxKind.Method || isObjectLiteralMethod(node));
if (node.type) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
}
if (node.body.kind === SyntaxKind.FunctionBlock) {
checkSourceElement(node.body);
}
else {
var exprType = checkExpression(<Expression>node.body);
if (node.type) {
checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, /*headMessage*/ undefined);
if (node.body) {
if (node.body.kind === SyntaxKind.Block) {
checkSourceElement(node.body);
}
else {
var exprType = checkExpression(<Expression>node.body);
if (node.type) {
checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, /*headMessage*/ undefined);
}
checkFunctionExpressionBodies(node.body);
}
checkFunctionExpressionBodies(node.body);
}
}
@@ -6545,13 +6623,13 @@ module ts {
var p = properties[i];
if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) {
// TODO(andersh): Computed property support
var name = <Identifier>(<PropertyDeclaration>p).name;
var name = <Identifier>(<PropertyAssignment>p).name;
var type = sourceType.flags & TypeFlags.Any ? sourceType :
getTypeOfPropertyOfType(sourceType, name.text) ||
isNumericName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) ||
getIndexTypeOfType(sourceType, IndexKind.String);
if (type) {
checkDestructuringAssignment((<PropertyDeclaration>p).initializer || name, type);
checkDestructuringAssignment((<PropertyAssignment>p).initializer || name, type);
}
else {
error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), declarationNameToString(name));
@@ -6798,6 +6876,32 @@ module ts {
return links.resolvedType;
}
function checkObjectLiteralMethod(node: MethodDeclaration, contextualMapper?: TypeMapper): Type {
var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper);
return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper);
}
function instantiateTypeWithSingleGenericCallSignature(node: Expression | MethodDeclaration, type: Type, contextualMapper?: TypeMapper) {
if (contextualMapper && contextualMapper !== identityMapper) {
var signature = getSingleCallSignature(type);
if (signature && signature.typeParameters) {
var contextualType = getContextualType(<Expression>node);
if (contextualType) {
var contextualSignature = getSingleCallSignature(contextualType);
if (contextualSignature && !contextualSignature.typeParameters) {
return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
}
}
}
}
return type;
}
function checkExpression(node: Expression, contextualMapper?: TypeMapper): Type {
return checkExpressionOrQualifiedName(node, contextualMapper);
}
// Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When
// contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the
// expression is being inferentially typed (section 4.12.2 in spec) and provides the type mapper to use in
@@ -6805,19 +6909,14 @@ module ts {
// object, it serves as an indicator that all contained function and arrow expressions should be considered to
// have the wildcard function type; this form of type check is used during overload resolution to exclude
// contextually typed function and arrow expressions in the initial phase.
function checkExpression(node: Expression | QualifiedName, contextualMapper?: TypeMapper): Type {
var type = checkExpressionNode(node, contextualMapper);
if (contextualMapper && contextualMapper !== identityMapper && node.kind !== SyntaxKind.QualifiedName) {
var signature = getSingleCallSignature(type);
if (signature && signature.typeParameters) {
var contextualType = getContextualType(<Expression>node);
if (contextualType) {
var contextualSignature = getSingleCallSignature(contextualType);
if (contextualSignature && !contextualSignature.typeParameters) {
type = getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper));
}
}
}
function checkExpressionOrQualifiedName(node: Expression | QualifiedName, contextualMapper?: TypeMapper): Type {
var type: Type;
if (node.kind == SyntaxKind.QualifiedName) {
type = checkQualifiedName(<QualifiedName>node);
}
else {
var uninstantiatedType = checkExpressionWorker(<Expression>node, contextualMapper);
type = instantiateTypeWithSingleGenericCallSignature(<Expression>node, uninstantiatedType, contextualMapper);
}
if (isConstEnumObjectType(type)) {
@@ -6837,7 +6936,7 @@ module ts {
return type;
}
function checkExpressionNode(node: Expression | QualifiedName, contextualMapper: TypeMapper): Type {
function checkExpressionWorker(node: Expression, contextualMapper: TypeMapper): Type {
switch (node.kind) {
case SyntaxKind.Identifier:
return checkIdentifier(<Identifier>node);
@@ -6859,8 +6958,6 @@ module ts {
return stringType;
case SyntaxKind.RegularExpressionLiteral:
return globalRegExpType;
case SyntaxKind.QualifiedName:
return checkQualifiedName(<QualifiedName>node);
case SyntaxKind.ArrayLiteralExpression:
return checkArrayLiteral(<ArrayLiteralExpression>node, contextualMapper);
case SyntaxKind.ObjectLiteralExpression:
@@ -6880,7 +6977,7 @@ module ts {
return checkExpression((<ParenthesizedExpression>node).expression);
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
return checkFunctionExpression(<FunctionExpression>node, contextualMapper);
return checkFunctionExpressionOrObjectLiteralMethod(<FunctionExpression>node, contextualMapper);
case SyntaxKind.TypeOfExpression:
return checkTypeOfExpression(<TypeOfExpression>node);
case SyntaxKind.DeleteExpression:
@@ -7554,6 +7651,9 @@ module ts {
function checkBlock(node: Block) {
forEach(node.statements, checkSourceElement);
if (isFunctionBlock(node) || node.kind === SyntaxKind.ModuleBlock) {
checkFunctionExpressionBodies(node);
}
}
function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) {
@@ -7922,7 +8022,9 @@ module ts {
}
function checkThrowStatement(node: ThrowStatement) {
checkExpression(node.expression);
if (node.expression) {
checkExpression(node.expression);
}
}
function checkTryStatement(node: TryStatement) {
@@ -8061,7 +8163,7 @@ module ts {
}
// Check that base type can be evaluated as expression
checkExpression(baseTypeNode.typeName);
checkExpressionOrQualifiedName(baseTypeNode.typeName);
}
var implementedTypeNodes = getClassImplementedTypeNodes(node);
@@ -8550,7 +8652,7 @@ module ts {
// ensure it can be evaluated as an expression
var moduleName = getFirstIdentifier(<EntityName>node.moduleReference);
if (resolveEntityName(node, moduleName, SymbolFlags.Value | SymbolFlags.Namespace).flags & SymbolFlags.Namespace) {
checkExpression(<EntityName>node.moduleReference);
checkExpressionOrQualifiedName(<EntityName>node.moduleReference);
}
else {
error(moduleName, Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, declarationNameToString(moduleName));
@@ -8648,10 +8750,8 @@ module ts {
case SyntaxKind.FunctionDeclaration:
return checkFunctionDeclaration(<FunctionDeclaration>node);
case SyntaxKind.Block:
return checkBlock(<Block>node);
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
return checkBody(<Block>node);
return checkBlock(<Block>node);
case SyntaxKind.VariableStatement:
return checkVariableStatement(<VariableStatement>node);
case SyntaxKind.ExpressionStatement:
@@ -8715,9 +8815,14 @@ module ts {
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
forEach((<FunctionLikeDeclaration>node).parameters, checkFunctionExpressionBodies);
checkFunctionExpressionBody(<FunctionExpression>node);
checkFunctionExpressionOrObjectLiteralMethodBody(<FunctionExpression>node);
break;
case SyntaxKind.Method:
forEach((<MethodDeclaration>node).parameters, checkFunctionExpressionBodies);
if (isObjectLiteralMethod(node)) {
checkFunctionExpressionOrObjectLiteralMethodBody(<MethodDeclaration>node);
}
break;
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
@@ -8750,7 +8855,6 @@ module ts {
case SyntaxKind.BinaryExpression:
case SyntaxKind.ConditionalExpression:
case SyntaxKind.Block:
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
case SyntaxKind.VariableStatement:
case SyntaxKind.ExpressionStatement:
@@ -8781,11 +8885,6 @@ module ts {
}
}
function checkBody(node: Block) {
checkBlock(node);
checkFunctionExpressionBodies(node);
}
// Fully type check a source file and collect the relevant diagnostics.
function checkSourceFile(node: SourceFile) {
var links = getNodeLinks(node);
@@ -8849,20 +8948,6 @@ module ts {
// Language service support
function getNodeAtPosition(sourceFile: SourceFile, position: number): Node {
function findChildAtPosition(parent: Node): Node {
var child = forEachChild(parent, node => {
if (position >= node.pos && position <= node.end && position >= getTokenPosOfNode(node)) {
return findChildAtPosition(node);
}
});
return child || parent;
}
if (position < sourceFile.pos) position = sourceFile.pos;
if (position > sourceFile.end) position = sourceFile.end;
return findChildAtPosition(sourceFile);
}
function isInsideWithStatementBody(node: Node): boolean {
if (node) {
while (node.parent) {
@@ -9183,7 +9268,7 @@ module ts {
// This is necessary as an identifier in short-hand property assignment can contains two meaning:
// property name and property value.
if (location && location.kind === SyntaxKind.ShorthandPropertyAssignment) {
return resolveEntityName(location, (<ShorthandPropertyDeclaration>location).name, SymbolFlags.Value);
return resolveEntityName(location, (<ShorthandPropertyAssignment>location).name, SymbolFlags.Value);
}
return undefined;
}
+4 -4
View File
@@ -28,15 +28,15 @@ module ts {
export interface StringSet extends Map<any> { }
export function forEach<T, U>(array: T[], callback: (element: T) => U): U {
var result: U;
if (array) {
for (var i = 0, len = array.length; i < len; i++) {
if (result = callback(array[i])) {
break;
var result = callback(array[i]);
if (result) {
return result;
}
}
}
return result;
return undefined;
}
export function contains<T>(array: T[], value: T): boolean {
+34 -45
View File
@@ -2,6 +2,7 @@
/// <reference path="core.ts"/>
/// <reference path="scanner.ts"/>
/// <reference path="parser.ts"/>
/// <reference path="binder.ts"/>
module ts {
interface EmitTextWriter {
@@ -2281,7 +2282,20 @@ module ts {
emit(node.expression);
write("]");
}
function emitMethod(node: MethodDeclaration) {
if (!isObjectLiteralMethod(node)) {
return;
}
emitLeadingComments(node);
emit(node.name);
if (compilerOptions.target < ScriptTarget.ES6) {
write(": function ");
}
emitSignatureAndBody(node);
emitTrailingComments(node);
}
function emitPropertyAssignment(node: PropertyDeclaration) {
emitLeadingComments(node);
emit(node.name);
@@ -2290,18 +2304,9 @@ module ts {
emitTrailingComments(node);
}
function emitDownlevelShorthandPropertyAssignment(node: ShorthandPropertyDeclaration) {
function emitShorthandPropertyAssignment(node: ShorthandPropertyAssignment) {
emitLeadingComments(node);
// Emit identifier as an identifier
emit(node.name);
write(": ");
// Even though this is stored as identifier treat it as an expression
// Short-hand, { x }, is equivalent of normal form { x: x }
emitExpressionIdentifier(node.name);
emitTrailingComments(node);
}
function emitShorthandPropertyAssignment(node: ShorthandPropertyDeclaration) {
// If short-hand property has a prefix, then regardless of the target version, we will emit it as normal property assignment. For example:
// module m {
// export var y;
@@ -2310,16 +2315,14 @@ module ts {
// export var obj = { y };
// }
// The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version
var prefix = resolver.getExpressionNamePrefix(node.name);
if (prefix) {
emitDownlevelShorthandPropertyAssignment(node);
}
// If short-hand property has no prefix, emit it as short-hand.
else {
emitLeadingComments(node);
emit(node.name);
emitTrailingComments(node);
if (compilerOptions.target < ScriptTarget.ES6 || resolver.getExpressionNamePrefix(node.name)) {
// Emit identifier as an identifier
write(": ");
// Even though this is stored as identifier treat it as an expression
// Short-hand, { x }, is equivalent of normal form { x: x }
emitExpressionIdentifier(node.name);
}
emitTrailingComments(node);
}
function tryEmitConstantValue(node: PropertyAccessExpression | ElementAccessExpression): boolean {
@@ -2868,8 +2871,8 @@ module ts {
var p = properties[i];
if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) {
// TODO(andersh): Computed property support
var propName = <Identifier>((<PropertyDeclaration>p).name);
emitDestructuringAssignment((<PropertyDeclaration>p).initializer || propName, createPropertyAccess(value, propName));
var propName = <Identifier>((<PropertyAssignment>p).name);
emitDestructuringAssignment((<PropertyAssignment>p).initializer || propName, createPropertyAccess(value, propName));
}
}
}
@@ -3139,17 +3142,17 @@ module ts {
scopeEmitStart(node);
increaseIndent();
emitDetachedComments(node.body.kind === SyntaxKind.FunctionBlock ? (<Block>node.body).statements : node.body);
emitDetachedComments(node.body.kind === SyntaxKind.Block ? (<Block>node.body).statements : node.body);
var startIndex = 0;
if (node.body.kind === SyntaxKind.FunctionBlock) {
if (node.body.kind === SyntaxKind.Block) {
startIndex = emitDirectivePrologues((<Block>node.body).statements, /*startWithNewLine*/ true);
}
var outPos = writer.getTextPos();
emitCaptureThisForNodeIfNecessary(node);
emitDefaultValueAssignments(node);
emitRestParameter(node);
if (node.body.kind !== SyntaxKind.FunctionBlock && outPos === writer.getTextPos()) {
if (node.body.kind !== SyntaxKind.Block && outPos === writer.getTextPos()) {
decreaseIndent();
write(" ");
emitStart(node.body);
@@ -3164,7 +3167,7 @@ module ts {
emitEnd(node.body);
}
else {
if (node.body.kind === SyntaxKind.FunctionBlock) {
if (node.body.kind === SyntaxKind.Block) {
emitLinesStartingAt((<Block>node.body).statements, startIndex);
}
else {
@@ -3177,7 +3180,7 @@ module ts {
}
emitTempDeclarations(/*newLine*/ true);
writeLine();
if (node.body.kind === SyntaxKind.FunctionBlock) {
if (node.body.kind === SyntaxKind.Block) {
emitLeadingCommentsOfPosition((<Block>node.body).statements.end);
decreaseIndent();
emitToken(SyntaxKind.CloseBraceToken,(<Block>node.body).statements.end);
@@ -3812,6 +3815,8 @@ module ts {
return emitIdentifier(<Identifier>node);
case SyntaxKind.Parameter:
return emitParameter(<ParameterDeclaration>node);
case SyntaxKind.Method:
return emitMethod(<MethodDeclaration>node);
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return emitAccessor(<AccessorDeclaration>node);
@@ -3849,6 +3854,8 @@ module ts {
return emitObjectLiteral(<ObjectLiteralExpression>node);
case SyntaxKind.PropertyAssignment:
return emitPropertyAssignment(<PropertyDeclaration>node);
case SyntaxKind.ShorthandPropertyAssignment:
return emitShorthandPropertyAssignment(<ShorthandPropertyAssignment>node);
case SyntaxKind.ComputedPropertyName:
return emitComputedPropertyName(<ComputedPropertyName>node);
case SyntaxKind.PropertyAccessExpression:
@@ -3888,7 +3895,6 @@ module ts {
case SyntaxKind.Block:
case SyntaxKind.TryBlock:
case SyntaxKind.FinallyBlock:
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
return emitBlock(<Block>node);
case SyntaxKind.VariableStatement:
@@ -3944,23 +3950,6 @@ module ts {
case SyntaxKind.SourceFile:
return emitSourceFile(<SourceFile>node);
}
// Emit node which needs to be emitted differently depended on ScriptTarget
if (compilerOptions.target < ScriptTarget.ES6) {
// Emit node down-level
switch (node.kind) {
case SyntaxKind.ShorthandPropertyAssignment:
return emitDownlevelShorthandPropertyAssignment(<ShorthandPropertyDeclaration>node);
}
}
else {
// Emit node natively
Debug.assert(compilerOptions.target >= ScriptTarget.ES6, "Invalid ScriptTarget. We should emit as ES6 or above");
switch (node.kind) {
case SyntaxKind.ShorthandPropertyAssignment:
return emitShorthandPropertyAssignment(<ShorthandPropertyDeclaration>node);
}
}
}
function hasDetachedComments(pos: number) {
+334 -230
View File
File diff suppressed because it is too large Load Diff
+24 -10
View File
@@ -29,6 +29,15 @@ module ts {
scan(): SyntaxKind;
setText(text: string): void;
setTextPos(textPos: number): void;
// Invokes the provided callback then unconditionally restores the scanner to the state it
// was in immediately prior to invoking the callback. The result of invoking the callback
// is returned from this function.
lookAhead<T>(callback: () => T): T;
// Invokes the provided callback. If the callback returns something falsy, then it restores
// the scanner to the state it was in immediately prior to invoking the callback. If the
// callback returns something truthy, then the scanner state is not rolled back. The result
// of invoking the callback is returned from this function.
tryScan<T>(callback: () => T): T;
}
@@ -463,7 +472,7 @@ module ts {
ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion);
}
export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback, onComment?: CommentCallback): Scanner {
export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback): Scanner {
var pos: number; // Current position (end position of text of current token)
var len: number; // Length of text
var startPos: number; // Start position of whitespace before current token
@@ -899,9 +908,6 @@ module ts {
pos++;
}
if (onComment) {
onComment(tokenPos, pos);
}
if (skipTrivia) {
continue;
@@ -934,10 +940,6 @@ module ts {
error(Diagnostics.Asterisk_Slash_expected);
}
if (onComment) {
onComment(tokenPos, pos);
}
if (skipTrivia) {
continue;
}
@@ -1174,7 +1176,7 @@ module ts {
return token = scanTemplateAndSetTokenValue();
}
function tryScan<T>(callback: () => T): T {
function speculationHelper<T>(callback: () => T, isLookahead: boolean): T {
var savePos = pos;
var saveStartPos = startPos;
var saveTokenPos = tokenPos;
@@ -1182,7 +1184,10 @@ module ts {
var saveTokenValue = tokenValue;
var savePrecedingLineBreak = precedingLineBreak;
var result = callback();
if (!result) {
// If our callback returned something 'falsy' or we're just looking ahead,
// then unconditionally restore us to where we were.
if (!result || isLookahead) {
pos = savePos;
startPos = saveStartPos;
tokenPos = saveTokenPos;
@@ -1193,6 +1198,14 @@ module ts {
return result;
}
function lookAhead<T>(callback: () => T): T {
return speculationHelper(callback, /*isLookahead:*/ true);
}
function tryScan<T>(callback: () => T): T {
return speculationHelper(callback, /*isLookahead:*/ false);
}
function setText(newText: string) {
text = newText || "";
len = text.length;
@@ -1228,6 +1241,7 @@ module ts {
setText,
setTextPos,
tryScan,
lookAhead,
};
}
}
+59 -23
View File
@@ -216,7 +216,6 @@ module ts {
DebuggerStatement,
VariableDeclaration,
FunctionDeclaration,
FunctionBlock,
ClassDeclaration,
InterfaceDeclaration,
TypeAliasDeclaration,
@@ -238,6 +237,7 @@ module ts {
// Property assignments
PropertyAssignment,
ShorthandPropertyAssignment,
// Enum
EnumMember,
// Top-level nodes
@@ -298,10 +298,27 @@ module ts {
export const enum ParserContextFlags {
// Set if this node was parsed in strict mode. Used for grammar error checks, as well as
// checking if the node can be reused in incremental settings.
StrictMode = 1 << 0,
DisallowIn = 1 << 1,
Yield = 1 << 2,
GeneratorParameter = 1 << 3,
StrictMode = 1 << 0,
// If this node was parsed in a context where 'in-expressions' are not allowed.
DisallowIn = 1 << 1,
// If this node was parsed in the 'yield' context created when parsing a generator.
Yield = 1 << 2,
// If this node was parsed in the parameters of a generator.
GeneratorParameter = 1 << 3,
// If the parser encountered an error when parsing the code that created this node. Note
// the parser only sets this directly on the node it creates right after encountering the
// error. We then propagate that flag upwards to parent nodes during incremental parsing.
ContainsError = 1 << 4,
// Used during incremental parsing to determine if we need to visit this node to see if
// any of its children had an error. Once we compute that once, we can set this bit on the
// node to know that we never have to do it again. From that point on, we can just check
// the node directly for 'ContainsError'.
HasPropagatedChildContainsErrorFlag = 1 << 5
}
export interface Node extends TextRange {
@@ -339,12 +356,6 @@ module ts {
export type EntityName = Identifier | QualifiedName;
export interface ParsedSignature {
typeParameters?: NodeArray<TypeParameterDeclaration>;
parameters: NodeArray<ParameterDeclaration>;
type?: TypeNode;
}
export type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern;
export interface Declaration extends Node {
@@ -364,7 +375,10 @@ module ts {
expression?: Expression;
}
export interface SignatureDeclaration extends Declaration, ParsedSignature {
export interface SignatureDeclaration extends Declaration {
typeParameters?: NodeArray<TypeParameterDeclaration>;
parameters: NodeArray<ParameterDeclaration>;
type?: TypeNode;
}
// SyntaxKind.VariableDeclaration
@@ -392,7 +406,6 @@ module ts {
}
// SyntaxKind.Property
// SyntaxKind.PropertyAssignment
export interface PropertyDeclaration extends Declaration, ClassElement {
name: DeclarationName; // Declared property name
questionToken?: Node; // Present on optional property
@@ -400,8 +413,20 @@ module ts {
initializer?: Expression; // Optional initializer
}
export interface ObjectLiteralElement extends Declaration {
_objectLiteralBrandBrand: any;
}
// SyntaxKind.PropertyAssignment
export interface PropertyAssignment extends ObjectLiteralElement {
_propertyAssignmentBrand: any;
name: DeclarationName;
questionToken?: Node;
initializer: Expression;
}
// SyntaxKind.ShorthandPropertyAssignment
export interface ShorthandPropertyDeclaration extends Declaration {
export interface ShorthandPropertyAssignment extends ObjectLiteralElement {
name: Identifier;
questionToken?: Node;
}
@@ -447,7 +472,16 @@ module ts {
body?: Block;
}
export interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement {
// Note that a MethodDeclaration is considered both a ClassElement and an ObjectLiteralElement.
// Both the grammars for ClassDeclaration and ObjectLiteralExpression allow for MethodDeclarations
// as child elements, and so a MethodDeclaration satisfies both interfaces. This avoids the
// alternative where we would need separate kinds/types for ClassMethodDeclaration and
// ObjectLiteralMethodDeclaration, which would look identical.
//
// Because of this, it may be necessary to determine what sort of MethodDeclaration you have
// at later stages of the compiler pipeline. In that case, you can either check the parent kind
// of the method, or use helpers like isObjectLiteralMethodDeclaration
export interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
body?: Block;
}
@@ -455,8 +489,11 @@ module ts {
body?: Block;
}
export interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement {
body?: Block;
// See the comment on MethodDeclaration for the intuition behind AccessorDeclaration being a
// ClassElement and an ObjectLiteralElement.
export interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
_accessorDeclarationBrand: any;
body: Block;
}
export interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement {
@@ -613,7 +650,7 @@ module ts {
// An ObjectLiteralExpression is the declaration node for an anonymous symbol.
export interface ObjectLiteralExpression extends PrimaryExpression, Declaration {
properties: NodeArray<Declaration>;
properties: NodeArray<ObjectLiteralElement>;
}
export interface PropertyAccessExpression extends MemberExpression {
@@ -920,8 +957,7 @@ module ts {
getSymbolCount(): number;
getTypeCount(): number;
emitFiles(targetSourceFile?: SourceFile): EmitResult;
getParentOfSymbol(symbol: Symbol): Symbol;
getNarrowedTypeOfSymbol(symbol: Symbol, node: Node): Type;
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
getPropertiesOfType(type: Type): Symbol[];
getPropertyOfType(type: Type, propertyName: string): Symbol;
@@ -929,16 +965,16 @@ module ts {
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
getReturnTypeOfSignature(signature: Signature): Type;
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
getSymbolInfo(node: Node): Symbol;
getSymbolAtLocation(node: Node): Symbol;
getShorthandAssignmentValueSymbol(location: Node): Symbol;
getTypeOfNode(node: Node): Type;
getTypeAtLocation(node: Node): Type;
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
getSymbolDisplayBuilder(): SymbolDisplayBuilder;
getFullyQualifiedName(symbol: Symbol): string;
getAugmentedPropertiesOfType(type: Type): Symbol[];
getRootSymbols(symbol: Symbol): Symbol[];
getContextualType(node: Node): Type;
getContextualType(node: Expression): Type;
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature;
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature;
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
+34 -1
View File
@@ -769,7 +769,7 @@ module FourSlash {
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
}
public verifyQuickInfo(negative: boolean, expectedText?: string, expectedDocumentation?: string) {
public verifyQuickInfoString(negative: boolean, expectedText?: string, expectedDocumentation?: string) {
[expectedText, expectedDocumentation].forEach(str => {
if (str) {
this.scenarioActions.push('<ShowQuickInfo />');
@@ -798,6 +798,39 @@ module FourSlash {
}
}
public verifyQuickInfoDisplayParts(kind: string, kindModifiers: string, textSpan: { start: number; length: number; },
displayParts: ts.SymbolDisplayPart[],
documentation: ts.SymbolDisplayPart[]) {
this.scenarioActions.push('<ShowQuickInfo />');
this.scenarioActions.push('<Verify return values of quickInfo="' + JSON.stringify(displayParts) + '"/>');
function getDisplayPartsJson(displayParts: ts.SymbolDisplayPart[]) {
var result = "";
ts.forEach(displayParts, part => {
if (result) {
result += ",\n ";
}
else {
result = "[\n ";
}
result += JSON.stringify(part);
});
if (result) {
result += "\n]";
}
return result;
}
var actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition);
assert.equal(actualQuickInfo.kind, kind, this.messageAtLastKnownMarker("QuickInfo kind"));
assert.equal(actualQuickInfo.kindModifiers, kindModifiers, this.messageAtLastKnownMarker("QuickInfo kindModifiers"));
assert.equal(JSON.stringify(actualQuickInfo.textSpan), JSON.stringify(textSpan), this.messageAtLastKnownMarker("QuickInfo textSpan"));
assert.equal(getDisplayPartsJson(actualQuickInfo.displayParts), getDisplayPartsJson(displayParts), this.messageAtLastKnownMarker("QuickInfo displayParts"));
assert.equal(getDisplayPartsJson(actualQuickInfo.documentation), getDisplayPartsJson(documentation), this.messageAtLastKnownMarker("QuickInfo documentation"));
}
public verifyRenameLocations(findInStrings: boolean, findInComments: boolean) {
var renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition);
if (renameInfo.canRename) {
+36 -1
View File
@@ -26,6 +26,30 @@ class Test262BaselineRunner extends RunnerBase {
return (<any>ts).SyntaxKind[k]
}
function getFlagName(flags: any, f: number): any {
if (f === 0) return 0;
var result = "";
ts.forEach(Object.getOwnPropertyNames(flags),(v: any) => {
if (isFinite(v)) {
v = +v;
if (f === +v) {
result = flags[v];
return true;
}
else if ((f & v) > 0) {
if (result.length)
result += " | ";
result += flags[v];
return false;
}
}
});
return result;
}
function getNodeFlagName(f: number) { return getFlagName((<any>ts).NodeFlags, f); }
function getParserContextFlagName(f: number) { return getFlagName((<any>ts).ParserContextFlags, f); }
function serializeNode(n: ts.Node): any {
var o = { kind: getKindName(n.kind) };
ts.forEach(Object.getOwnPropertyNames(n), i => {
@@ -39,13 +63,24 @@ class Test262BaselineRunner extends RunnerBase {
case "parseDiagnostics":
case "grammarDiagnostics":
return undefined;
case "flags":
(<any>o)[i] = getNodeFlagName(n.flags);
return undefined;
case "parserContextFlags":
(<any>o)[i] = getParserContextFlagName(n.parserContextFlags);
return undefined;
case "nextContainer":
if (n.nextContainer) {
(<any>o)[i] = { kind: getKindName(n.nextContainer.kind), pos: n.nextContainer.pos, end: n.nextContainer.end };
(<any>o)[i] = { kind: n.nextContainer.kind, pos: n.nextContainer.pos, end: n.nextContainer.end };
return undefined;
}
case "text":
if (n.kind === ts.SyntaxKind.SourceFile) return undefined;
default:
(<any>o)[i] = ((<any>n)[i]);
}
+1 -1
View File
@@ -94,7 +94,7 @@ class TypeWriterWalker {
}
private getTypeOfNode(node: ts.Node): ts.Type {
var type = this.checker.getTypeOfNode(node);
var type = this.checker.getTypeAtLocation(node);
ts.Debug.assert(type !== undefined, "type doesn't exist");
return type;
}
+6 -6
View File
@@ -1,4 +1,4 @@
declare type PropertyKey = string | number | Symbol;
declare type PropertyKey = string | number | Symbol;
interface Symbol {
/** Returns a string representation of an object. */
@@ -211,7 +211,7 @@ interface NumberConstructor {
* Converts a string to a floating-point number.
* @param string A string that contains a floating-point number.
*/
parseFloat(string: string);
parseFloat(string: string): number;
/**
* Converts A string to an integer.
@@ -438,7 +438,7 @@ interface StringConstructor {
* @param template A well-formed template string call site representation.
* @param substitutions A set of substitution values.
*/
raw(template: TemplateStringsArray, ...substitutions: any[]);
raw(template: TemplateStringsArray, ...substitutions: any[]): string;
}
interface IteratorResult<T> {
@@ -472,8 +472,8 @@ declare var GeneratorFunction: GeneratorFunctionConstructor;
interface Generator<T> extends Iterator<T> {
next(value?: any): IteratorResult<T>;
throw (exception: any);
return (value: T);
throw (exception: any): IteratorResult<T>;
return (value: T): IteratorResult<T>;
// [Symbol.toStringTag]: string;
}
@@ -874,7 +874,7 @@ interface DataView {
}
interface DataViewConstructor {
new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number);
new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView;
}
declare var DataView: DataViewConstructor;
+10 -4
View File
@@ -101,10 +101,11 @@ module ts.BreakpointResolver {
case SyntaxKind.ArrowFunction:
return spanInFunctionDeclaration(<FunctionLikeDeclaration>node);
case SyntaxKind.FunctionBlock:
return spanInFunctionBlock(<Block>node);
case SyntaxKind.Block:
if (isFunctionBlock(node)) {
return spanInFunctionBlock(<Block>node);
}
// Fall through
case SyntaxKind.TryBlock:
case SyntaxKind.FinallyBlock:
case SyntaxKind.ModuleBlock:
@@ -414,13 +415,18 @@ module ts.BreakpointResolver {
return undefined;
}
case SyntaxKind.FunctionBlock:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ClassDeclaration:
// Span on close brace token
return textSpan(node);
case SyntaxKind.Block:
if (isFunctionBlock(node.parent)) {
// Span on close brace token
return textSpan(node);
}
// fall through.
case SyntaxKind.TryBlock:
case SyntaxKind.CatchClause:
case SyntaxKind.FinallyBlock:
+1 -1
View File
@@ -897,7 +897,7 @@ module ts.formatting {
function isSomeBlock(kind: SyntaxKind): boolean {
switch (kind) {
case SyntaxKind.Block:
case SyntaxKind.FunctionBlock:
case SyntaxKind.Block:
case SyntaxKind.TryBlock:
case SyntaxKind.FinallyBlock:
case SyntaxKind.ModuleBlock:
-2
View File
@@ -526,7 +526,6 @@ module ts.formatting {
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.TryBlock:
case SyntaxKind.FinallyBlock:
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
return true;
}
@@ -582,7 +581,6 @@ module ts.formatting {
case SyntaxKind.TryBlock:
case SyntaxKind.CatchClause:
case SyntaxKind.FinallyBlock:
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
case SyntaxKind.SwitchStatement:
return true;
+3 -4
View File
@@ -144,7 +144,7 @@ module ts.NavigationBar {
if (functionDeclaration.kind === SyntaxKind.FunctionDeclaration) {
// A function declaration is 'top level' if it contains any function declarations
// within it.
if (functionDeclaration.body && functionDeclaration.body.kind === SyntaxKind.FunctionBlock) {
if (functionDeclaration.body && functionDeclaration.body.kind === SyntaxKind.Block) {
// Proper function declarations can only have identifier names
if (forEach((<Block>functionDeclaration.body).statements,
s => s.kind === SyntaxKind.FunctionDeclaration && !isEmpty((<FunctionDeclaration>s).name.text))) {
@@ -154,7 +154,7 @@ module ts.NavigationBar {
// Or if it is not parented by another function. i.e all functions
// at module scope are 'top level'.
if (functionDeclaration.parent.kind !== SyntaxKind.FunctionBlock) {
if (!isFunctionBlock(functionDeclaration.parent)) {
return true;
}
}
@@ -230,7 +230,6 @@ module ts.NavigationBar {
if ((node.flags & NodeFlags.Modifier) === 0) {
return undefined;
}
return createItem(node, getTextOfNode((<ParameterDeclaration>node).name), ts.ScriptElementKind.memberVariableElement);
case SyntaxKind.Method:
@@ -363,7 +362,7 @@ module ts.NavigationBar {
}
function createFunctionItem(node: FunctionDeclaration) {
if (node.name && node.body && node.body.kind === SyntaxKind.FunctionBlock) {
if (node.name && node.body && node.body.kind === SyntaxKind.Block) {
var childItems = getItemsWorker(sortNodes((<Block>node.body).statements), createChildItem);
return getNavigationBarItem(node.name.text,
+30 -29
View File
@@ -67,38 +67,39 @@ module ts {
}
switch (n.kind) {
case SyntaxKind.Block:
var parent = n.parent;
var openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
var closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
if (!isFunctionBlock(n)) {
var parent = n.parent;
var openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
var closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
// Check if the block is standalone, or 'attached' to some parent statement.
// If the latter, we want to collaps the block, but consider its hint span
// to be the entire span of the parent.
if (parent.kind === SyntaxKind.DoStatement ||
parent.kind === SyntaxKind.ForInStatement ||
parent.kind === SyntaxKind.ForStatement ||
parent.kind === SyntaxKind.IfStatement ||
parent.kind === SyntaxKind.WhileStatement ||
parent.kind === SyntaxKind.WithStatement ||
parent.kind === SyntaxKind.CatchClause) {
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
// Check if the block is standalone, or 'attached' to some parent statement.
// If the latter, we want to collaps the block, but consider its hint span
// to be the entire span of the parent.
if (parent.kind === SyntaxKind.DoStatement ||
parent.kind === SyntaxKind.ForInStatement ||
parent.kind === SyntaxKind.ForStatement ||
parent.kind === SyntaxKind.IfStatement ||
parent.kind === SyntaxKind.WhileStatement ||
parent.kind === SyntaxKind.WithStatement ||
parent.kind === SyntaxKind.CatchClause) {
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
}
else {
// Block was a standalone block. In this case we want to only collapse
// the span of the block, independent of any parent span.
var span = TextSpan.fromBounds(n.getStart(), n.end);
elements.push({
textSpan: span,
hintSpan: span,
bannerText: collapseText,
autoCollapse: autoCollapse(n)
});
}
break;
}
else {
// Block was a standalone block. In this case we want to only collapse
// the span of the block, independent of any parent span.
var span = TextSpan.fromBounds(n.getStart(), n.end);
elements.push({
textSpan: span,
hintSpan: span,
bannerText: collapseText,
autoCollapse: autoCollapse(n)
});
}
break;
// Fallthrough.
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
case SyntaxKind.TryBlock:
case SyntaxKind.FinallyBlock:
@@ -104,6 +104,7 @@ module TypeScript {
A_generator_declaration_cannot_have_the_async_modifier: "A generator declaration cannot have the 'async' modifier.",
async_modifier_cannot_appear_here: "'async' modifier cannot appear here.",
comma_expression_cannot_appear_in_a_computed_property_name: "'comma' expression cannot appear in a computed property name.",
String_literal_expected: "String literal expected.",
Duplicate_identifier_0: "Duplicate identifier '{0}'.",
The_name_0_does_not_exist_in_the_current_scope: "The name '{0}' does not exist in the current scope.",
The_name_0_does_not_refer_to_a_value: "The name '{0}' does not refer to a value.",
@@ -106,6 +106,7 @@ module TypeScript {
"A generator declaration cannot have the 'async' modifier.": { "code": 1118, "category": DiagnosticCategory.Error },
"'async' modifier cannot appear here.": { "code": 1119, "category": DiagnosticCategory.Error },
"'comma' expression cannot appear in a computed property name.": { "code": 1120, "category": DiagnosticCategory.Error },
"String literal expected.": { "code": 1121, "category": DiagnosticCategory.Error },
"Duplicate identifier '{0}'.": { "code": 2000, "category": DiagnosticCategory.Error },
"The name '{0}' does not exist in the current scope.": { "code": 2001, "category": DiagnosticCategory.Error },
"The name '{0}' does not refer to a value.": { "code": 2002, "category": DiagnosticCategory.Error },
@@ -411,6 +411,10 @@
"category": "Error",
"code": 1120
},
"String literal expected.": {
"category": "Error",
"code": 1121
},
"Duplicate identifier '{0}'.": {
"category": "Error",
"code": 2000
+55 -40
View File
@@ -808,10 +808,15 @@ module ts {
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ModuleBlock:
case SyntaxKind.FunctionBlock:
forEachChild(node, visit);
break;
case SyntaxKind.Block:
if (isFunctionBlock(node)) {
forEachChild(node, visit);
}
break;
case SyntaxKind.Parameter:
// Only consider properties defined as constructor parameters
if (!(node.flags & NodeFlags.AccessibilityModifier)) {
@@ -1293,6 +1298,7 @@ module ts {
public static interfaceName = "interface name";
public static moduleName = "module name";
public static typeParameterName = "type parameter name";
public static typeAlias = "type alias name";
}
enum MatchKind {
@@ -1370,7 +1376,10 @@ module ts {
function writeIndent() {
if (lineStart) {
displayParts.push(displayPart(getIndentString(indent), SymbolDisplayPartKind.space));
var indentString = getIndentString(indent);
if (indentString) {
displayParts.push(displayPart(indentString, SymbolDisplayPartKind.space));
}
lineStart = false;
}
}
@@ -1448,7 +1457,7 @@ module ts {
}
// If the parent is not sourceFile or module block it is local variable
for (var parent = declaration.parent; parent.kind !== SyntaxKind.FunctionBlock; parent = parent.parent) {
for (var parent = declaration.parent; !isFunctionBlock(parent); parent = parent.parent) {
// Reached source file or module block
if (parent.kind === SyntaxKind.SourceFile || parent.kind === SyntaxKind.ModuleBlock) {
return false;
@@ -1470,6 +1479,8 @@ module ts {
return isFirstDeclarationOfSymbolParameter(symbol) ? SymbolDisplayPartKind.parameterName : SymbolDisplayPartKind.localName;
}
else if (flags & SymbolFlags.Property) { return SymbolDisplayPartKind.propertyName; }
else if (flags & SymbolFlags.GetAccessor) { return SymbolDisplayPartKind.propertyName; }
else if (flags & SymbolFlags.SetAccessor) { return SymbolDisplayPartKind.propertyName; }
else if (flags & SymbolFlags.EnumMember) { return SymbolDisplayPartKind.enumMemberName; }
else if (flags & SymbolFlags.Function) { return SymbolDisplayPartKind.functionName; }
else if (flags & SymbolFlags.Class) { return SymbolDisplayPartKind.className; }
@@ -1478,6 +1489,9 @@ module ts {
else if (flags & SymbolFlags.Module) { return SymbolDisplayPartKind.moduleName; }
else if (flags & SymbolFlags.Method) { return SymbolDisplayPartKind.methodName; }
else if (flags & SymbolFlags.TypeParameter) { return SymbolDisplayPartKind.typeParameterName; }
else if (flags & SymbolFlags.TypeAlias) { return SymbolDisplayPartKind.aliasName; }
else if (flags & SymbolFlags.Import) { return SymbolDisplayPartKind.aliasName; }
return SymbolDisplayPartKind.text;
}
@@ -1643,7 +1657,6 @@ module ts {
private currentSourceFile: SourceFile = null;
constructor(private host: LanguageServiceHost) {
this.hostCache = new HostCache(host);
}
private initialize(filename: string) {
@@ -2427,7 +2440,7 @@ module ts {
isMemberCompletion = true;
if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression) {
var symbol = typeInfoResolver.getSymbolInfo(node);
var symbol = typeInfoResolver.getSymbolAtLocation(node);
// This is an alias, follow what it aliases
if (symbol && symbol.flags & SymbolFlags.Import) {
@@ -2444,7 +2457,7 @@ module ts {
}
}
var type = typeInfoResolver.getTypeOfNode(node);
var type = typeInfoResolver.getTypeAtLocation(node);
if (type) {
// Filter private properties
forEach(type.getApparentProperties(), symbol => {
@@ -2696,7 +2709,7 @@ module ts {
// which is permissible given that it is backwards compatible; but really we should consider
// passing the meaning for the node so that we don't report that a suggestion for a value is an interface.
// We COULD also just do what 'getSymbolModifiers' does, which is to use the first declaration.
Debug.assert(session.typeChecker.getNarrowedTypeOfSymbol(symbol, location) !== undefined, "Could not find type for symbol");
Debug.assert(session.typeChecker.getTypeOfSymbolAtLocation(symbol, location) !== undefined, "Could not find type for symbol");
var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getSourceFile(filename), location, session.typeChecker, location, SemanticMeaning.All);
return {
name: entryName,
@@ -2755,6 +2768,7 @@ module ts {
if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement;
if (flags & SymbolFlags.EnumMember) return ScriptElementKind.variableElement;
if (flags & SymbolFlags.Import) return ScriptElementKind.alias;
if (flags & SymbolFlags.Module) return ScriptElementKind.moduleElement;
}
return result;
@@ -2798,7 +2812,7 @@ module ts {
if (!unionPropertyKind) {
// If this was union of all methods,
//make sure it has call signatures before we can label it as method
var typeOfUnionProperty = typeInfoResolver.getNarrowedTypeOfSymbol(symbol, location);
var typeOfUnionProperty = typeInfoResolver.getTypeOfSymbolAtLocation(symbol, location);
if (typeOfUnionProperty.getCallSignatures().length) {
return ScriptElementKind.memberFunctionElement;
}
@@ -2875,7 +2889,7 @@ module ts {
symbolKind = ScriptElementKind.memberVariableElement;
}
var type = typeResolver.getNarrowedTypeOfSymbol(symbol, location);
var type = typeResolver.getTypeOfSymbolAtLocation(symbol, location);
if (type) {
if (location.parent && location.parent.kind === SyntaxKind.PropertyAccessExpression) {
var right = (<PropertyAccessExpression>location.parent).name;
@@ -2936,6 +2950,7 @@ module ts {
case ScriptElementKind.memberVariableElement:
case ScriptElementKind.variableElement:
case ScriptElementKind.constElement:
case ScriptElementKind.letElement:
case ScriptElementKind.parameterElement:
case ScriptElementKind.localVariableElement:
// If it is call or construct signature of lambda's write type name
@@ -2973,7 +2988,8 @@ module ts {
if (functionDeclaration.kind === SyntaxKind.Constructor) {
// show (constructor) Type(...) signature
addPrefixForAnyFunctionOrVar(type.symbol, ScriptElementKind.constructorImplementationElement);
symbolKind = ScriptElementKind.constructorImplementationElement;
addPrefixForAnyFunctionOrVar(type.symbol, symbolKind);
}
else {
// (function/method) symbol(..signature)
@@ -3005,7 +3021,7 @@ module ts {
displayParts.push(spacePart());
addFullSymbolName(symbol);
displayParts.push(spacePart());
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
displayParts.push(spacePart());
displayParts.push.apply(displayParts, typeToDisplayParts(typeResolver, typeResolver.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
}
@@ -3077,7 +3093,7 @@ module ts {
var importDeclaration = <ImportDeclaration>declaration;
if (isExternalModuleImportDeclaration(importDeclaration)) {
displayParts.push(spacePart());
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
displayParts.push(spacePart());
displayParts.push(keywordPart(SyntaxKind.RequireKeyword));
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
@@ -3085,10 +3101,10 @@ module ts {
displayParts.push(punctuationPart(SyntaxKind.CloseParenToken));
}
else {
var internalAliasSymbol = typeResolver.getSymbolInfo(importDeclaration.moduleReference);
var internalAliasSymbol = typeResolver.getSymbolAtLocation(importDeclaration.moduleReference);
if (internalAliasSymbol) {
displayParts.push(spacePart());
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
displayParts.push(spacePart());
addFullSymbolName(internalAliasSymbol, enclosingDeclaration);
}
@@ -3195,7 +3211,7 @@ module ts {
return undefined;
}
var symbol = typeInfoResolver.getSymbolInfo(node);
var symbol = typeInfoResolver.getSymbolAtLocation(node);
if (!symbol) {
// Try getting just type at this position and show
switch (node.kind) {
@@ -3205,7 +3221,7 @@ module ts {
case SyntaxKind.ThisKeyword:
case SyntaxKind.SuperKeyword:
// For the identifiers/this/super etc get the type at position
var type = typeInfoResolver.getTypeOfNode(node);
var type = typeInfoResolver.getTypeAtLocation(node);
if (type) {
return {
kind: ScriptElementKind.unknown,
@@ -3322,7 +3338,7 @@ module ts {
return undefined;
}
var symbol = typeInfoResolver.getSymbolInfo(node);
var symbol = typeInfoResolver.getSymbolAtLocation(node);
// Could not find a symbol e.g. node is string or number keyword,
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
@@ -3522,7 +3538,7 @@ module ts {
var func = <FunctionLikeDeclaration>getContainingFunction(returnStatement);
// If we didn't find a containing function with a block body, bail out.
if (!(func && hasKind(func.body, SyntaxKind.FunctionBlock))) {
if (!(func && hasKind(func.body, SyntaxKind.Block))) {
return undefined;
}
@@ -3554,7 +3570,7 @@ module ts {
// If the "owner" is a function, then we equate 'return' and 'throw' statements in their
// ability to "jump out" of the function, and include occurrences for both.
if (owner.kind === SyntaxKind.FunctionBlock) {
if (isFunctionBlock(owner)) {
forEachReturnStatement(<Block>owner, returnStatement => {
pushKeywordIf(keywords, returnStatement.getFirstToken(), SyntaxKind.ReturnKeyword);
});
@@ -3610,7 +3626,7 @@ module ts {
while (child.parent) {
var parent = child.parent;
if (parent.kind === SyntaxKind.FunctionBlock || parent.kind === SyntaxKind.SourceFile) {
if (isFunctionBlock(parent) || parent.kind === SyntaxKind.SourceFile) {
return parent;
}
@@ -3954,7 +3970,7 @@ module ts {
return getReferencesForSuperKeyword(node);
}
var symbol = typeInfoResolver.getSymbolInfo(node);
var symbol = typeInfoResolver.getSymbolAtLocation(node);
// Could not find a symbol e.g. unknown identifier
if (!symbol) {
@@ -4206,7 +4222,7 @@ module ts {
return;
}
var referenceSymbol = typeInfoResolver.getSymbolInfo(referenceLocation);
var referenceSymbol = typeInfoResolver.getSymbolAtLocation(referenceLocation);
if (referenceSymbol) {
var referenceSymbolDeclaration = referenceSymbol.valueDeclaration;
var shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
@@ -4307,8 +4323,12 @@ module ts {
var staticFlag = NodeFlags.Static;
switch (searchSpaceNode.kind) {
case SyntaxKind.Property:
case SyntaxKind.Method:
if (isObjectLiteralMethod(searchSpaceNode)) {
break;
}
// fall through
case SyntaxKind.Property:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
@@ -4361,6 +4381,11 @@ module ts {
result.push(getReferenceEntryFromNode(node));
}
break;
case SyntaxKind.Method:
if (isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) {
result.push(getReferenceEntryFromNode(node));
}
break;
case SyntaxKind.ClassDeclaration:
// Make sure the container belongs to the same class
// and has the appropriate static modifier from the original container.
@@ -4439,7 +4464,7 @@ module ts {
function getPropertySymbolFromTypeReference(typeReference: TypeReferenceNode) {
if (typeReference) {
var type = typeInfoResolver.getTypeOfNode(typeReference);
var type = typeInfoResolver.getTypeAtLocation(typeReference);
if (type) {
var propertySymbol = typeInfoResolver.getPropertyOfType(type, propertyName);
if (propertySymbol) {
@@ -4489,7 +4514,7 @@ module ts {
function getPropertySymbolsFromContextualType(node: Node): Symbol[] {
if (isNameOfPropertyAssignment(node)) {
var objectLiteral = node.parent.parent;
var objectLiteral = <ObjectLiteralExpression>node.parent.parent;
var contextualType = typeInfoResolver.getContextualType(objectLiteral);
var name = (<Identifier>node).text;
if (contextualType) {
@@ -4930,6 +4955,9 @@ module ts {
else if (flags & SymbolFlags.Enum) {
return ClassificationTypeNames.enumName;
}
else if (flags & SymbolFlags.TypeAlias) {
return ClassificationTypeNames.typeAlias;
}
else if (meaningAtPosition & SemanticMeaning.Type) {
if (flags & SymbolFlags.Interface) {
return ClassificationTypeNames.interfaceName;
@@ -4964,7 +4992,7 @@ module ts {
// Only walk into nodes that intersect the requested span.
if (node && span.intersectsWith(node.getStart(), node.getWidth())) {
if (node.kind === SyntaxKind.Identifier && node.getWidth() > 0) {
var symbol = typeInfoResolver.getSymbolInfo(node);
var symbol = typeInfoResolver.getSymbolAtLocation(node);
if (symbol) {
var type = classifySymbol(symbol, getMeaningFromLocation(node));
if (type) {
@@ -5362,19 +5390,6 @@ module ts {
return new RegExp(regExpString, "gim");
}
function getContainingComment(comments: CommentRange[], position: number): CommentRange {
if (comments) {
for (var i = 0, n = comments.length; i < n; i++) {
var comment = comments[i];
if (comment.pos <= position && position < comment.end) {
return comment;
}
}
}
return undefined;
}
function isLetterOrDigit(char: number): boolean {
return (char >= CharacterCodes.a && char <= CharacterCodes.z) ||
(char >= CharacterCodes.A && char <= CharacterCodes.Z) ||
@@ -5393,7 +5408,7 @@ module ts {
// Can only rename an identifier.
if (node && node.kind === SyntaxKind.Identifier) {
var symbol = typeInfoResolver.getSymbolInfo(node);
var symbol = typeInfoResolver.getSymbolAtLocation(node);
// Only allow a symbol to be renamed if it actually has at least one declaration.
if (symbol && symbol.getDeclarations() && symbol.getDeclarations().length > 0) {
+2 -2
View File
@@ -396,7 +396,7 @@ module ts.SignatureHelp {
function getContainingArgumentInfo(node: Node): ArgumentListInfo {
for (var n = node; n.kind !== SyntaxKind.SourceFile; n = n.parent) {
if (n.kind === SyntaxKind.FunctionBlock) {
if (isFunctionBlock(n)) {
return undefined;
}
@@ -457,7 +457,7 @@ module ts.SignatureHelp {
var invocation = argumentListInfo.invocation;
var callTarget = getInvokedExpression(invocation)
var callTargetSymbol = typeInfoResolver.getSymbolInfo(callTarget);
var callTargetSymbol = typeInfoResolver.getSymbolAtLocation(callTarget);
var callTargetDisplayParts = callTargetSymbol && symbolToDisplayParts(typeInfoResolver, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined);
var items: SignatureHelpItem[] = map(candidates, candidateSignature => {
var signatureHelpParameters: SignatureHelpParameter[];
+1 -4
View File
@@ -326,7 +326,6 @@ module ts.formatting {
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.Block:
case SyntaxKind.FunctionBlock:
case SyntaxKind.TryBlock:
case SyntaxKind.FinallyBlock:
case SyntaxKind.ModuleBlock:
@@ -357,7 +356,6 @@ module ts.formatting {
case SyntaxKind.ForInStatement:
case SyntaxKind.ForStatement:
case SyntaxKind.IfStatement:
return child !== SyntaxKind.Block;
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.Method:
@@ -365,7 +363,7 @@ module ts.formatting {
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return child !== SyntaxKind.FunctionBlock;
return child !== SyntaxKind.Block;
default:
return false;
}
@@ -404,7 +402,6 @@ module ts.formatting {
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.Block:
case SyntaxKind.FinallyBlock:
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
case SyntaxKind.SwitchStatement:
return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile);
+10 -1
View File
@@ -1138,7 +1138,7 @@ var definitions = [
children: [
{ name: 'asyncKeyword', isToken: true, isOptional: true },
{ name: 'callSignature', type: 'CallSignatureSyntax' },
{ name: 'equalsGreaterThanToken', isToken: true, excludeFromAST: true },
{ name: 'equalsGreaterThanToken', isToken: true, isOptional: true },
{ name: 'body', type: 'BlockSyntax | IExpressionSyntax' }
],
isTypeScriptSpecific: true
@@ -1964,17 +1964,23 @@ function generateConstructorFunction(definition) {
}
result += ") {\r\n";
result += " if (data) { this.__data = data; }\r\n";
result += " this.parent = undefined";
if (definition.children.length) {
result += " ";
for (var i = 0; i < definition.children.length; i++) {
<<<<<<< HEAD
if (i) {
result += ", ";
}
=======
result += ",\r\n";
>>>>>>> 691a8a7... Remove restriction that you cannot reuse nodes/tokens during incremental parsing while doing speculatively operations.
var child = definition.children[i];
result += "this." + child.name + " = " + getSafeName(child);
}
result += ";\r\n";
}
<<<<<<< HEAD
if (definition.children.length > 0) {
result += " ";
for (var i = 0; i < definition.children.length; i++) {
@@ -1991,6 +1997,9 @@ function generateConstructorFunction(definition) {
}
result += ";\r\n";
}
=======
result += ";\r\n";
>>>>>>> 691a8a7... Remove restriction that you cannot reuse nodes/tokens during incremental parsing while doing speculatively operations.
result += " };\r\n";
result += " " + definition.name + ".prototype.kind = SyntaxKind." + getNameWithoutSuffix(definition) + ";\r\n";
result += " " + definition.name + ".prototype.childCount = " + definition.children.length + ";\r\n";
File diff suppressed because one or more lines are too long
+53 -390
View File
@@ -1,11 +1,6 @@
///<reference path="references.ts" />
module TypeScript.IncrementalParser {
interface IParserRewindPoint {
// Information used by the incremental parser source.
oldSourceUnitCursor: SyntaxCursor;
}
interface ISyntaxElementInternal extends ISyntaxElement {
intersectsChange: boolean;
}
@@ -30,17 +25,15 @@ module TypeScript.IncrementalParser {
//
// This parser source also keeps track of the absolute position in the text that we're in,
// and any token diagnostics produced. That way we dont' have to track that ourselves.
var _scannerParserSource = Scanner.createParserSource(oldSyntaxTree.fileName(), text, oldSyntaxTree.languageVersion());
var scannerParserSource = Scanner.createParserSource(oldSyntaxTree.fileName(), text, oldSyntaxTree.languageVersion());
// The cursor we use to navigate through and retrieve nodes and tokens from the old tree.
var oldSourceUnit = oldSyntaxTree.sourceUnit();
var _outstandingRewindPointCount = 0;
// Start the cursor pointing at the first element in the source unit (if it exists).
var _oldSourceUnitCursor = getSyntaxCursor();
var oldSourceUnitCursor = getSyntaxCursor();
if (oldSourceUnit.moduleElements.length > 0) {
_oldSourceUnitCursor.pushElement(childAt(oldSourceUnit.moduleElements, 0), /*indexInParent:*/ 0);
oldSourceUnitCursor.pushElement(childAt(oldSourceUnit.moduleElements, 0), /*indexInParent:*/ 0);
}
// In general supporting multiple individual edits is just not that important. So we
@@ -48,18 +41,16 @@ module TypeScript.IncrementalParser {
// time this could be problematic would be if the user made a ton of discontinuous edits.
// For example, doing a column select on a *large* section of a code. If this is a
// problem, we can always update this code to handle multiple changes.
var _changeRange = extendToAffectedRange(textChangeRange, oldSourceUnit);
// Cached value of _changeRange.newSpan(). Cached for performance.
var _changeRangeNewSpan = _changeRange.newSpan();
var changeRange = extendToAffectedRange(textChangeRange, oldSourceUnit);
// The old tree's length, plus whatever length change was caused by the edit
// Had better equal the new text's length!
if (Debug.shouldAssert(AssertionLevel.Aggressive)) {
Debug.assert((fullWidth(oldSourceUnit) - _changeRange.span().length() + _changeRange.newLength()) === text.length());
Debug.assert((fullWidth(oldSourceUnit) - changeRange.span().length() + changeRange.newLength()) === text.length());
}
var delta = _changeRange.newSpan().length() - _changeRange.span().length();
var delta = changeRange.newSpan().length() - changeRange.span().length();
// If we added or removed characters during the edit, then we need to go and adjust all
// the nodes after the edit. Those nodes may move forward down (if we inserted chars)
// or they may move backward (if we deleted chars).
@@ -75,14 +66,7 @@ module TypeScript.IncrementalParser {
// Also, mark any syntax elements that intersect the changed span. We know, up front,
// that we cannot reuse these elements.
updateTokenPositionsAndMarkElements(<ISyntaxElementInternal><ISyntaxElement>oldSourceUnit,
_changeRange.span().start(), _changeRange.span().end(), delta, /*fullStart:*/ 0);
function release() {
_scannerParserSource.release();
_scannerParserSource = undefined;
_oldSourceUnitCursor = undefined;
_outstandingRewindPointCount = 0;
}
changeRange.span().start(), changeRange.span().end(), delta, /*fullStart:*/ 0);
function extendToAffectedRange(changeRange: TextChangeRange, sourceUnit: SourceUnitSyntax): TextChangeRange {
// Consider the following code:
@@ -116,84 +100,46 @@ module TypeScript.IncrementalParser {
}
function absolutePosition() {
return _scannerParserSource.absolutePosition();
return scannerParserSource.absolutePosition();
}
function tokenDiagnostics(): Diagnostic[] {
return _scannerParserSource.tokenDiagnostics();
function diagnostics(): Diagnostic[] {
return scannerParserSource.diagnostics();
}
function getRewindPoint() {
// Get a rewind point for our new text reader and for our old source unit cursor.
var rewindPoint = <IParserRewindPoint>_scannerParserSource.getRewindPoint();
function tryParse<T extends ISyntaxNode>(callback: () => T): T {
// Clone our cursor. That way we can restore to that point if the parser needs to rewind.
rewindPoint.oldSourceUnitCursor = cloneSyntaxCursor(_oldSourceUnitCursor);
var savedOldSourceUnitCursor = cloneSyntaxCursor(oldSourceUnitCursor);
_outstandingRewindPointCount++;
return rewindPoint;
}
// Now defer to our underlying scanner source to actually invoke the callback. That
// way, if the parser decides to rewind, both the scanner source and this incremental
// source will rewind appropriately.
var result = scannerParserSource.tryParse(callback);
function rewind(rewindPoint: IParserRewindPoint): void {
// Restore our state to the values when the rewind point was created.
// Reset the cursor to what it was when we got the rewind point. Make sure to return
// our existing cursor to the pool so it can be reused.
returnSyntaxCursor(_oldSourceUnitCursor);
_oldSourceUnitCursor = rewindPoint.oldSourceUnitCursor;
// Clear the cursor that the rewind point points to. This way we don't try
// to return it in 'releaseRewindPoint'.
rewindPoint.oldSourceUnitCursor = undefined;
_scannerParserSource.rewind(rewindPoint);
}
function releaseRewindPoint(rewindPoint: IParserRewindPoint): void {
if (rewindPoint.oldSourceUnitCursor) {
returnSyntaxCursor(rewindPoint.oldSourceUnitCursor);
if (!result) {
// We're rewinding. Reset the cursor to what it was when we got the rewind point.
// Make sure to return our existing cursor to the pool so it can be reused.
returnSyntaxCursor(oldSourceUnitCursor);
oldSourceUnitCursor = savedOldSourceUnitCursor;
}
else {
// We're not rewinding. Return the cloned original cursor back to the pool.
returnSyntaxCursor(savedOldSourceUnitCursor);
}
_scannerParserSource.releaseRewindPoint(rewindPoint);
_outstandingRewindPointCount--;
Debug.assert(_outstandingRewindPointCount >= 0);
}
function isPinned() {
return _outstandingRewindPointCount > 0;
return result;
}
function trySynchronizeCursorToPosition() {
// If we're currently pinned, then do not want to touch the cursor. Here's why. First,
// recall that we're 'pinned' when we're speculatively parsing. So say we were to allow
// returning old nodes/tokens while speculatively parsing. Then, the parser might start
// mutating the nodes and tokens we returned (i.e. by setting their parents). Then,
// when we rewound, those nodes and tokens would still have those updated parents.
// Parents which we just decided we did *not* want to parse (hence why we rewound). For
// Example, say we have something like:
//
// var v = f<a,b,c>e; // note: this is not generic.
//
// When incrementally parsing, we will need to speculatively parse to determine if the
// above is generic. This will cause us to reuse the "a, b, c" tokens, and set their
// parent to a new type argument list. A type argument list we will then throw away once
// we decide that it isn't actually generic. We will have now 'broken' the original tree.
//
// As such, the rule is simple. We only return nodes/tokens from teh original tree if
// we know the parser will accept and consume them and never rewind back before them.
if (isPinned()) {
return false;
}
var absolutePos = absolutePosition();
while (true) {
if (_oldSourceUnitCursor.isFinished()) {
if (oldSourceUnitCursor.isFinished()) {
// Can't synchronize the cursor to the current position if the cursor is finished.
return false;
}
// Start with the current node or token the cursor is pointing at.
var currentNodeOrToken = _oldSourceUnitCursor.currentNodeOrToken();
var currentNodeOrToken = oldSourceUnitCursor.currentNodeOrToken();
// Node, move the cursor past any nodes or tokens that intersect the change range
// 1) they are never reusable.
@@ -203,10 +149,10 @@ module TypeScript.IncrementalParser {
// of the incremental algorithm.
if ((<ISyntaxElementInternal><ISyntaxElement>currentNodeOrToken).intersectsChange) {
if (isNode(currentNodeOrToken)) {
_oldSourceUnitCursor.moveToFirstChild();
oldSourceUnitCursor.moveToFirstChild();
}
else {
_oldSourceUnitCursor.moveToNextSibling();
oldSourceUnitCursor.moveToNextSibling();
}
continue;
}
@@ -234,13 +180,13 @@ module TypeScript.IncrementalParser {
// able to break up that token any further and we should just move to the next
// token.
if (currentNodeOrTokenFullEnd <= absolutePos || isToken(currentNodeOrToken)) {
_oldSourceUnitCursor.moveToNextSibling();
oldSourceUnitCursor.moveToNextSibling();
}
else {
// We have a node, and it started before our absolute pos, and ended after our
// pos. Try to crumble this node to see if we'll be able to skip the first node
// or token contained within.
_oldSourceUnitCursor.moveToFirstChild();
oldSourceUnitCursor.moveToFirstChild();
}
}
}
@@ -269,12 +215,12 @@ module TypeScript.IncrementalParser {
// Either we couldn't read from the old source unit, or we weren't able to successfully
// get a token from it. In this case we need to read a token from the underlying text.
return _scannerParserSource.currentToken();
return scannerParserSource.currentToken();
}
function currentContextualToken(): ISyntaxToken {
// Just delegate to the underlying source to handle
return _scannerParserSource.currentContextualToken();
return scannerParserSource.currentContextualToken();
}
function tryGetNodeFromOldSourceUnit(): ISyntaxNode {
@@ -285,7 +231,7 @@ module TypeScript.IncrementalParser {
// c) it does not have a regex token in it.
// d) we are still in the same strict or non-strict state that the node was originally parsed in.
while (true) {
var node = _oldSourceUnitCursor.currentNode();
var node = oldSourceUnitCursor.currentNode();
if (node === undefined) {
// Couldn't even read a node, nothing to return.
return undefined;
@@ -300,7 +246,7 @@ module TypeScript.IncrementalParser {
// We couldn't use currentNode. Try to move to its first child (in case that's a
// node). If it is we can try using that. Otherwise we'll just bail out in the
// next iteration of the loop.
_oldSourceUnitCursor.moveToFirstChild();
oldSourceUnitCursor.moveToFirstChild();
}
}
@@ -330,7 +276,7 @@ module TypeScript.IncrementalParser {
function tryGetTokenFromOldSourceUnit(): ISyntaxToken {
// get the current token that the cursor is pointing at.
var token = _oldSourceUnitCursor.currentToken();
var token = oldSourceUnitCursor.currentToken();
return canReuseTokenFromOldSourceUnit(token) ? token : undefined;
}
@@ -344,44 +290,44 @@ module TypeScript.IncrementalParser {
}
// Couldn't peek this far in the old tree. Get the token from the new text.
return _scannerParserSource.peekToken(n);
return scannerParserSource.peekToken(n);
}
function tryPeekTokenFromOldSourceUnit(n: number): ISyntaxToken {
// clone the existing cursor so we can move it forward and then restore ourselves back
// to where we started from.
var cursorClone = cloneSyntaxCursor(_oldSourceUnitCursor);
var cursorClone = cloneSyntaxCursor(oldSourceUnitCursor);
var token = tryPeekTokenFromOldSourceUnitWorker(n);
returnSyntaxCursor(_oldSourceUnitCursor);
_oldSourceUnitCursor = cursorClone;
returnSyntaxCursor(oldSourceUnitCursor);
oldSourceUnitCursor = cursorClone;
return token;
}
function tryPeekTokenFromOldSourceUnitWorker(n: number): ISyntaxToken {
// First, make sure the cursor is pointing at a token.
_oldSourceUnitCursor.moveToFirstToken();
oldSourceUnitCursor.moveToFirstToken();
// Now, keep walking forward to successive tokens.
for (var i = 0; i < n; i++) {
var interimToken = _oldSourceUnitCursor.currentToken();
var interimToken = oldSourceUnitCursor.currentToken();
if (!canReuseTokenFromOldSourceUnit(interimToken)) {
return undefined;
}
_oldSourceUnitCursor.moveToNextSibling();
oldSourceUnitCursor.moveToNextSibling();
}
var token = _oldSourceUnitCursor.currentToken();
var token = oldSourceUnitCursor.currentToken();
return canReuseTokenFromOldSourceUnit(token) ? token : undefined;
}
function consumeNodeOrToken(nodeOrToken: ISyntaxNodeOrToken): void {
_scannerParserSource.consumeNodeOrToken(nodeOrToken);
scannerParserSource.consumeNodeOrToken(nodeOrToken);
}
return {
@@ -393,282 +339,15 @@ module TypeScript.IncrementalParser {
currentToken: currentToken,
currentContextualToken: currentContextualToken,
peekToken: peekToken,
consumeNodeOrToken: consumeNodeOrToken,
getRewindPoint: getRewindPoint,
rewind: rewind,
releaseRewindPoint: releaseRewindPoint,
tokenDiagnostics: tokenDiagnostics,
release: release
consumeNodeOrToken: scannerParserSource.consumeNodeOrToken,
tryParse: tryParse,
diagnostics: diagnostics
};
}
interface SyntaxCursorPiece {
element: ISyntaxElement;
indexInParent: number
}
function createSyntaxCursorPiece(element: ISyntaxElement, indexInParent: number) {
return { element: element, indexInParent: indexInParent };
}
// Pool syntax cursors so we don't churn too much memory when we need temporary cursors.
// i.e. when we're speculatively parsing, we can cheaply get a pooled cursor and then
// return it when we no longer need it.
var syntaxCursorPool: SyntaxCursor[] = [];
var syntaxCursorPoolCount: number = 0;
function returnSyntaxCursor(cursor: SyntaxCursor): void {
// Make sure the cursor isn't holding onto any syntax elements. We don't want to leak
// them when we return the cursor to the pool.
cursor.clean();
syntaxCursorPool[syntaxCursorPoolCount] = cursor;
syntaxCursorPoolCount++;
}
function getSyntaxCursor(): SyntaxCursor {
// Get an existing cursor from the pool if we have one. Or create a new one if we don't.
var cursor = syntaxCursorPoolCount > 0
? syntaxCursorPool[syntaxCursorPoolCount - 1]
: createSyntaxCursor();
if (syntaxCursorPoolCount > 0) {
// If we reused an existing cursor, take it out of the pool so no one else uses it.
syntaxCursorPoolCount--;
syntaxCursorPool[syntaxCursorPoolCount] = undefined;
}
return cursor;
}
function cloneSyntaxCursor(cursor: SyntaxCursor): SyntaxCursor {
var newCursor = getSyntaxCursor();
// Make the new cursor a *deep* copy of the cursor passed in. This ensures each cursor can
// be moved without affecting the other.
newCursor.deepCopyFrom(cursor);
return newCursor;
}
interface SyntaxCursor {
pieces: SyntaxCursorPiece[];
clean(): void;
isFinished(): boolean;
moveToFirstChild(): void;
moveToFirstToken(): void;
moveToNextSibling(): void;
currentNodeOrToken(): ISyntaxNodeOrToken;
currentNode(): ISyntaxNode;
currentToken(): ISyntaxToken;
pushElement(element: ISyntaxElement, indexInParent: number): void;
deepCopyFrom(other: SyntaxCursor): void;
}
function createSyntaxCursor(): SyntaxCursor {
// Our list of path pieces. The piece pointed to by 'currentPieceIndex' must be a node or
// token. However, pieces earlier than that may point to list nodes.
//
// For perf we reuse pieces as much as possible. i.e. instead of popping items off the
// list, we just will change currentPieceIndex so we can reuse that piece later.
var pieces: SyntaxCursorPiece[] = [];
var currentPieceIndex: number = -1;
// Cleans up this cursor so that it doesn't have any references to actual syntax nodes.
// This sould be done before returning the cursor to the pool so that the Parser module
// doesn't unnecessarily keep old syntax trees alive.
function clean(): void {
for (var i = 0, n = pieces.length; i < n; i++) {
var piece = pieces[i];
if (piece.element === undefined) {
break;
}
piece.element = undefined;
piece.indexInParent = -1;
}
currentPieceIndex = -1;
}
// Makes this cursor into a deep copy of the cursor passed in.
function deepCopyFrom(other: SyntaxCursor): void {
for (var i = 0, n = other.pieces.length; i < n; i++) {
var piece = other.pieces[i];
if (piece.element === undefined) {
break;
}
pushElement(piece.element, piece.indexInParent);
}
}
function isFinished(): boolean {
return currentPieceIndex < 0;
}
function currentNodeOrToken(): ISyntaxNodeOrToken {
if (isFinished()) {
return undefined;
}
var result = pieces[currentPieceIndex].element;
// The current element must always be a node or a token.
return <ISyntaxNodeOrToken>result;
}
function currentNode(): ISyntaxNode {
var element = currentNodeOrToken();
return isNode(element) ? <ISyntaxNode>element : undefined;
}
function isEmptyList(element: ISyntaxElement) {
return isList(element) && (<ISyntaxNodeOrToken[]>element).length === 0;
}
function moveToFirstChild() {
var nodeOrToken = currentNodeOrToken();
if (nodeOrToken === undefined) {
return;
}
if (isToken(nodeOrToken)) {
// If we're already on a token, there's nothing to do.
return;
}
// Either the node has some existent child, then move to it. if it doesn't, then it's
// an empty node. Conceptually the first child of an empty node is really just the
// next sibling of the empty node.
for (var i = 0, n = childCount(nodeOrToken); i < n; i++) {
var child = childAt(nodeOrToken, i);
if (child && !isEmptyList(child)) {
// Great, we found a real child. Push that.
pushElement(child, /*indexInParent:*/ i);
// If it was a list, make sure we're pointing at its first element. We know we
// must have one because this is a non-shared list.
moveToFirstChildIfList();
return;
}
}
// This element must have been an empty node. Moving to its 'first child' is equivalent to just
// moving to the next sibling.
moveToNextSibling();
}
function moveToNextSibling(): void {
while (!isFinished()) {
// first look to our parent and see if it has a sibling of us that we can move to.
var currentPiece = pieces[currentPieceIndex];
var parent = currentPiece.element.parent;
// We start searching at the index one past our own index in the parent.
for (var i = currentPiece.indexInParent + 1, n = childCount(parent); i < n; i++) {
var sibling = childAt(parent, i);
if (sibling && !isEmptyList(sibling)) {
// We found a good sibling that we can move to. Just reuse our existing piece
// so we don't have to push/pop.
currentPiece.element = sibling;
currentPiece.indexInParent = i;
// The sibling might have been a list. Move to it's first child.
moveToFirstChildIfList();
return;
}
}
// Didn't have a sibling for this element. Go up to our parent and get its sibling.
// Clear the data from the old piece. We don't want to keep any elements around
// unintentionally.
currentPiece.element = undefined;
currentPiece.indexInParent = -1;
// Point at the parent. if we move past the top of the path, then we're finished.
currentPieceIndex--;
}
}
function moveToFirstChildIfList(): void {
var element = pieces[currentPieceIndex].element;
if (isList(element)) {
// We cannot ever get an empty list in our piece path. Empty lists are 'shared' and
// we make sure to filter that out before pushing any children.
pushElement(childAt(element, 0), /*indexInParent:*/ 0);
}
}
function pushElement(element: ISyntaxElement, indexInParent: number): void {
currentPieceIndex++;
// Reuse an existing piece if we have one. Otherwise, push a new piece to our list.
if (currentPieceIndex === pieces.length) {
pieces.push(createSyntaxCursorPiece(element, indexInParent));
}
else {
var piece = pieces[currentPieceIndex];
piece.element = element;
piece.indexInParent = indexInParent;
}
}
function moveToFirstToken(): void {
while (!isFinished()) {
var element = pieces[currentPieceIndex].element;
if (isNode(element)) {
moveToFirstChild();
continue;
}
return;
}
}
function currentToken(): ISyntaxToken {
moveToFirstToken();
var element = currentNodeOrToken();
return <ISyntaxToken>element;
}
return {
pieces: pieces,
clean: clean,
isFinished: isFinished,
moveToFirstChild: moveToFirstChild,
moveToFirstToken: moveToFirstToken,
moveToNextSibling: moveToNextSibling,
currentNodeOrToken: currentNodeOrToken,
currentNode: currentNode,
currentToken: currentToken,
pushElement: pushElement,
deepCopyFrom: deepCopyFrom
};
}
// A simple walker we use to hit all the tokens of a node and update their positions when they
// are reused in a different location because of an incremental parse.
class TokenCollectorWalker extends SyntaxWalker {
public tokens: ISyntaxToken[] = [];
public visitToken(token: ISyntaxToken): void {
this.tokens.push(token);
}
}
var tokenCollectorWalker = new TokenCollectorWalker();
function updateTokenPositionsAndMarkElements(element: ISyntaxElement, changeStart: number, changeRangeOldEnd: number, delta: number, fullStart: number): void {
// First, try to skip past any elements that we dont' need to move. We don't need to
// move any elements that don't start after the end of the change range.
// First, try to skip past any elements that we dont' need to move. We don't need to
// move any elements that don't start after the end of the change range.
if (fullStart > changeRangeOldEnd) {
// Note, we only move elements that are truly after the end of the change range.
// We consider elements that are touching the end of the change range to be unusable.
@@ -732,29 +411,13 @@ module TypeScript.IncrementalParser {
forceUpdateTokenPosition(<ISyntaxToken>nodeOrToken, delta);
}
else {
var node = <ISyntaxNode>nodeOrToken;
var tokens = getTokens(node);
var tokens = getTokens(<ISyntaxNode>nodeOrToken);
for (var i = 0, n = tokens.length; i < n; i++) {
forceUpdateTokenPosition(tokens[i], delta);
}
}
}
function getTokens(node: ISyntaxNode): ISyntaxToken[] {
var tokens = node.__cachedTokens;
if (!tokens) {
tokens = [];
tokenCollectorWalker.tokens = tokens;
visitNodeOrToken(tokenCollectorWalker, node);
node.__cachedTokens = tokens;
tokenCollectorWalker.tokens = undefined;
}
return tokens;
}
export function parse(oldSyntaxTree: SyntaxTree, textChangeRange: TextChangeRange, newText: ISimpleText): SyntaxTree {
if (textChangeRange.isUnchanged()) {
return oldSyntaxTree;
File diff suppressed because it is too large Load Diff
+5 -1
View File
@@ -27,13 +27,15 @@
///<reference path='syntaxToken.ts' />
///<reference path='syntaxTrivia.ts' />
///<reference path='syntaxTriviaList.ts' />
///<reference path='syntaxUtilities.ts' />
///<reference path='syntaxVisitor.generated.ts' />
///<reference path='syntaxWalker.generated.ts' />
// SyntaxInformationMap depends on SyntaxWalker
// ///<reference path='syntaxNodeInvariantsChecker.ts' />
// SyntaxUtilities depends on SyntaxWalker
///<reference path='syntaxUtilities.ts' />
///<reference path='parser.ts' />
// Concrete nodes depend on the parser.
@@ -44,3 +46,5 @@
///<reference path='syntaxTree.ts' />
///<reference path='unicode.ts' />
///<reference path='syntaxCursor.ts' />
///<reference path='incrementalParser.ts' />
+22 -69
View File
@@ -60,15 +60,15 @@ module TypeScript.Scanner {
// This gives us 23bit for width (or 8MB of width which should be enough for any codebase).
enum ScannerConstants {
LargeTokenFullWidthShift = 3,
LargeTokenFullWidthShift = 3,
WhitespaceTrivia = 0x01, // 00000001
NewlineTrivia = 0x02, // 00000010
CommentTrivia = 0x04, // 00000100
TriviaMask = 0x07, // 00000111
WhitespaceTrivia = 0x01, // 00000001
NewlineTrivia = 0x02, // 00000010
CommentTrivia = 0x04, // 00000100
TriviaMask = 0x07, // 00000111
KindMask = 0x7F, // 01111111
IsVariableWidthMask = 0x80, // 10000000
KindMask = 0x7F, // 01111111
IsVariableWidthMask = 0x80, // 10000000
}
function largeTokenPackData(fullWidth: number, leadingTriviaInfo: number) {
@@ -154,7 +154,7 @@ module TypeScript.Scanner {
var lastTokenInfo = { leadingTriviaWidth: -1 };
var lastTokenInfoTokenID: number = -1;
var triviaScanner = createScannerInternal(ts.ScriptTarget.Latest, SimpleText.fromString(""), () => { });
var triviaScanner = createScannerInternal(ts.ScriptTarget.Latest, SimpleText.fromString(""),() => { });
interface IScannerToken extends ISyntaxToken {
}
@@ -208,7 +208,7 @@ module TypeScript.Scanner {
public setFullStart(fullStart: number): void {
this._fullStart = fullStart;
}
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
public isIncrementallyUnusable(): boolean { return false; }
@@ -1425,19 +1425,13 @@ module TypeScript.Scanner {
export function isValidIdentifier(text: ISimpleText, languageVersion: ts.ScriptTarget): boolean {
var hadError = false;
var scanner = createScanner(languageVersion, text, () => hadError = true);
var scanner = createScanner(languageVersion, text,() => hadError = true);
var token = scanner.scan(/*allowContextualToken:*/ false);
return !hadError && SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && width(token) === text.length();
}
interface IScannerRewindPoint extends Parser.IRewindPoint {
// Information used by normal parser source.
absolutePosition: number;
slidingWindowIndex: number;
}
// Parser source used in batch scenarios. Directly calls into an underlying text scanner and
// supports none of the functionality to reuse nodes. Good for when you just want want to do
// a single parse of a file.
@@ -1451,10 +1445,6 @@ module TypeScript.Scanner {
// reparse a / or /= as a regular expression.
var _tokenDiagnostics: Diagnostic[] = [];
// Pool of rewind points we give out if the parser needs one.
var rewindPointPool: IScannerRewindPoint[] = [];
var rewindPointPoolCount = 0;
var lastDiagnostic: Diagnostic = undefined;
var reportDiagnostic = (position: number, fullWidth: number, diagnosticKey: string, args: any[]) => {
lastDiagnostic = new Diagnostic(fileName, text.lineMap(), position, fullWidth, diagnosticKey, args);
@@ -1466,15 +1456,6 @@ module TypeScript.Scanner {
// The scanner we're pulling tokens from.
var scanner = createScanner(languageVersion, text, reportDiagnostic);
function release() {
slidingWindow = undefined;
scanner = undefined;
_tokenDiagnostics = [];
rewindPointPool = [];
lastDiagnostic = undefined;
reportDiagnostic = undefined;
}
function currentNode(): ISyntaxNode {
// The normal parser source never returns nodes. They're only returned by the
// incremental parser source.
@@ -1486,48 +1467,23 @@ module TypeScript.Scanner {
return _absolutePosition;
}
function tokenDiagnostics(): Diagnostic[] {
function diagnostics(): Diagnostic[] {
return _tokenDiagnostics;
}
function getOrCreateRewindPoint(): IScannerRewindPoint {
if (rewindPointPoolCount === 0) {
return <IScannerRewindPoint>{};
function tryParse<T extends ISyntaxNode>(callback: () => T): T {
var savedSlidingWindowIndex = slidingWindow.getAndPinAbsoluteIndex();
var savedAbsolutePosition = _absolutePosition;
var result = callback();
if (!result) {
slidingWindow.rewindToPinnedIndex(savedSlidingWindowIndex);
_absolutePosition = savedAbsolutePosition;
}
rewindPointPoolCount--;
var result = rewindPointPool[rewindPointPoolCount];
rewindPointPool[rewindPointPoolCount] = undefined;
return result;
}
function getRewindPoint(): IScannerRewindPoint {
var slidingWindowIndex = slidingWindow.getAndPinAbsoluteIndex();
var rewindPoint = getOrCreateRewindPoint();
rewindPoint.slidingWindowIndex = slidingWindowIndex;
rewindPoint.absolutePosition = _absolutePosition;
// rewindPoint.pinCount = slidingWindow.pinCount();
return rewindPoint;
}
function rewind(rewindPoint: IScannerRewindPoint): void {
slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex);
_absolutePosition = rewindPoint.absolutePosition;
}
function releaseRewindPoint(rewindPoint: IScannerRewindPoint): void {
// Debug.assert(slidingWindow.pinCount() === rewindPoint.pinCount);
slidingWindow.releaseAndUnpinAbsoluteIndex((<any>rewindPoint).absoluteIndex);
rewindPointPool[rewindPointPoolCount] = rewindPoint;
rewindPointPoolCount++;
}
function fetchNextItem(allowContextualToken: boolean): ISyntaxToken {
// Assert disabled because it is actually expensive enugh to affect perf.
// Debug.assert(spaceAvailable > 0);
@@ -1641,12 +1597,9 @@ module TypeScript.Scanner {
currentContextualToken: currentContextualToken,
peekToken: peekToken,
consumeNodeOrToken: consumeNodeOrToken,
getRewindPoint: getRewindPoint,
rewind: rewind,
releaseRewindPoint: releaseRewindPoint,
tokenDiagnostics: tokenDiagnostics,
release: release,
absolutePosition: absolutePosition,
tryParse: tryParse,
diagnostics: diagnostics,
absolutePosition: absolutePosition
};
}
+255
View File
@@ -0,0 +1,255 @@
/// <reference path="references.ts" />
module TypeScript.IncrementalParser {
interface SyntaxCursorPiece {
element: ISyntaxElement;
indexInParent: number
}
function createSyntaxCursorPiece(element: ISyntaxElement, indexInParent: number) {
return { element: element, indexInParent: indexInParent };
}
// Pool syntax cursors so we don't churn too much memory when we need temporary cursors.
// i.e. when we're speculatively parsing, we can cheaply get a pooled cursor and then
// return it when we no longer need it.
var syntaxCursorPool: SyntaxCursor[] = [];
var syntaxCursorPoolCount: number = 0;
export function returnSyntaxCursor(cursor: SyntaxCursor): void {
// Make sure the cursor isn't holding onto any syntax elements. We don't want to leak
// them when we return the cursor to the pool.
cursor.clean();
syntaxCursorPool[syntaxCursorPoolCount] = cursor;
syntaxCursorPoolCount++;
}
export function getSyntaxCursor(): SyntaxCursor {
// Get an existing cursor from the pool if we have one. Or create a new one if we don't.
var cursor = syntaxCursorPoolCount > 0
? syntaxCursorPool[syntaxCursorPoolCount - 1]
: createSyntaxCursor();
if (syntaxCursorPoolCount > 0) {
// If we reused an existing cursor, take it out of the pool so no one else uses it.
syntaxCursorPoolCount--;
syntaxCursorPool[syntaxCursorPoolCount] = undefined;
}
return cursor;
}
export function cloneSyntaxCursor(cursor: SyntaxCursor): SyntaxCursor {
var newCursor = getSyntaxCursor();
// Make the new cursor a *deep* copy of the cursor passed in. This ensures each cursor can
// be moved without affecting the other.
newCursor.deepCopyFrom(cursor);
return newCursor;
}
interface SyntaxCursor {
pieces: SyntaxCursorPiece[];
clean(): void;
isFinished(): boolean;
moveToFirstChild(): void;
moveToFirstToken(): void;
moveToNextSibling(): void;
currentNodeOrToken(): ISyntaxNodeOrToken;
currentNode(): ISyntaxNode;
currentToken(): ISyntaxToken;
pushElement(element: ISyntaxElement, indexInParent: number): void;
deepCopyFrom(other: SyntaxCursor): void;
}
function createSyntaxCursor(): SyntaxCursor {
// Our list of path pieces. The piece pointed to by 'currentPieceIndex' must be a node or
// token. However, pieces earlier than that may point to list nodes.
//
// For perf we reuse pieces as much as possible. i.e. instead of popping items off the
// list, we just will change currentPieceIndex so we can reuse that piece later.
var pieces: SyntaxCursorPiece[] = [];
var currentPieceIndex: number = -1;
// Cleans up this cursor so that it doesn't have any references to actual syntax nodes.
// This sould be done before returning the cursor to the pool so that the Parser module
// doesn't unnecessarily keep old syntax trees alive.
function clean(): void {
for (var i = 0, n = pieces.length; i < n; i++) {
var piece = pieces[i];
if (piece.element === undefined) {
break;
}
piece.element = undefined;
piece.indexInParent = -1;
}
currentPieceIndex = -1;
}
// Makes this cursor into a deep copy of the cursor passed in.
function deepCopyFrom(other: SyntaxCursor): void {
for (var i = 0, n = other.pieces.length; i < n; i++) {
var piece = other.pieces[i];
if (piece.element === undefined) {
break;
}
pushElement(piece.element, piece.indexInParent);
}
}
function isFinished(): boolean {
return currentPieceIndex < 0;
}
function currentNodeOrToken(): ISyntaxNodeOrToken {
if (isFinished()) {
return undefined;
}
var result = pieces[currentPieceIndex].element;
// The current element must always be a node or a token.
return <ISyntaxNodeOrToken>result;
}
function currentNode(): ISyntaxNode {
var element = currentNodeOrToken();
return isNode(element) ? <ISyntaxNode>element : undefined;
}
function isEmptyList(element: ISyntaxElement) {
return isList(element) && (<ISyntaxNodeOrToken[]>element).length === 0;
}
function moveToFirstChild() {
var nodeOrToken = currentNodeOrToken();
if (nodeOrToken === undefined) {
return;
}
if (isToken(nodeOrToken)) {
// If we're already on a token, there's nothing to do.
return;
}
// Either the node has some existent child, then move to it. if it doesn't, then it's
// an empty node. Conceptually the first child of an empty node is really just the
// next sibling of the empty node.
for (var i = 0, n = childCount(nodeOrToken); i < n; i++) {
var child = childAt(nodeOrToken, i);
if (child && !isEmptyList(child)) {
// Great, we found a real child. Push that.
pushElement(child, /*indexInParent:*/ i);
// If it was a list, make sure we're pointing at its first element. We know we
// must have one because this is a non-shared list.
moveToFirstChildIfList();
return;
}
}
// This element must have been an empty node. Moving to its 'first child' is equivalent to just
// moving to the next sibling.
moveToNextSibling();
}
function moveToNextSibling(): void {
while (!isFinished()) {
// first look to our parent and see if it has a sibling of us that we can move to.
var currentPiece = pieces[currentPieceIndex];
var parent = currentPiece.element.parent;
// We start searching at the index one past our own index in the parent.
for (var i = currentPiece.indexInParent + 1, n = childCount(parent); i < n; i++) {
var sibling = childAt(parent, i);
if (sibling && !isEmptyList(sibling)) {
// We found a good sibling that we can move to. Just reuse our existing piece
// so we don't have to push/pop.
currentPiece.element = sibling;
currentPiece.indexInParent = i;
// The sibling might have been a list. Move to it's first child.
moveToFirstChildIfList();
return;
}
}
// Didn't have a sibling for this element. Go up to our parent and get its sibling.
// Clear the data from the old piece. We don't want to keep any elements around
// unintentionally.
currentPiece.element = undefined;
currentPiece.indexInParent = -1;
// Point at the parent. if we move past the top of the path, then we're finished.
currentPieceIndex--;
}
}
function moveToFirstChildIfList(): void {
var element = pieces[currentPieceIndex].element;
if (isList(element)) {
// We cannot ever get an empty list in our piece path. Empty lists are 'shared' and
// we make sure to filter that out before pushing any children.
pushElement(childAt(element, 0), /*indexInParent:*/ 0);
}
}
function pushElement(element: ISyntaxElement, indexInParent: number): void {
currentPieceIndex++;
// Reuse an existing piece if we have one. Otherwise, push a new piece to our list.
if (currentPieceIndex === pieces.length) {
pieces.push(createSyntaxCursorPiece(element, indexInParent));
}
else {
var piece = pieces[currentPieceIndex];
piece.element = element;
piece.indexInParent = indexInParent;
}
}
function moveToFirstToken(): void {
while (!isFinished()) {
var element = pieces[currentPieceIndex].element;
if (isNode(element)) {
moveToFirstChild();
continue;
}
return;
}
}
function currentToken(): ISyntaxToken {
moveToFirstToken();
var element = currentNodeOrToken();
return <ISyntaxToken>element;
}
return {
pieces: pieces,
clean: clean,
isFinished: isFinished,
moveToFirstChild: moveToFirstChild,
moveToFirstToken: moveToFirstToken,
moveToNextSibling: moveToNextSibling,
currentNodeOrToken: currentNodeOrToken,
currentNode: currentNode,
currentToken: currentToken,
pushElement: pushElement,
deepCopyFrom: deepCopyFrom
};
}
}
-1
View File
@@ -378,7 +378,6 @@ module TypeScript {
export interface ISyntaxNode extends ISyntaxNodeOrToken {
__data: number;
__cachedTokens: ISyntaxToken[];
}
export interface IModuleReferenceSyntax extends ISyntaxNode {
+21 -43
View File
@@ -41,7 +41,7 @@ var interfaces: any = {
IPrimaryExpressionSyntax: 'IMemberExpressionSyntax',
};
var definitions:ITypeDefinition[] = [
var definitions: ITypeDefinition[] = [
<any>{
name: 'SourceUnitSyntax',
baseType: 'ISyntaxNode',
@@ -55,10 +55,10 @@ var definitions:ITypeDefinition[] = [
baseType: 'ISyntaxNode',
interfaces: ['IModuleReferenceSyntax'],
children: [
<any>{ name: 'requireKeyword', isToken: true, excludeFromAST: true },
<any>{ name: 'openParenToken', isToken: true, excludeFromAST: true },
<any>{ name: 'stringLiteral', isToken: true },
<any>{ name: 'closeParenToken', isToken: true, excludeFromAST: true }
<any>{ name: 'requireKeyword', isToken: true },
<any>{ name: 'openParenToken', isToken: true },
<any>{ name: 'expression', type: 'IExpressionSyntax' },
<any>{ name: 'closeParenToken', isToken: true }
],
isTypeScriptSpecific: true
},
@@ -275,7 +275,7 @@ var definitions:ITypeDefinition[] = [
children: [
<any>{ name: 'asyncKeyword', isToken: true, isOptional: true },
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
<any>{ name: 'equalsGreaterThanToken', isToken: true, excludeFromAST: true },
<any>{ name: 'equalsGreaterThanToken', isToken: true, isOptional: true },
<any>{ name: 'body', type: 'BlockSyntax | IExpressionSyntax' }
],
isTypeScriptSpecific: true
@@ -665,7 +665,7 @@ var definitions:ITypeDefinition[] = [
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
<any>{ name: 'constructorKeyword', isToken: true },
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
<any>{ name: 'body', type: 'BlockSyntax | ExpressionBody | ISyntaxToken', isOptional: true }
<any>{ name: 'body', type: 'BlockSyntax | ExpressionBody | ISyntaxToken', isOptional: true }
],
isTypeScriptSpecific: true
},
@@ -678,20 +678,20 @@ var definitions:ITypeDefinition[] = [
<any>{ name: 'asterixToken', isToken: true, isOptional: true },
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
<any>{ name: 'body', type: 'BlockSyntax | ExpressionBody | ISyntaxToken', isOptional: true }
<any>{ name: 'body', type: 'BlockSyntax | ExpressionBody | ISyntaxToken', isOptional: true }
],
isTypeScriptSpecific: true
},
<any>{
name: 'GetAccessorSyntax',
baseType: 'ISyntaxNode',
interfaces: ['IAccessorSyntax' ],
interfaces: ['IAccessorSyntax'],
children: [
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken', isTypeScriptSpecific: true },
<any>{ name: 'getKeyword', isToken: true, excludeFromAST: true },
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
<any>{ name: 'body', type: 'BlockSyntax | ExpressionBody | ISyntaxToken', isOptional: true }
<any>{ name: 'body', type: 'BlockSyntax | ExpressionBody | ISyntaxToken', isOptional: true }
]
},
<any>{
@@ -703,7 +703,7 @@ var definitions:ITypeDefinition[] = [
<any>{ name: 'setKeyword', isToken: true, excludeFromAST: true },
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
<any>{ name: 'body', type: 'BlockSyntax | ExpressionBody | ISyntaxToken', isOptional: true }
<any>{ name: 'body', type: 'BlockSyntax | ExpressionBody | ISyntaxToken', isOptional: true }
],
isTypeScriptSpecific: true
},
@@ -769,7 +769,7 @@ var definitions:ITypeDefinition[] = [
children: [
<any>{ name: 'caseKeyword', isToken: true, excludeFromAST: true },
<any>{ name: 'expression', type: 'IExpressionSyntax' },
<any>{ name: 'colonToken', isToken: true, excludeFromAST: true},
<any>{ name: 'colonToken', isToken: true, excludeFromAST: true },
<any>{ name: 'statements', isList: true, elementType: 'IStatementSyntax' }
]
},
@@ -931,7 +931,7 @@ var definitions:ITypeDefinition[] = [
<any>{ name: 'asterixToken', isToken: true, isOptional: true },
<any>{ name: 'identifier', isToken: true, isOptional: true },
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
<any>{ name: 'body', type: 'BlockSyntax | ExpressionBody | ISyntaxToken', isOptional: true }]
<any>{ name: 'body', type: 'BlockSyntax | ExpressionBody | ISyntaxToken', isOptional: true }]
},
<any>{
name: 'EmptyStatementSyntax',
@@ -1104,41 +1104,19 @@ function generateConstructorFunction(definition: ITypeDefinition) {
result += ") {\r\n";
result += " if (data) { this.__data = data; }\r\n";
result += " this.parent = undefined";
if (definition.children.length) {
result += " ";
for (var i = 0; i < definition.children.length; i++) {
if (i) {
result += ", ";
}
//if (i) {
result += ",\r\n";
//}
var child = definition.children[i];
result += "this." + child.name + " = " + getSafeName(child);
result += " this." + child.name + " = " + getSafeName(child);
}
result += ";\r\n";
}
if (definition.children.length > 0) {
result += " ";
for (var i = 0; i < definition.children.length; i++) {
if (i) {
result += ", ";
}
var child = definition.children[i];
if (child.isOptional) {
result += getSafeName(child) + " && (" + getSafeName(child) + ".parent = this)";
}
else {
result += getSafeName(child) + ".parent = this";
}
}
result += ";\r\n";
}
result += ";\r\n";
result += " };\r\n";
result += " " + definition.name + ".prototype.kind = SyntaxKind." + getNameWithoutSuffix(definition) + ";\r\n";
@@ -1202,7 +1180,7 @@ function generateSyntaxInterface(definition: ITypeDefinition): string {
result += " }\r\n";
result += " export interface " + getNameWithoutSuffix(definition) + "Constructor {";
result += " new (data: number";
for (var i = 0; i < definition.children.length; i++) {
var child = definition.children[i];
result += ", ";
@@ -1338,7 +1316,7 @@ function generateKeywordCondition(keywords: { text: string; kind: TypeScript.Syn
if (keywords.length === 1) {
var keyword = keywords[0];
if (currentCharacter === length) {
return " return SyntaxKind." + firstEnumName(getSyntaxKindEnum(), keyword.kind) + ";\r\n";
}
@@ -702,10 +702,10 @@ module TypeScript {
export interface ExternalModuleReferenceSyntax extends ISyntaxNode, IModuleReferenceSyntax {
requireKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
stringLiteral: ISyntaxToken;
expression: IExpressionSyntax;
closeParenToken: ISyntaxToken;
}
export interface ExternalModuleReferenceConstructor { new (data: number, requireKeyword: ISyntaxToken, openParenToken: ISyntaxToken, stringLiteral: ISyntaxToken, closeParenToken: ISyntaxToken): ExternalModuleReferenceSyntax }
export interface ExternalModuleReferenceConstructor { new (data: number, requireKeyword: ISyntaxToken, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken): ExternalModuleReferenceSyntax }
export interface ModuleNameModuleReferenceSyntax extends ISyntaxNode, IModuleReferenceSyntax {
moduleName: INameSyntax;
-12
View File
@@ -48,22 +48,10 @@ module TypeScript.Syntax {
addArrayPrototypeValue("kind", SyntaxKind.List);
export function list<T extends ISyntaxNodeOrToken>(nodes: T[]): T[] {
if (nodes !== undefined) {
for (var i = 0, n = nodes.length; i < n; i++) {
nodes[i].parent = nodes;
}
}
return nodes;
}
export function separatedList<T extends ISyntaxNodeOrToken>(nodesAndTokens: ISyntaxNodeOrToken[]): ISeparatedSyntaxList<T> {
if (nodesAndTokens !== undefined) {
for (var i = 0, n = nodesAndTokens.length; i < n; i++) {
nodesAndTokens[i].parent = nodesAndTokens;
}
}
return <ISeparatedSyntaxList<T>>nodesAndTokens;
}
}
File diff suppressed because it is too large Load Diff
+9 -75
View File
@@ -74,55 +74,11 @@ module TypeScript {
return this._languageVersion;
}
private cacheSyntaxTreeInfo(): void {
// If we're not keeping around the syntax tree, store the diagnostics and line
// map so they don't have to be recomputed.
var firstToken = firstSyntaxTreeToken(this);
var leadingTrivia = firstToken.leadingTrivia(this.text);
this._isExternalModule = !!externalModuleIndicatorSpanWorker(this, firstToken);
var amdDependencies: string[] = [];
for (var i = 0, n = leadingTrivia.count(); i < n; i++) {
var trivia = leadingTrivia.syntaxTriviaAt(i);
if (trivia.isComment()) {
var amdDependency = this.getAmdDependency(trivia.fullText());
if (amdDependency) {
amdDependencies.push(amdDependency);
}
}
}
this._amdDependencies = amdDependencies;
}
private getAmdDependency(comment: string): string {
var amdDependencyRegEx = /^\/\/\/\s*<amd-dependency\s+path=('|")(.+?)\1/gim;
var match = amdDependencyRegEx.exec(comment);
return match ? match[2] : undefined;
}
public isExternalModule(): boolean {
// October 11, 2013
// External modules are written as separate source files that contain at least one
// external import declaration, export assignment, or top-level exported declaration.
if (this._isExternalModule === undefined) {
// force the info about isExternalModule to get created.
this.cacheSyntaxTreeInfo();
Debug.assert(this._isExternalModule !== undefined);
}
return this._isExternalModule;
}
public amdDependencies(): string[] {
if (this._amdDependencies === undefined) {
this.cacheSyntaxTreeInfo();
Debug.assert(this._amdDependencies !== undefined);
}
return this._amdDependencies;
}
}
class GrammarCheckerWalker extends SyntaxWalker {
@@ -1033,6 +989,15 @@ module TypeScript {
super.visitExportAssignment(node);
}
public visitExternalModuleReference(node: ExternalModuleReferenceSyntax): void {
if (node.expression.kind !== SyntaxKind.StringLiteral) {
this.pushDiagnostic(node.expression, DiagnosticCode.String_literal_expected);
return;
}
super.visitExternalModuleReference(node);
}
public visitExpressionBody(node: ExpressionBody): void {
// These are always errors. So no need to ever recurse on them.
this.pushDiagnostic(node.equalsGreaterThanToken, DiagnosticCode._0_expected, ["{"]);
@@ -1741,16 +1706,6 @@ module TypeScript {
return scanner.scan(/*allowContextualToken:*/ false);
}
export function externalModuleIndicatorSpan(syntaxTree: SyntaxTree): TextSpan {
var firstToken = firstSyntaxTreeToken(syntaxTree);
return externalModuleIndicatorSpanWorker(syntaxTree, firstToken);
}
export function externalModuleIndicatorSpanWorker(syntaxTree: SyntaxTree, firstToken: ISyntaxToken) {
var leadingTrivia = firstToken.leadingTrivia(syntaxTree.text);
return implicitImportSpan(leadingTrivia) || topLevelImportOrExportSpan(syntaxTree.sourceUnit());
}
function implicitImportSpan(sourceUnitLeadingTrivia: ISyntaxTriviaList): TextSpan {
for (var i = 0, n = sourceUnitLeadingTrivia.count(); i < n; i++) {
var trivia = sourceUnitLeadingTrivia.syntaxTriviaAt(i);
@@ -1776,25 +1731,4 @@ module TypeScript {
return undefined;
}
function topLevelImportOrExportSpan(node: SourceUnitSyntax): TextSpan {
for (var i = 0, n = node.moduleElements.length; i < n; i++) {
var moduleElement = node.moduleElements[i];
var _firstToken = firstToken(moduleElement);
if (_firstToken && _firstToken.kind === SyntaxKind.ExportKeyword) {
return new TextSpan(start(_firstToken), width(_firstToken));
}
if (moduleElement.kind === SyntaxKind.ImportDeclaration) {
var importDecl = <ImportDeclarationSyntax>moduleElement;
if (importDecl.moduleReference.kind === SyntaxKind.ExternalModuleReference) {
var literal = (<TypeScript.ExternalModuleReferenceSyntax>importDecl.moduleReference).stringLiteral;
return new TextSpan(start(literal), width(literal));
}
}
}
return undefined;
}
}
+29 -47
View File
@@ -11,6 +11,35 @@ module TypeScript {
return (<ISyntaxNodeOrToken>element).childAt(index);
}
interface ISyntaxNodeInternal extends ISyntaxNode {
__cachedTokens: ISyntaxToken[];
}
class TokenCollectorWalker extends SyntaxWalker {
public tokens: ISyntaxToken[] = [];
public visitToken(token: ISyntaxToken): void {
this.tokens.push(token);
}
}
var tokenCollectorWalker = new TokenCollectorWalker();
export function getTokens(node: ISyntaxNode): ISyntaxToken[] {
var tokens = (<ISyntaxNodeInternal>node).__cachedTokens;
if (!tokens) {
tokens = [];
tokenCollectorWalker.tokens = tokens;
visitNodeOrToken(tokenCollectorWalker, node);
(<ISyntaxNodeInternal>node).__cachedTokens = tokens;
tokenCollectorWalker.tokens = undefined;
}
return tokens;
}
export module SyntaxUtilities {
export function isAnyFunctionExpressionOrDeclaration(ast: ISyntaxElement): boolean {
switch (ast.kind) {
@@ -28,19 +57,6 @@ module TypeScript {
return false;
}
export function isLastTokenOnLine(token: ISyntaxToken, text: ISimpleText): boolean {
var _nextToken = nextToken(token, text);
if (_nextToken === undefined) {
return true;
}
var lineMap = text.lineMap();
var tokenLine = lineMap.getLineNumberFromPosition(fullEnd(token));
var nextTokenLine = lineMap.getLineNumberFromPosition(start(_nextToken, text));
return tokenLine !== nextTokenLine;
}
export function isLeftHandSizeExpression(element: ISyntaxElement) {
if (element) {
switch (element.kind) {
@@ -178,21 +194,6 @@ module TypeScript {
return false;
}
export function isAngleBracket(positionedElement: ISyntaxElement): boolean {
var element = positionedElement;
var parent = positionedElement.parent;
if (parent && (element.kind === SyntaxKind.LessThanToken || element.kind === SyntaxKind.GreaterThanToken)) {
switch (parent.kind) {
case SyntaxKind.TypeArgumentList:
case SyntaxKind.TypeParameterList:
case SyntaxKind.TypeAssertionExpression:
return true;
}
}
return false;
}
export function getToken(list: ISyntaxToken[], kind: SyntaxKind): ISyntaxToken {
for (var i = 0, n = list.length; i < n; i++) {
var token = list[i];
@@ -207,24 +208,5 @@ module TypeScript {
export function containsToken(list: ISyntaxToken[], kind: SyntaxKind): boolean {
return !!SyntaxUtilities.getToken(list, kind);
}
export function hasExportKeyword(moduleElement: IModuleElementSyntax): boolean {
return !!SyntaxUtilities.getExportKeyword(moduleElement);
}
export function getExportKeyword(moduleElement: IModuleElementSyntax): ISyntaxToken {
switch (moduleElement.kind) {
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.VariableStatement:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.ImportDeclaration:
return SyntaxUtilities.getToken((<any>moduleElement).modifiers, SyntaxKind.ExportKeyword);
default:
return undefined;
}
}
}
}
@@ -428,7 +428,7 @@ module TypeScript {
public visitParenthesizedArrowFunctionExpression(node: ParenthesizedArrowFunctionExpressionSyntax): void {
this.visitOptionalToken(node.asyncKeyword);
visitNodeOrToken(this, node.callSignature);
this.visitToken(node.equalsGreaterThanToken);
this.visitOptionalToken(node.equalsGreaterThanToken);
visitNodeOrToken(this, node.body);
}
@@ -627,7 +627,7 @@ module TypeScript {
public visitExternalModuleReference(node: ExternalModuleReferenceSyntax): void {
this.visitToken(node.requireKeyword);
this.visitToken(node.openParenToken);
this.visitToken(node.stringLiteral);
visitNodeOrToken(this, node.expression);
this.visitToken(node.closeParenToken);
}
-15
View File
@@ -104,21 +104,6 @@ module ts {
return syntaxList;
}
/**
* Includes the start position of each child, but excludes the end.
*/
export function findListItemIndexContainingPosition(list: Node, position: number): number {
Debug.assert(list.kind === SyntaxKind.SyntaxList);
var children = list.getChildren();
for (var i = 0; i < children.length; i++) {
if (children[i].pos <= position && children[i].end > position) {
return i;
}
}
return -1;
}
/* Gets the token whose text has range [start, end) and
* position >= start and (position < end or (position === end && token is keyword or identifier))
*/
@@ -1,15 +1,12 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,12): error TS1005: ',' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,14): error TS1005: ';' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,10): error TS2304: Cannot find name 'a'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,14): error TS1110: Type expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,13): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts (3 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts (2 errors) ====
var v = (a): => {
~
!!! error TS1005: ',' expected.
~~
!!! error TS1005: ';' expected.
~
!!! error TS2304: Cannot find name 'a'.
!!! error TS1110: Type expected.
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
};
@@ -1,10 +1,7 @@
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: 'generators' are not currently supported.
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (2 errors) ====
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (1 errors) ====
var v = { *[foo()]() { } }
~
!!! error TS9001: 'generators' are not currently supported.
~~~~~~~
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
!!! error TS9001: 'generators' are not currently supported.
@@ -1,19 +1,10 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,9): error TS1127: Invalid character.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,1): error TS2304: Cannot find name 'Foo'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,5): error TS2304: Cannot find name 'A'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,7): error TS2304: Cannot find name 'B'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,11): error TS2304: Cannot find name 'C'.
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts (5 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts (2 errors) ====
Foo<A,B,\ C>(4, 5, 6);
!!! error TS1127: Invalid character.
~~~
!!! error TS2304: Cannot find name 'Foo'.
~
!!! error TS2304: Cannot find name 'A'.
~
!!! error TS2304: Cannot find name 'B'.
~
!!! error TS2304: Cannot find name 'C'.
!!! error TS2304: Cannot find name 'Foo'.
@@ -1,7 +1,7 @@
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration6_es6.ts(1,4): error TS1123: Variable declaration list cannot be empty.
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration6_es6.ts(1,1): error TS2304: Cannot find name 'let'.
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration6_es6.ts (1 errors) ====
let
!!! error TS1123: Variable declaration list cannot be empty.
~~~
!!! error TS2304: Cannot find name 'let'.
@@ -0,0 +1,5 @@
//// [VariableDeclaration6_es6.ts]
let
//// [VariableDeclaration6_es6.js]
let;
@@ -0,0 +1,7 @@
tests/cases/compiler/accessorWithoutBody1.ts(1,19): error TS1005: '{' expected.
==== tests/cases/compiler/accessorWithoutBody1.ts (1 errors) ====
var v = { get foo() }
~
!!! error TS1005: '{' expected.
@@ -0,0 +1,7 @@
tests/cases/compiler/accessorWithoutBody2.ts(1,20): error TS1005: '{' expected.
==== tests/cases/compiler/accessorWithoutBody2.ts (1 errors) ====
var v = { set foo(a) }
~
!!! error TS1005: '{' expected.
@@ -32,8 +32,8 @@ function foo(animals: IAnimal[]) { }
>IAnimal : IAnimal
function bar(animals: { [n: number]: IAnimal }) { }
>bar : (animals: { [x: number]: IAnimal; }) => void
>animals : { [x: number]: IAnimal; }
>bar : (animals: { [n: number]: IAnimal; }) => void
>animals : { [n: number]: IAnimal; }
>n : number
>IAnimal : IAnimal
@@ -53,7 +53,7 @@ foo([
]); // Legal because of the contextual type IAnimal provided by the parameter
bar([
>bar([ new Giraffe(), new Elephant()]) : void
>bar : (animals: { [x: number]: IAnimal; }) => void
>bar : (animals: { [n: number]: IAnimal; }) => void
>[ new Giraffe(), new Elephant()] : (Giraffe | Elephant)[]
new Giraffe(),
@@ -81,6 +81,6 @@ foo(arr); // ok because arr is Array<Giraffe|Elephant> not {}[]
bar(arr); // ok because arr is Array<Giraffe|Elephant> not {}[]
>bar(arr) : void
>bar : (animals: { [x: number]: IAnimal; }) => void
>bar : (animals: { [n: number]: IAnimal; }) => void
>arr : (Giraffe | Elephant)[]
@@ -61,7 +61,7 @@ var classTypeArray: Array<typeof C>; // Should OK, not be a parse error
// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[]
var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
>context1 : { [x: number]: { a: string; b: number; }; }
>context1 : { [n: number]: { a: string; b: number; }; }
>n : number
>a : string
>b : number
@@ -132,18 +132,16 @@ x = i;
>i : () => string
x = { f() { return 1; } }
>x = { f() { return 1; } } : { f: () => number; }
>x = { f() { return 1; } } : { f(): number; }
>x : any
>{ f() { return 1; } } : { f: () => number; }
>{ f() { return 1; } } : { f(): number; }
>f : () => number
>f() { return 1; } : () => number
x = { f<T>(x: T) { return x; } }
>x = { f<T>(x: T) { return x; } } : { f: <T>(x: T) => T; }
>x = { f<T>(x: T) { return x; } } : { f<T>(x: T): T; }
>x : any
>{ f<T>(x: T) { return x; } } : { f: <T>(x: T) => T; }
>{ f<T>(x: T) { return x; } } : { f<T>(x: T): T; }
>f : <T>(x: T) => T
>f<T>(x: T) { return x; } : <T>(x: T) => T
>T : T
>x : T
>T : T
@@ -1,6 +1,6 @@
tests/cases/compiler/assignmentCompat1.ts(4,1): error TS2322: Type '{ [x: string]: any; }' is not assignable to type '{ one: number; }'.
Property 'one' is missing in type '{ [x: string]: any; }'.
tests/cases/compiler/assignmentCompat1.ts(5,1): error TS2322: Type '{ one: number; }' is not assignable to type '{ [x: string]: any; }'.
tests/cases/compiler/assignmentCompat1.ts(4,1): error TS2322: Type '{ [index: string]: any; }' is not assignable to type '{ one: number; }'.
Property 'one' is missing in type '{ [index: string]: any; }'.
tests/cases/compiler/assignmentCompat1.ts(5,1): error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: any; }'.
Index signature is missing in type '{ one: number; }'.
@@ -10,9 +10,9 @@ tests/cases/compiler/assignmentCompat1.ts(5,1): error TS2322: Type '{ one: numbe
x = y;
~
!!! error TS2322: Type '{ [x: string]: any; }' is not assignable to type '{ one: number; }'.
!!! error TS2322: Property 'one' is missing in type '{ [x: string]: any; }'.
!!! error TS2322: Type '{ [index: string]: any; }' is not assignable to type '{ one: number; }'.
!!! error TS2322: Property 'one' is missing in type '{ [index: string]: any; }'.
y = x;
~
!!! error TS2322: Type '{ one: number; }' is not assignable to type '{ [x: string]: any; }'.
!!! error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: any; }'.
!!! error TS2322: Index signature is missing in type '{ one: number; }'.
@@ -1,4 +1,4 @@
tests/cases/compiler/assignmentCompatability35.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [x: number]: number; }'.
tests/cases/compiler/assignmentCompatability35.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [index: number]: number; }'.
Index signature is missing in type 'interfaceWithPublicAndOptional<number, string>'.
@@ -13,5 +13,5 @@ tests/cases/compiler/assignmentCompatability35.ts(9,1): error TS2322: Type 'inte
}
__test2__.__val__aa = __test1__.__val__obj4
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [x: number]: number; }'.
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [index: number]: number; }'.
!!! error TS2322: Index signature is missing in type 'interfaceWithPublicAndOptional<number, string>'.
@@ -1,4 +1,4 @@
tests/cases/compiler/assignmentCompatability36.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [x: string]: any; }'.
tests/cases/compiler/assignmentCompatability36.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [index: string]: any; }'.
Index signature is missing in type 'interfaceWithPublicAndOptional<number, string>'.
@@ -13,5 +13,5 @@ tests/cases/compiler/assignmentCompatability36.ts(9,1): error TS2322: Type 'inte
}
__test2__.__val__aa = __test1__.__val__obj4
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [x: string]: any; }'.
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [index: string]: any; }'.
!!! error TS2322: Index signature is missing in type 'interfaceWithPublicAndOptional<number, string>'.
@@ -1,6 +1,6 @@
tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts(15,5): error TS2322: Type '{}' is not assignable to type '{ [x: number]: Foo; }'.
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 '{ [x: number]: Bar; }'.
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'.
@@ -21,14 +21,14 @@ tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignatur
var v1: {
~~
!!! error TS2322: Type '{}' is not assignable to type '{ [x: number]: Foo; }'.
!!! 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
var v2: {
~~
!!! error TS2322: Type '() => void' is not assignable to type '{ [x: number]: Bar; }'.
!!! error TS2322: Type '() => void' is not assignable to type '{ [n: number]: Bar; }'.
!!! error TS2322: Index signature is missing in type '() => void'.
[n: number]: Bar
} = f; // Should be allowed
@@ -3,8 +3,8 @@ function method() {
>method : () => void
var dictionary = <{ [index: string]: string; }>{};
>dictionary : { [x: string]: string; }
><{ [index: string]: string; }>{} : { [x: string]: string; }
>dictionary : { [index: string]: string; }
><{ [index: string]: string; }>{} : { [index: string]: string; }
>index : string
>{} : { [x: string]: undefined; }
}
@@ -33,7 +33,7 @@ var arr: Contextual[] = [e]; // Ellement[]
>e : Ellement
var obj: { [s: string]: Contextual } = { s: e }; // { s: Ellement; [s: string]: Ellement }
>obj : { [x: string]: Contextual; }
>obj : { [s: string]: Contextual; }
>s : string
>Contextual : Contextual
>{ s: e } : { [x: string]: Ellement; s: Ellement; }
@@ -0,0 +1,10 @@
tests/cases/compiler/callExpressionWithMissingTypeArgument1.ts(1,7): error TS1110: Type expected.
tests/cases/compiler/callExpressionWithMissingTypeArgument1.ts(1,1): error TS2304: Cannot find name 'Foo'.
==== tests/cases/compiler/callExpressionWithMissingTypeArgument1.ts (2 errors) ====
Foo<a,,b>();
~
!!! error TS1110: Type expected.
~~~
!!! error TS2304: Cannot find name 'Foo'.
@@ -133,12 +133,11 @@ a.foo(1);
>foo : (x?: number) => any
var b = {
>b : { foo: (x?: number) => void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>{ foo(x?: number) { }, a: function foo(x: number, y?: number) { }, b: (x?: number) => { }} : { foo: (x?: number) => void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>{ foo(x?: number) { }, a: function foo(x: number, y?: number) { }, b: (x?: number) => { }} : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
foo(x?: number) { },
>foo : (x?: number) => void
>foo(x?: number) { } : (x?: number) => void
>x : number
a: function foo(x: number, y?: number) { },
@@ -157,36 +156,36 @@ var b = {
b.foo();
>b.foo() : void
>b.foo : (x?: number) => void
>b : { foo: (x?: number) => void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>foo : (x?: number) => void
b.foo(1);
>b.foo(1) : void
>b.foo : (x?: number) => void
>b : { foo: (x?: number) => void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>foo : (x?: number) => void
b.a(1);
>b.a(1) : void
>b.a : (x: number, y?: number) => void
>b : { foo: (x?: number) => void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>a : (x: number, y?: number) => void
b.a(1, 2);
>b.a(1, 2) : void
>b.a : (x: number, y?: number) => void
>b : { foo: (x?: number) => void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>a : (x: number, y?: number) => void
b.b();
>b.b() : void
>b.b : (x?: number) => void
>b : { foo: (x?: number) => void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>b : (x?: number) => void
b.b(1);
>b.b(1) : void
>b.b : (x?: number) => void
>b : { foo: (x?: number) => void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; }
>b : (x?: number) => void
@@ -1,8 +1,8 @@
=== tests/cases/compiler/commentsOnObjectLiteral3.ts ===
var v = {
>v : { prop: number; func: () => void; func1: () => void; a: any; }
>{ //property prop: 1 /* multiple trailing comments */ /*trailing comments*/, //property func: function () { }, //PropertyName + CallSignature func1() { }, //getter get a() { return this.prop; } /*trailing 1*/, //setter set a(value) { this.prop = value; } // trailing 2} : { prop: number; func: () => void; func1: () => void; a: any; }
>v : { prop: number; func: () => void; func1(): void; a: any; }
>{ //property prop: 1 /* multiple trailing comments */ /*trailing comments*/, //property func: function () { }, //PropertyName + CallSignature func1() { }, //getter get a() { return this.prop; } /*trailing 1*/, //setter set a(value) { this.prop = value; } // trailing 2} : { prop: number; func: () => void; func1(): void; a: any; }
//property
prop: 1 /* multiple trailing comments */ /*trailing comments*/,
@@ -17,7 +17,6 @@ var v = {
//PropertyName + CallSignature
func1() { },
>func1 : () => void
>func1() { } : () => void
//getter
get a() {
@@ -1,67 +1,67 @@
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(26,12): error TS2365: Operator '<' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(27,12): error TS2365: Operator '<' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(28,12): error TS2365: Operator '<' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(29,12): error TS2365: Operator '<' cannot be applied to types '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(31,12): error TS2365: Operator '<' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(32,12): error TS2365: Operator '<' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(33,12): error TS2365: Operator '<' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(34,12): error TS2365: Operator '<' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(37,12): error TS2365: Operator '>' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(38,12): error TS2365: Operator '>' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(39,12): error TS2365: Operator '>' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(40,12): error TS2365: Operator '>' cannot be applied to types '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(42,12): error TS2365: Operator '>' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(43,12): error TS2365: Operator '>' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(44,12): error TS2365: Operator '>' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(45,12): error TS2365: Operator '>' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(48,12): error TS2365: Operator '<=' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(49,12): error TS2365: Operator '<=' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(50,12): error TS2365: Operator '<=' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(51,12): error TS2365: Operator '<=' cannot be applied to types '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(53,12): error TS2365: Operator '<=' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(54,12): error TS2365: Operator '<=' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(55,12): error TS2365: Operator '<=' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(56,12): error TS2365: Operator '<=' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(59,12): error TS2365: Operator '>=' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(60,12): error TS2365: Operator '>=' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(61,12): error TS2365: Operator '>=' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(62,12): error TS2365: Operator '>=' cannot be applied to types '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(64,12): error TS2365: Operator '>=' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(65,12): error TS2365: Operator '>=' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(66,12): error TS2365: Operator '>=' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(67,12): error TS2365: Operator '>=' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(70,12): error TS2365: Operator '==' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(71,12): error TS2365: Operator '==' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(72,12): error TS2365: Operator '==' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(73,12): error TS2365: Operator '==' cannot be applied to types '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(75,12): error TS2365: Operator '==' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(76,12): error TS2365: Operator '==' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(77,12): error TS2365: Operator '==' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(78,12): error TS2365: Operator '==' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(81,12): error TS2365: Operator '!=' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(82,12): error TS2365: Operator '!=' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(83,12): error TS2365: Operator '!=' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(84,12): error TS2365: Operator '!=' cannot be applied to types '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(86,12): error TS2365: Operator '!=' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(87,12): error TS2365: Operator '!=' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(88,12): error TS2365: Operator '!=' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(89,12): error TS2365: Operator '!=' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(92,12): error TS2365: Operator '===' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(93,12): error TS2365: Operator '===' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(94,12): error TS2365: Operator '===' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(95,12): error TS2365: Operator '===' cannot be applied to types '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(97,12): error TS2365: Operator '===' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(98,12): error TS2365: Operator '===' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(99,12): error TS2365: Operator '===' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(100,12): error TS2365: Operator '===' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(103,12): error TS2365: Operator '!==' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(104,12): error TS2365: Operator '!==' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(105,12): error TS2365: Operator '!==' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(106,12): error TS2365: Operator '!==' cannot be applied to types '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(108,12): error TS2365: Operator '!==' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(109,12): error TS2365: Operator '!==' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(110,12): error TS2365: Operator '!==' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(111,12): error TS2365: Operator '!==' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
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) ====
@@ -92,215 +92,215 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso
// operator <
var r1a1 = a1 < b1;
~~~~~~~
!!! error TS2365: Operator '<' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
!!! error TS2365: Operator '<' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'.
var r1a2 = a2 < b2;
~~~~~~~
!!! error TS2365: Operator '<' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
!!! error TS2365: Operator '<' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'.
var r1a3 = a3 < b3;
~~~~~~~
!!! error TS2365: Operator '<' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
!!! 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 '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '<' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'.
var r1b1 = b1 < a1;
~~~~~~~
!!! error TS2365: Operator '<' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
!!! error TS2365: Operator '<' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'.
var r1b2 = b2 < a2;
~~~~~~~
!!! error TS2365: Operator '<' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '<' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'.
var r1b3 = b3 < a3;
~~~~~~~
!!! error TS2365: Operator '<' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
!!! 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 '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
!!! error TS2365: Operator '<' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'.
// operator >
var r2a1 = a1 > b1;
~~~~~~~
!!! error TS2365: Operator '>' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
!!! error TS2365: Operator '>' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'.
var r2a2 = a2 > b2;
~~~~~~~
!!! error TS2365: Operator '>' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
!!! error TS2365: Operator '>' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'.
var r2a3 = a3 > b3;
~~~~~~~
!!! error TS2365: Operator '>' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
!!! 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 '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '>' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'.
var r2b1 = b1 > a1;
~~~~~~~
!!! error TS2365: Operator '>' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
!!! error TS2365: Operator '>' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'.
var r2b2 = b2 > a2;
~~~~~~~
!!! error TS2365: Operator '>' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '>' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'.
var r2b3 = b3 > a3;
~~~~~~~
!!! error TS2365: Operator '>' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
!!! 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 '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
!!! error TS2365: Operator '>' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'.
// operator <=
var r3a1 = a1 <= b1;
~~~~~~~~
!!! error TS2365: Operator '<=' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
!!! error TS2365: Operator '<=' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'.
var r3a2 = a2 <= b2;
~~~~~~~~
!!! error TS2365: Operator '<=' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
!!! error TS2365: Operator '<=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'.
var r3a3 = a3 <= b3;
~~~~~~~~
!!! error TS2365: Operator '<=' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
!!! 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 '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '<=' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'.
var r3b1 = b1 <= a1;
~~~~~~~~
!!! error TS2365: Operator '<=' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
!!! error TS2365: Operator '<=' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'.
var r3b2 = b2 <= a2;
~~~~~~~~
!!! error TS2365: Operator '<=' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '<=' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'.
var r3b3 = b3 <= a3;
~~~~~~~~
!!! error TS2365: Operator '<=' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
!!! 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 '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
!!! error TS2365: Operator '<=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'.
// operator >=
var r4a1 = a1 >= b1;
~~~~~~~~
!!! error TS2365: Operator '>=' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
!!! error TS2365: Operator '>=' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'.
var r4a2 = a2 >= b2;
~~~~~~~~
!!! error TS2365: Operator '>=' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
!!! error TS2365: Operator '>=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'.
var r4a3 = a3 >= b3;
~~~~~~~~
!!! error TS2365: Operator '>=' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
!!! 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 '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '>=' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'.
var r4b1 = b1 >= a1;
~~~~~~~~
!!! error TS2365: Operator '>=' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
!!! error TS2365: Operator '>=' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'.
var r4b2 = b2 >= a2;
~~~~~~~~
!!! error TS2365: Operator '>=' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '>=' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'.
var r4b3 = b3 >= a3;
~~~~~~~~
!!! error TS2365: Operator '>=' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
!!! 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 '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
!!! error TS2365: Operator '>=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'.
// operator ==
var r5a1 = a1 == b1;
~~~~~~~~
!!! error TS2365: Operator '==' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
!!! error TS2365: Operator '==' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'.
var r5a2 = a2 == b2;
~~~~~~~~
!!! error TS2365: Operator '==' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
!!! error TS2365: Operator '==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'.
var r5a3 = a3 == b3;
~~~~~~~~
!!! error TS2365: Operator '==' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
!!! 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 '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '==' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'.
var r5b1 = b1 == a1;
~~~~~~~~
!!! error TS2365: Operator '==' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
!!! error TS2365: Operator '==' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'.
var r5b2 = b2 == a2;
~~~~~~~~
!!! error TS2365: Operator '==' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '==' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'.
var r5b3 = b3 == a3;
~~~~~~~~
!!! error TS2365: Operator '==' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
!!! 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 '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
!!! error TS2365: Operator '==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'.
// operator !=
var r6a1 = a1 != b1;
~~~~~~~~
!!! error TS2365: Operator '!=' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
!!! error TS2365: Operator '!=' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'.
var r6a2 = a2 != b2;
~~~~~~~~
!!! error TS2365: Operator '!=' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
!!! error TS2365: Operator '!=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'.
var r6a3 = a3 != b3;
~~~~~~~~
!!! error TS2365: Operator '!=' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
!!! 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 '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '!=' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'.
var r6b1 = b1 != a1;
~~~~~~~~
!!! error TS2365: Operator '!=' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
!!! error TS2365: Operator '!=' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'.
var r6b2 = b2 != a2;
~~~~~~~~
!!! error TS2365: Operator '!=' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '!=' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'.
var r6b3 = b3 != a3;
~~~~~~~~
!!! error TS2365: Operator '!=' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
!!! 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 '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
!!! error TS2365: Operator '!=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'.
// operator ===
var r7a1 = a1 === b1;
~~~~~~~~~
!!! error TS2365: Operator '===' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
!!! error TS2365: Operator '===' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'.
var r7a2 = a2 === b2;
~~~~~~~~~
!!! error TS2365: Operator '===' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
!!! error TS2365: Operator '===' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'.
var r7a3 = a3 === b3;
~~~~~~~~~
!!! error TS2365: Operator '===' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
!!! 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 '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '===' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'.
var r7b1 = b1 === a1;
~~~~~~~~~
!!! error TS2365: Operator '===' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
!!! error TS2365: Operator '===' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'.
var r7b2 = b2 === a2;
~~~~~~~~~
!!! error TS2365: Operator '===' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '===' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'.
var r7b3 = b3 === a3;
~~~~~~~~~
!!! error TS2365: Operator '===' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
!!! 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 '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
!!! error TS2365: Operator '===' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'.
// operator !==
var r8a1 = a1 !== b1;
~~~~~~~~~
!!! error TS2365: Operator '!==' cannot be applied to types '{ [x: string]: string; }' and '{ [x: string]: number; }'.
!!! error TS2365: Operator '!==' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'.
var r8a2 = a2 !== b2;
~~~~~~~~~
!!! error TS2365: Operator '!==' cannot be applied to types '{ [x: string]: Base; }' and '{ [x: string]: C; }'.
!!! error TS2365: Operator '!==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'.
var r8a3 = a3 !== b3;
~~~~~~~~~
!!! error TS2365: Operator '!==' cannot be applied to types '{ [x: number]: Base; }' and '{ [x: number]: C; }'.
!!! 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 '{ [x: number]: Derived; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '!==' cannot be applied to types '{ [index: number]: Derived; }' and '{ [index: string]: Base; }'.
var r8b1 = b1 !== a1;
~~~~~~~~~
!!! error TS2365: Operator '!==' cannot be applied to types '{ [x: string]: number; }' and '{ [x: string]: string; }'.
!!! error TS2365: Operator '!==' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'.
var r8b2 = b2 !== a2;
~~~~~~~~~
!!! error TS2365: Operator '!==' cannot be applied to types '{ [x: string]: C; }' and '{ [x: string]: Base; }'.
!!! error TS2365: Operator '!==' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'.
var r8b3 = b3 !== a3;
~~~~~~~~~
!!! error TS2365: Operator '!==' cannot be applied to types '{ [x: number]: C; }' and '{ [x: number]: Base; }'.
!!! 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 '{ [x: string]: Base; }' and '{ [x: number]: Derived; }'.
!!! error TS2365: Operator '!==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: number]: Derived; }'.
@@ -15,38 +15,38 @@ class Derived extends Base {
}
var a1: { [a: string]: string };
>a1 : { [x: string]: string; }
>a1 : { [a: string]: string; }
>a : string
var b1: { [b: string]: string };
>b1 : { [x: string]: string; }
>b1 : { [b: string]: string; }
>b : string
var a2: { [index: string]: Base };
>a2 : { [x: string]: Base; }
>a2 : { [index: string]: Base; }
>index : string
>Base : Base
var b2: { [index: string]: Derived };
>b2 : { [x: string]: Derived; }
>b2 : { [index: string]: Derived; }
>index : string
>Derived : Derived
var a3: { [index: number]: string };
>a3 : { [x: number]: string; }
>a3 : { [index: number]: string; }
>index : number
var b3: { [index: number]: string };
>b3 : { [x: number]: string; }
>b3 : { [index: number]: string; }
>index : number
var a4: { [index: number]: Base };
>a4 : { [x: number]: Base; }
>a4 : { [index: number]: Base; }
>index : number
>Base : Base
var b4: { [index: string]: Derived };
>b4 : { [x: string]: Derived; }
>b4 : { [index: string]: Derived; }
>index : string
>Derived : Derived
@@ -54,391 +54,391 @@ var b4: { [index: string]: Derived };
var r1a1 = a1 < b1;
>r1a1 : boolean
>a1 < b1 : boolean
>a1 : { [x: string]: string; }
>b1 : { [x: string]: string; }
>a1 : { [a: string]: string; }
>b1 : { [b: string]: string; }
var r1a1 = a2 < b2;
>r1a1 : boolean
>a2 < b2 : boolean
>a2 : { [x: string]: Base; }
>b2 : { [x: string]: Derived; }
>a2 : { [index: string]: Base; }
>b2 : { [index: string]: Derived; }
var r1a1 = a3 < b3;
>r1a1 : boolean
>a3 < b3 : boolean
>a3 : { [x: number]: string; }
>b3 : { [x: number]: string; }
>a3 : { [index: number]: string; }
>b3 : { [index: number]: string; }
var r1a1 = a4 < b4;
>r1a1 : boolean
>a4 < b4 : boolean
>a4 : { [x: number]: Base; }
>b4 : { [x: string]: Derived; }
>a4 : { [index: number]: Base; }
>b4 : { [index: string]: Derived; }
var r1b1 = b1 < a1;
>r1b1 : boolean
>b1 < a1 : boolean
>b1 : { [x: string]: string; }
>a1 : { [x: string]: string; }
>b1 : { [b: string]: string; }
>a1 : { [a: string]: string; }
var r1b1 = b2 < a2;
>r1b1 : boolean
>b2 < a2 : boolean
>b2 : { [x: string]: Derived; }
>a2 : { [x: string]: Base; }
>b2 : { [index: string]: Derived; }
>a2 : { [index: string]: Base; }
var r1b1 = b3 < a3;
>r1b1 : boolean
>b3 < a3 : boolean
>b3 : { [x: number]: string; }
>a3 : { [x: number]: string; }
>b3 : { [index: number]: string; }
>a3 : { [index: number]: string; }
var r1b1 = b4 < a4;
>r1b1 : boolean
>b4 < a4 : boolean
>b4 : { [x: string]: Derived; }
>a4 : { [x: number]: Base; }
>b4 : { [index: string]: Derived; }
>a4 : { [index: number]: Base; }
// operator >
var r2a1 = a1 > b1;
>r2a1 : boolean
>a1 > b1 : boolean
>a1 : { [x: string]: string; }
>b1 : { [x: string]: string; }
>a1 : { [a: string]: string; }
>b1 : { [b: string]: string; }
var r2a1 = a2 > b2;
>r2a1 : boolean
>a2 > b2 : boolean
>a2 : { [x: string]: Base; }
>b2 : { [x: string]: Derived; }
>a2 : { [index: string]: Base; }
>b2 : { [index: string]: Derived; }
var r2a1 = a3 > b3;
>r2a1 : boolean
>a3 > b3 : boolean
>a3 : { [x: number]: string; }
>b3 : { [x: number]: string; }
>a3 : { [index: number]: string; }
>b3 : { [index: number]: string; }
var r2a1 = a4 > b4;
>r2a1 : boolean
>a4 > b4 : boolean
>a4 : { [x: number]: Base; }
>b4 : { [x: string]: Derived; }
>a4 : { [index: number]: Base; }
>b4 : { [index: string]: Derived; }
var r2b1 = b1 > a1;
>r2b1 : boolean
>b1 > a1 : boolean
>b1 : { [x: string]: string; }
>a1 : { [x: string]: string; }
>b1 : { [b: string]: string; }
>a1 : { [a: string]: string; }
var r2b1 = b2 > a2;
>r2b1 : boolean
>b2 > a2 : boolean
>b2 : { [x: string]: Derived; }
>a2 : { [x: string]: Base; }
>b2 : { [index: string]: Derived; }
>a2 : { [index: string]: Base; }
var r2b1 = b3 > a3;
>r2b1 : boolean
>b3 > a3 : boolean
>b3 : { [x: number]: string; }
>a3 : { [x: number]: string; }
>b3 : { [index: number]: string; }
>a3 : { [index: number]: string; }
var r2b1 = b4 > a4;
>r2b1 : boolean
>b4 > a4 : boolean
>b4 : { [x: string]: Derived; }
>a4 : { [x: number]: Base; }
>b4 : { [index: string]: Derived; }
>a4 : { [index: number]: Base; }
// operator <=
var r3a1 = a1 <= b1;
>r3a1 : boolean
>a1 <= b1 : boolean
>a1 : { [x: string]: string; }
>b1 : { [x: string]: string; }
>a1 : { [a: string]: string; }
>b1 : { [b: string]: string; }
var r3a1 = a2 <= b2;
>r3a1 : boolean
>a2 <= b2 : boolean
>a2 : { [x: string]: Base; }
>b2 : { [x: string]: Derived; }
>a2 : { [index: string]: Base; }
>b2 : { [index: string]: Derived; }
var r3a1 = a3 <= b3;
>r3a1 : boolean
>a3 <= b3 : boolean
>a3 : { [x: number]: string; }
>b3 : { [x: number]: string; }
>a3 : { [index: number]: string; }
>b3 : { [index: number]: string; }
var r3a1 = a4 <= b4;
>r3a1 : boolean
>a4 <= b4 : boolean
>a4 : { [x: number]: Base; }
>b4 : { [x: string]: Derived; }
>a4 : { [index: number]: Base; }
>b4 : { [index: string]: Derived; }
var r3b1 = b1 <= a1;
>r3b1 : boolean
>b1 <= a1 : boolean
>b1 : { [x: string]: string; }
>a1 : { [x: string]: string; }
>b1 : { [b: string]: string; }
>a1 : { [a: string]: string; }
var r3b1 = b2 <= a2;
>r3b1 : boolean
>b2 <= a2 : boolean
>b2 : { [x: string]: Derived; }
>a2 : { [x: string]: Base; }
>b2 : { [index: string]: Derived; }
>a2 : { [index: string]: Base; }
var r3b1 = b3 <= a3;
>r3b1 : boolean
>b3 <= a3 : boolean
>b3 : { [x: number]: string; }
>a3 : { [x: number]: string; }
>b3 : { [index: number]: string; }
>a3 : { [index: number]: string; }
var r3b1 = b4 <= a4;
>r3b1 : boolean
>b4 <= a4 : boolean
>b4 : { [x: string]: Derived; }
>a4 : { [x: number]: Base; }
>b4 : { [index: string]: Derived; }
>a4 : { [index: number]: Base; }
// operator >=
var r4a1 = a1 >= b1;
>r4a1 : boolean
>a1 >= b1 : boolean
>a1 : { [x: string]: string; }
>b1 : { [x: string]: string; }
>a1 : { [a: string]: string; }
>b1 : { [b: string]: string; }
var r4a1 = a2 >= b2;
>r4a1 : boolean
>a2 >= b2 : boolean
>a2 : { [x: string]: Base; }
>b2 : { [x: string]: Derived; }
>a2 : { [index: string]: Base; }
>b2 : { [index: string]: Derived; }
var r4a1 = a3 >= b3;
>r4a1 : boolean
>a3 >= b3 : boolean
>a3 : { [x: number]: string; }
>b3 : { [x: number]: string; }
>a3 : { [index: number]: string; }
>b3 : { [index: number]: string; }
var r4a1 = a4 >= b4;
>r4a1 : boolean
>a4 >= b4 : boolean
>a4 : { [x: number]: Base; }
>b4 : { [x: string]: Derived; }
>a4 : { [index: number]: Base; }
>b4 : { [index: string]: Derived; }
var r4b1 = b1 >= a1;
>r4b1 : boolean
>b1 >= a1 : boolean
>b1 : { [x: string]: string; }
>a1 : { [x: string]: string; }
>b1 : { [b: string]: string; }
>a1 : { [a: string]: string; }
var r4b1 = b2 >= a2;
>r4b1 : boolean
>b2 >= a2 : boolean
>b2 : { [x: string]: Derived; }
>a2 : { [x: string]: Base; }
>b2 : { [index: string]: Derived; }
>a2 : { [index: string]: Base; }
var r4b1 = b3 >= a3;
>r4b1 : boolean
>b3 >= a3 : boolean
>b3 : { [x: number]: string; }
>a3 : { [x: number]: string; }
>b3 : { [index: number]: string; }
>a3 : { [index: number]: string; }
var r4b1 = b4 >= a4;
>r4b1 : boolean
>b4 >= a4 : boolean
>b4 : { [x: string]: Derived; }
>a4 : { [x: number]: Base; }
>b4 : { [index: string]: Derived; }
>a4 : { [index: number]: Base; }
// operator ==
var r5a1 = a1 == b1;
>r5a1 : boolean
>a1 == b1 : boolean
>a1 : { [x: string]: string; }
>b1 : { [x: string]: string; }
>a1 : { [a: string]: string; }
>b1 : { [b: string]: string; }
var r5a1 = a2 == b2;
>r5a1 : boolean
>a2 == b2 : boolean
>a2 : { [x: string]: Base; }
>b2 : { [x: string]: Derived; }
>a2 : { [index: string]: Base; }
>b2 : { [index: string]: Derived; }
var r5a1 = a3 == b3;
>r5a1 : boolean
>a3 == b3 : boolean
>a3 : { [x: number]: string; }
>b3 : { [x: number]: string; }
>a3 : { [index: number]: string; }
>b3 : { [index: number]: string; }
var r5a1 = a4 == b4;
>r5a1 : boolean
>a4 == b4 : boolean
>a4 : { [x: number]: Base; }
>b4 : { [x: string]: Derived; }
>a4 : { [index: number]: Base; }
>b4 : { [index: string]: Derived; }
var r5b1 = b1 == a1;
>r5b1 : boolean
>b1 == a1 : boolean
>b1 : { [x: string]: string; }
>a1 : { [x: string]: string; }
>b1 : { [b: string]: string; }
>a1 : { [a: string]: string; }
var r5b1 = b2 == a2;
>r5b1 : boolean
>b2 == a2 : boolean
>b2 : { [x: string]: Derived; }
>a2 : { [x: string]: Base; }
>b2 : { [index: string]: Derived; }
>a2 : { [index: string]: Base; }
var r5b1 = b3 == a3;
>r5b1 : boolean
>b3 == a3 : boolean
>b3 : { [x: number]: string; }
>a3 : { [x: number]: string; }
>b3 : { [index: number]: string; }
>a3 : { [index: number]: string; }
var r5b1 = b4 == a4;
>r5b1 : boolean
>b4 == a4 : boolean
>b4 : { [x: string]: Derived; }
>a4 : { [x: number]: Base; }
>b4 : { [index: string]: Derived; }
>a4 : { [index: number]: Base; }
// operator !=
var r6a1 = a1 != b1;
>r6a1 : boolean
>a1 != b1 : boolean
>a1 : { [x: string]: string; }
>b1 : { [x: string]: string; }
>a1 : { [a: string]: string; }
>b1 : { [b: string]: string; }
var r6a1 = a2 != b2;
>r6a1 : boolean
>a2 != b2 : boolean
>a2 : { [x: string]: Base; }
>b2 : { [x: string]: Derived; }
>a2 : { [index: string]: Base; }
>b2 : { [index: string]: Derived; }
var r6a1 = a3 != b3;
>r6a1 : boolean
>a3 != b3 : boolean
>a3 : { [x: number]: string; }
>b3 : { [x: number]: string; }
>a3 : { [index: number]: string; }
>b3 : { [index: number]: string; }
var r6a1 = a4 != b4;
>r6a1 : boolean
>a4 != b4 : boolean
>a4 : { [x: number]: Base; }
>b4 : { [x: string]: Derived; }
>a4 : { [index: number]: Base; }
>b4 : { [index: string]: Derived; }
var r6b1 = b1 != a1;
>r6b1 : boolean
>b1 != a1 : boolean
>b1 : { [x: string]: string; }
>a1 : { [x: string]: string; }
>b1 : { [b: string]: string; }
>a1 : { [a: string]: string; }
var r6b1 = b2 != a2;
>r6b1 : boolean
>b2 != a2 : boolean
>b2 : { [x: string]: Derived; }
>a2 : { [x: string]: Base; }
>b2 : { [index: string]: Derived; }
>a2 : { [index: string]: Base; }
var r6b1 = b3 != a3;
>r6b1 : boolean
>b3 != a3 : boolean
>b3 : { [x: number]: string; }
>a3 : { [x: number]: string; }
>b3 : { [index: number]: string; }
>a3 : { [index: number]: string; }
var r6b1 = b4 != a4;
>r6b1 : boolean
>b4 != a4 : boolean
>b4 : { [x: string]: Derived; }
>a4 : { [x: number]: Base; }
>b4 : { [index: string]: Derived; }
>a4 : { [index: number]: Base; }
// operator ===
var r7a1 = a1 === b1;
>r7a1 : boolean
>a1 === b1 : boolean
>a1 : { [x: string]: string; }
>b1 : { [x: string]: string; }
>a1 : { [a: string]: string; }
>b1 : { [b: string]: string; }
var r7a1 = a2 === b2;
>r7a1 : boolean
>a2 === b2 : boolean
>a2 : { [x: string]: Base; }
>b2 : { [x: string]: Derived; }
>a2 : { [index: string]: Base; }
>b2 : { [index: string]: Derived; }
var r7a1 = a3 === b3;
>r7a1 : boolean
>a3 === b3 : boolean
>a3 : { [x: number]: string; }
>b3 : { [x: number]: string; }
>a3 : { [index: number]: string; }
>b3 : { [index: number]: string; }
var r7a1 = a4 === b4;
>r7a1 : boolean
>a4 === b4 : boolean
>a4 : { [x: number]: Base; }
>b4 : { [x: string]: Derived; }
>a4 : { [index: number]: Base; }
>b4 : { [index: string]: Derived; }
var r7b1 = b1 === a1;
>r7b1 : boolean
>b1 === a1 : boolean
>b1 : { [x: string]: string; }
>a1 : { [x: string]: string; }
>b1 : { [b: string]: string; }
>a1 : { [a: string]: string; }
var r7b1 = b2 === a2;
>r7b1 : boolean
>b2 === a2 : boolean
>b2 : { [x: string]: Derived; }
>a2 : { [x: string]: Base; }
>b2 : { [index: string]: Derived; }
>a2 : { [index: string]: Base; }
var r7b1 = b3 === a3;
>r7b1 : boolean
>b3 === a3 : boolean
>b3 : { [x: number]: string; }
>a3 : { [x: number]: string; }
>b3 : { [index: number]: string; }
>a3 : { [index: number]: string; }
var r7b1 = b4 === a4;
>r7b1 : boolean
>b4 === a4 : boolean
>b4 : { [x: string]: Derived; }
>a4 : { [x: number]: Base; }
>b4 : { [index: string]: Derived; }
>a4 : { [index: number]: Base; }
// operator !==
var r8a1 = a1 !== b1;
>r8a1 : boolean
>a1 !== b1 : boolean
>a1 : { [x: string]: string; }
>b1 : { [x: string]: string; }
>a1 : { [a: string]: string; }
>b1 : { [b: string]: string; }
var r8a1 = a2 !== b2;
>r8a1 : boolean
>a2 !== b2 : boolean
>a2 : { [x: string]: Base; }
>b2 : { [x: string]: Derived; }
>a2 : { [index: string]: Base; }
>b2 : { [index: string]: Derived; }
var r8a1 = a3 !== b3;
>r8a1 : boolean
>a3 !== b3 : boolean
>a3 : { [x: number]: string; }
>b3 : { [x: number]: string; }
>a3 : { [index: number]: string; }
>b3 : { [index: number]: string; }
var r8a1 = a4 !== b4;
>r8a1 : boolean
>a4 !== b4 : boolean
>a4 : { [x: number]: Base; }
>b4 : { [x: string]: Derived; }
>a4 : { [index: number]: Base; }
>b4 : { [index: string]: Derived; }
var r8b1 = b1 !== a1;
>r8b1 : boolean
>b1 !== a1 : boolean
>b1 : { [x: string]: string; }
>a1 : { [x: string]: string; }
>b1 : { [b: string]: string; }
>a1 : { [a: string]: string; }
var r8b1 = b2 !== a2;
>r8b1 : boolean
>b2 !== a2 : boolean
>b2 : { [x: string]: Derived; }
>a2 : { [x: string]: Base; }
>b2 : { [index: string]: Derived; }
>a2 : { [index: string]: Base; }
var r8b1 = b3 !== a3;
>r8b1 : boolean
>b3 !== a3 : boolean
>b3 : { [x: number]: string; }
>a3 : { [x: number]: string; }
>b3 : { [index: number]: string; }
>a3 : { [index: number]: string; }
var r8b1 = b4 !== a4;
>r8b1 : boolean
>b4 !== a4 : boolean
>b4 : { [x: string]: Derived; }
>a4 : { [x: number]: Base; }
>b4 : { [index: string]: Derived; }
>a4 : { [index: number]: Base; }
@@ -265,7 +265,7 @@ var C = (function () {
})();
// object literals
var o = {
f: function () {
f() {
const c = 0;
n = c;
},
@@ -220,7 +220,7 @@ var C = (function () {
})();
// object literals
var o = {
f: function () {
f() {
const c28 = 0;
},
f2: function () {
@@ -3,7 +3,7 @@ var x: any;
>x : any
var obj: { [s: string]: number } = { p: "", q: x };
>obj : { [x: string]: number; }
>obj : { [s: string]: number; }
>s : string
>{ p: "", q: x } : { [x: string]: any; p: string; q: any; }
>p : string
@@ -1,6 +1,6 @@
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 '{ [x: string]: 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; }'.
==== tests/cases/compiler/contextualTypingOfObjectLiterals.ts (2 errors) ====
@@ -18,4 +18,4 @@ tests/cases/compiler/contextualTypingOfObjectLiterals.ts(10,3): error TS2345: Ar
f(obj1); // Ok
f(obj2); // Error - indexer doesn't match
~~~~
!!! error TS2345: Argument of type '{ x: string; }' is not assignable to parameter of type '{ [x: string]: string; }'.
!!! error TS2345: Argument of type '{ x: string; }' is not assignable to parameter of type '{ [s: string]: string; }'.
@@ -17,7 +17,7 @@ module m {
// Object literal with everything
var x: {
>x : { (a: number): c; (a: string): g<string>; new (a: number): c; new (a: string): m.c; [x: string]: c; [x: number]: c; a: c; b: g<string>; m1(): g<number>; m2(a: string, b?: number, ...c: c[]): string; }
>x : { (a: number): c; (a: string): g<string>; new (a: number): c; new (a: string): m.c; [n: string]: c; [n: number]: c; a: c; b: g<string>; m1(): g<number>; m2(a: string, b?: number, ...c: c[]): string; }
// Call signatures
(a: number): c;
@@ -0,0 +1,10 @@
tests/cases/compiler/declareModifierOnImport1.ts(1,1): error TS1079: A 'declare' modifier cannot be used with an import declaration.
tests/cases/compiler/declareModifierOnImport1.ts(1,1): error TS2304: Cannot find name 'b'.
==== tests/cases/compiler/declareModifierOnImport1.ts (2 errors) ====
declare import a = b;
~~~~~~~
!!! error TS1079: A 'declare' modifier cannot be used with an import declaration.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'b'.
@@ -22,7 +22,7 @@ var moduleATyped: IHasVisualizationModel = moduleA;
>moduleA : typeof moduleA
var moduleMap: { [key: string]: IHasVisualizationModel } = {
>moduleMap : { [x: string]: IHasVisualizationModel; }
>moduleMap : { [key: string]: IHasVisualizationModel; }
>key : string
>IHasVisualizationModel : IHasVisualizationModel
>{ "moduleA": moduleA, "moduleB": moduleB} : { [x: string]: typeof moduleA; "moduleA": typeof moduleA; "moduleB": typeof moduleB; }
@@ -42,7 +42,7 @@ var visModel = new moduleMap[moduleName].VisualizationModel();
>new moduleMap[moduleName].VisualizationModel() : Backbone.Model
>moduleMap[moduleName].VisualizationModel : typeof Backbone.Model
>moduleMap[moduleName] : IHasVisualizationModel
>moduleMap : { [x: string]: IHasVisualizationModel; }
>moduleMap : { [key: string]: IHasVisualizationModel; }
>moduleName : string
>VisualizationModel : typeof Backbone.Model
@@ -97,7 +97,7 @@ var x8: Array<Base> = [d1, d2];
>d2 : Derived2
var x9: { [n: number]: Base; } = [d1, d2];
>x9 : { [x: number]: Base; }
>x9 : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -210,7 +210,7 @@ class x20 { member: Array<Base> = [d1, d2] }
class x21 { member: { [n: number]: Base; } = [d1, d2] }
>x21 : x21
>member : { [x: number]: Base; }
>member : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -326,7 +326,7 @@ class x32 { private member: Array<Base> = [d1, d2] }
class x33 { private member: { [n: number]: Base; } = [d1, d2] }
>x33 : x33
>member : { [x: number]: Base; }
>member : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -442,7 +442,7 @@ class x44 { public member: Array<Base> = [d1, d2] }
class x45 { public member: { [n: number]: Base; } = [d1, d2] }
>x45 : x45
>member : { [x: number]: Base; }
>member : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -558,7 +558,7 @@ class x56 { static member: Array<Base> = [d1, d2] }
class x57 { static member: { [n: number]: Base; } = [d1, d2] }
>x57 : x57
>member : { [x: number]: Base; }
>member : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -674,7 +674,7 @@ class x68 { private static member: Array<Base> = [d1, d2] }
class x69 { private static member: { [n: number]: Base; } = [d1, d2] }
>x69 : x69
>member : { [x: number]: Base; }
>member : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -790,7 +790,7 @@ class x80 { public static member: Array<Base> = [d1, d2] }
class x81 { public static member: { [n: number]: Base; } = [d1, d2] }
>x81 : x81
>member : { [x: number]: Base; }
>member : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -906,7 +906,7 @@ class x92 { constructor(parm: Array<Base> = [d1, d2]) { } }
class x93 { constructor(parm: { [n: number]: Base; } = [d1, d2]) { } }
>x93 : x93
>parm : { [x: number]: Base; }
>parm : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -1022,7 +1022,7 @@ class x104 { constructor(public parm: Array<Base> = [d1, d2]) { } }
class x105 { constructor(public parm: { [n: number]: Base; } = [d1, d2]) { } }
>x105 : x105
>parm : { [x: number]: Base; }
>parm : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -1138,7 +1138,7 @@ class x116 { constructor(private parm: Array<Base> = [d1, d2]) { } }
class x117 { constructor(private parm: { [n: number]: Base; } = [d1, d2]) { } }
>x117 : x117
>parm : { [x: number]: Base; }
>parm : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -1253,8 +1253,8 @@ function x128(parm: Array<Base> = [d1, d2]) { }
>d2 : Derived2
function x129(parm: { [n: number]: Base; } = [d1, d2]) { }
>x129 : (parm?: { [x: number]: Base; }) => void
>parm : { [x: number]: Base; }
>x129 : (parm?: { [n: number]: Base; }) => void
>parm : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -1361,7 +1361,7 @@ function x140(): Array<Base> { return [d1, d2]; }
>d2 : Derived2
function x141(): { [n: number]: Base; } { return [d1, d2]; }
>x141 : () => { [x: number]: Base; }
>x141 : () => { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -1497,7 +1497,7 @@ function x152(): Array<Base> { return [d1, d2]; return [d1, d2]; }
>d2 : Derived2
function x153(): { [n: number]: Base; } { return [d1, d2]; return [d1, d2]; }
>x153 : () => { [x: number]: Base; }
>x153 : () => { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -1628,7 +1628,7 @@ var x164: () => Array<Base> = () => { return [d1, d2]; };
>d2 : Derived2
var x165: () => { [n: number]: Base; } = () => { return [d1, d2]; };
>x165 : () => { [x: number]: Base; }
>x165 : () => { [n: number]: Base; }
>n : number
>Base : Base
>() => { return [d1, d2]; } : () => (Derived1 | Derived2)[]
@@ -1744,7 +1744,7 @@ var x176: () => Array<Base> = function() { return [d1, d2]; };
>d2 : Derived2
var x177: () => { [n: number]: Base; } = function() { return [d1, d2]; };
>x177 : () => { [x: number]: Base; }
>x177 : () => { [n: number]: Base; }
>n : number
>Base : Base
>function() { return [d1, d2]; } : () => (Derived1 | Derived2)[]
@@ -1861,7 +1861,7 @@ module x188 { var t: Array<Base> = [d1, d2]; }
module x189 { var t: { [n: number]: Base; } = [d1, d2]; }
>x189 : typeof x189
>t : { [x: number]: Base; }
>t : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -1977,7 +1977,7 @@ module x200 { export var t: Array<Base> = [d1, d2]; }
module x201 { export var t: { [n: number]: Base; } = [d1, d2]; }
>x201 : typeof x201
>t : { [x: number]: Base; }
>t : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -2074,8 +2074,8 @@ var x212 = <Array<Base>>[d1, d2];
>d2 : Derived2
var x213 = <{ [n: number]: Base; }>[d1, d2];
>x213 : { [x: number]: Base; }
><{ [n: number]: Base; }>[d1, d2] : { [x: number]: Base; }
>x213 : { [n: number]: Base; }
><{ [n: number]: Base; }>[d1, d2] : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] : (Derived1 | Derived2)[]
@@ -2180,10 +2180,10 @@ var x222 = (<Array<Base>>undefined) || [d1, d2];
>d2 : Derived2
var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2];
>x223 : { [x: number]: Base; }
>(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [x: number]: Base; }
>(<{ [n: number]: Base; }>undefined) : { [x: number]: Base; }
><{ [n: number]: Base; }>undefined : { [x: number]: Base; }
>x223 : { [n: number]: Base; }
>(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [n: number]: Base; }
>(<{ [n: number]: Base; }>undefined) : { [n: number]: Base; }
><{ [n: number]: Base; }>undefined : { [n: number]: Base; }
>n : number
>Base : Base
>undefined : undefined
@@ -2287,11 +2287,11 @@ var x232: Array<Base>; x232 = [d1, d2];
>d2 : Derived2
var x233: { [n: number]: Base; }; x233 = [d1, d2];
>x233 : { [x: number]: Base; }
>x233 : { [n: number]: Base; }
>n : number
>Base : Base
>x233 = [d1, d2] : (Derived1 | Derived2)[]
>x233 : { [x: number]: Base; }
>x233 : { [n: number]: Base; }
>[d1, d2] : (Derived1 | Derived2)[]
>d1 : Derived1
>d2 : Derived2
@@ -2423,8 +2423,8 @@ var x244: { n: Array<Base>; } = { n: [d1, d2] };
>d2 : Derived2
var x245: { n: { [n: number]: Base; }; } = { n: [d1, d2] };
>x245 : { n: { [x: number]: Base; }; }
>n : { [x: number]: Base; }
>x245 : { n: { [n: number]: Base; }; }
>n : { [n: number]: Base; }
>n : number
>Base : Base
>{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; }
@@ -2519,7 +2519,7 @@ var x256: Array<Base>[] = [[d1, d2]];
>d2 : Derived2
var x257: { [n: number]: Base; }[] = [[d1, d2]];
>x257 : { [x: number]: Base; }[]
>x257 : { [n: number]: Base; }[]
>n : number
>Base : Base
>[[d1, d2]] : (Derived1 | Derived2)[][]
@@ -2613,7 +2613,7 @@ var x266: Array<Base> = [d1, d2] || undefined;
>undefined : undefined
var x267: { [n: number]: Base; } = [d1, d2] || undefined;
>x267 : { [x: number]: Base; }
>x267 : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] || undefined : (Derived1 | Derived2)[]
@@ -2696,7 +2696,7 @@ var x274: Array<Base> = undefined || [d1, d2];
>d2 : Derived2
var x275: { [n: number]: Base; } = undefined || [d1, d2];
>x275 : { [x: number]: Base; }
>x275 : { [n: number]: Base; }
>n : number
>Base : Base
>undefined || [d1, d2] : (Derived1 | Derived2)[]
@@ -2797,7 +2797,7 @@ var x282: Array<Base> = [d1, d2] || [d1, d2];
>d2 : Derived2
var x283: { [n: number]: Base; } = [d1, d2] || [d1, d2];
>x283 : { [x: number]: Base; }
>x283 : { [n: number]: Base; }
>n : number
>Base : Base
>[d1, d2] || [d1, d2] : (Derived1 | Derived2)[]
@@ -2930,7 +2930,7 @@ var x292: Array<Base> = true ? [d1, d2] : [d1, d2];
>d2 : Derived2
var x293: { [n: number]: Base; } = true ? [d1, d2] : [d1, d2];
>x293 : { [x: number]: Base; }
>x293 : { [n: number]: Base; }
>n : number
>Base : Base
>true ? [d1, d2] : [d1, d2] : (Derived1 | Derived2)[]
@@ -3073,7 +3073,7 @@ var x304: Array<Base> = true ? undefined : [d1, d2];
>d2 : Derived2
var x305: { [n: number]: Base; } = true ? undefined : [d1, d2];
>x305 : { [x: number]: Base; }
>x305 : { [n: number]: Base; }
>n : number
>Base : Base
>true ? undefined : [d1, d2] : (Derived1 | Derived2)[]
@@ -3201,7 +3201,7 @@ var x316: Array<Base> = true ? [d1, d2] : undefined;
>undefined : undefined
var x317: { [n: number]: Base; } = true ? [d1, d2] : undefined;
>x317 : { [x: number]: Base; }
>x317 : { [n: number]: Base; }
>n : number
>Base : Base
>true ? [d1, d2] : undefined : (Derived1 | Derived2)[]
@@ -3337,12 +3337,12 @@ function x328(n: Array<Base>) { }; x328([d1, d2]);
>d2 : Derived2
function x329(n: { [n: number]: Base; }) { }; x329([d1, d2]);
>x329 : (n: { [x: number]: Base; }) => void
>n : { [x: number]: Base; }
>x329 : (n: { [n: number]: Base; }) => void
>n : { [n: number]: Base; }
>n : number
>Base : Base
>x329([d1, d2]) : void
>x329 : (n: { [x: number]: Base; }) => void
>x329 : (n: { [n: number]: Base; }) => void
>[d1, d2] : (Derived1 | Derived2)[]
>d1 : Derived1
>d2 : Derived2
@@ -3493,14 +3493,14 @@ var x340 = (n: Array<Base>) => n; x340([d1, d2]);
>d2 : Derived2
var x341 = (n: { [n: number]: Base; }) => n; x341([d1, d2]);
>x341 : (n: { [x: number]: Base; }) => { [x: number]: Base; }
>(n: { [n: number]: Base; }) => n : (n: { [x: number]: Base; }) => { [x: number]: Base; }
>n : { [x: number]: Base; }
>x341 : (n: { [n: number]: Base; }) => { [n: number]: Base; }
>(n: { [n: number]: Base; }) => n : (n: { [n: number]: Base; }) => { [n: number]: Base; }
>n : { [n: number]: Base; }
>n : number
>Base : Base
>n : { [x: number]: Base; }
>x341([d1, d2]) : { [x: number]: Base; }
>x341 : (n: { [x: number]: Base; }) => { [x: number]: Base; }
>n : { [n: number]: Base; }
>x341([d1, d2]) : { [n: number]: Base; }
>x341 : (n: { [n: number]: Base; }) => { [n: number]: Base; }
>[d1, d2] : (Derived1 | Derived2)[]
>d1 : Derived1
>d2 : Derived2
@@ -3649,13 +3649,13 @@ var x352 = function(n: Array<Base>) { }; x352([d1, d2]);
>d2 : Derived2
var x353 = function(n: { [n: number]: Base; }) { }; x353([d1, d2]);
>x353 : (n: { [x: number]: Base; }) => void
>function(n: { [n: number]: Base; }) { } : (n: { [x: number]: Base; }) => void
>n : { [x: number]: Base; }
>x353 : (n: { [n: number]: Base; }) => void
>function(n: { [n: number]: Base; }) { } : (n: { [n: number]: Base; }) => void
>n : { [n: number]: Base; }
>n : number
>Base : Base
>x353([d1, d2]) : void
>x353 : (n: { [x: number]: Base; }) => void
>x353 : (n: { [n: number]: Base; }) => void
>[d1, d2] : (Derived1 | Derived2)[]
>d1 : Derived1
>d2 : Derived2
@@ -8,16 +8,16 @@ class BaseCollection2<TItem extends CollectionItem2> {
>CollectionItem2 : CollectionItem2
_itemsByKey: { [key: string]: TItem; };
>_itemsByKey : { [x: string]: TItem; }
>_itemsByKey : { [key: string]: TItem; }
>key : string
>TItem : TItem
constructor() {
this._itemsByKey = {};
>this._itemsByKey = {} : { [x: string]: undefined; }
>this._itemsByKey : { [x: string]: TItem; }
>this._itemsByKey : { [key: string]: TItem; }
>this : BaseCollection2<TItem>
>_itemsByKey : { [x: string]: TItem; }
>_itemsByKey : { [key: string]: TItem; }
>{} : { [x: string]: undefined; }
}
}
@@ -35,9 +35,9 @@ class DataView2 extends BaseCollection2<CollectionItem2> {
this._itemsByKey['dummy'] = item;
>this._itemsByKey['dummy'] = item : CollectionItem2
>this._itemsByKey['dummy'] : CollectionItem2
>this._itemsByKey : { [x: string]: CollectionItem2; }
>this._itemsByKey : { [key: string]: CollectionItem2; }
>this : DataView2
>_itemsByKey : { [x: string]: CollectionItem2; }
>_itemsByKey : { [key: string]: CollectionItem2; }
>item : CollectionItem2
}
}
@@ -1,19 +1,13 @@
tests/cases/compiler/genericCallWithoutArgs.ts(4,17): error TS1109: Expression expected.
tests/cases/compiler/genericCallWithoutArgs.ts(4,18): error TS1003: Identifier expected.
tests/cases/compiler/genericCallWithoutArgs.ts(4,3): error TS2304: Cannot find name 'number'.
tests/cases/compiler/genericCallWithoutArgs.ts(4,10): error TS2304: Cannot find name 'string'.
tests/cases/compiler/genericCallWithoutArgs.ts(4,17): error TS1005: '(' expected.
tests/cases/compiler/genericCallWithoutArgs.ts(4,18): error TS1005: ')' expected.
==== tests/cases/compiler/genericCallWithoutArgs.ts (4 errors) ====
==== tests/cases/compiler/genericCallWithoutArgs.ts (2 errors) ====
function f<X, Y>(x: X, y: Y) {
}
f<number,string>.
~
!!! error TS1109: Expression expected.
!!! error TS1005: '(' expected.
!!! error TS1003: Identifier expected.
~~~~~~
!!! error TS2304: Cannot find name 'number'.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
!!! error TS1005: ')' expected.
@@ -1,24 +1,18 @@
tests/cases/compiler/genericCallsWithoutParens.ts(2,18): error TS1109: Expression expected.
tests/cases/compiler/genericCallsWithoutParens.ts(7,22): error TS1109: Expression expected.
tests/cases/compiler/genericCallsWithoutParens.ts(2,11): error TS2304: Cannot find name 'number'.
tests/cases/compiler/genericCallsWithoutParens.ts(7,15): error TS2304: Cannot find name 'number'.
tests/cases/compiler/genericCallsWithoutParens.ts(2,18): error TS1005: '(' expected.
tests/cases/compiler/genericCallsWithoutParens.ts(7,22): error TS1005: '(' expected.
==== tests/cases/compiler/genericCallsWithoutParens.ts (4 errors) ====
==== tests/cases/compiler/genericCallsWithoutParens.ts (2 errors) ====
function f<T>() { }
var r = f<number>; // parse error
~
!!! error TS1109: Expression expected.
~~~~~~
!!! error TS2304: Cannot find name 'number'.
!!! error TS1005: '(' expected.
class C<T> {
foo: T;
}
var c = new C<number>; // parse error
~
!!! error TS1109: Expression expected.
~~~~~~
!!! error TS2304: Cannot find name 'number'.
!!! error TS1005: '(' expected.
@@ -1,8 +1,7 @@
tests/cases/compiler/genericConstructExpressionWithoutArgs.ts(10,1): error TS1109: Expression expected.
tests/cases/compiler/genericConstructExpressionWithoutArgs.ts(9,16): error TS2304: Cannot find name 'number'.
tests/cases/compiler/genericConstructExpressionWithoutArgs.ts(10,1): error TS1005: '(' expected.
==== tests/cases/compiler/genericConstructExpressionWithoutArgs.ts (2 errors) ====
==== tests/cases/compiler/genericConstructExpressionWithoutArgs.ts (1 errors) ====
class B { }
var b = new B; // no error
@@ -12,8 +11,6 @@ tests/cases/compiler/genericConstructExpressionWithoutArgs.ts(9,16): error TS230
var c = new C // C<any>
var c2 = new C<number> // error, type params are actually part of the arg list so you need both
~~~~~~
!!! error TS2304: Cannot find name 'number'.
!!! error TS1109: Expression expected.
!!! error TS1005: '(' expected.
@@ -1,8 +1,7 @@
tests/cases/compiler/genericObjectCreationWithoutTypeArgs.ts(6,26): error TS1109: Expression expected.
tests/cases/compiler/genericObjectCreationWithoutTypeArgs.ts(6,19): error TS2304: Cannot find name 'number'.
tests/cases/compiler/genericObjectCreationWithoutTypeArgs.ts(6,26): error TS1005: '(' expected.
==== tests/cases/compiler/genericObjectCreationWithoutTypeArgs.ts (2 errors) ====
==== tests/cases/compiler/genericObjectCreationWithoutTypeArgs.ts (1 errors) ====
class SS<T>{
}
@@ -10,9 +9,7 @@ tests/cases/compiler/genericObjectCreationWithoutTypeArgs.ts(6,19): error TS2304
var x1 = new SS<number>(); // OK
var x2 = new SS < number>; // Correctly give error
~
!!! error TS1109: Expression expected.
~~~~~~
!!! error TS2304: Cannot find name 'number'.
!!! error TS1005: '(' expected.
var x3 = new SS(); // OK
var x4 = new SS; // Should be allowed, but currently give error ('supplied parameters do not match any signature of the call target')
@@ -4,19 +4,19 @@ class LazyArray<T> {
>T : T
private objects = <{ [objectId: string]: T; }>{};
>objects : { [x: string]: T; }
><{ [objectId: string]: T; }>{} : { [x: string]: T; }
>objects : { [objectId: string]: T; }
><{ [objectId: string]: T; }>{} : { [objectId: string]: T; }
>objectId : string
>T : T
>{} : { [x: string]: undefined; }
array() {
>array : () => { [x: string]: T; }
>array : () => { [objectId: string]: T; }
return this.objects;
>this.objects : { [x: string]: T; }
>this.objects : { [objectId: string]: T; }
>this : LazyArray<T>
>objects : { [x: string]: T; }
>objects : { [objectId: string]: T; }
}
}
var lazyArray = new LazyArray<string>();
@@ -27,8 +27,8 @@ var lazyArray = new LazyArray<string>();
var value: string = lazyArray.array()["test"]; // used to be an error
>value : string
>lazyArray.array()["test"] : string
>lazyArray.array() : { [x: string]: string; }
>lazyArray.array : () => { [x: string]: string; }
>lazyArray.array() : { [objectId: string]: string; }
>lazyArray.array : () => { [objectId: string]: string; }
>lazyArray : LazyArray<string>
>array : () => { [x: string]: string; }
>array : () => { [objectId: string]: string; }
@@ -5,7 +5,7 @@ export class Collection<TItem extends CollectionItem> {
>CollectionItem : CollectionItem
_itemsByKey: { [key: string]: TItem; };
>_itemsByKey : { [x: string]: TItem; }
>_itemsByKey : { [key: string]: TItem; }
>key : string
>TItem : TItem
}
@@ -0,0 +1,12 @@
tests/cases/compiler/indexSignatureWithInitializer1.ts(2,4): error TS1020: An index signature parameter cannot have an initializer.
tests/cases/compiler/indexSignatureWithInitializer1.ts(2,4): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
==== tests/cases/compiler/indexSignatureWithInitializer1.ts (2 errors) ====
class C {
[a: number = 1]: number;
~
!!! error TS1020: An index signature parameter cannot have an initializer.
~~~~~~~~~~~~~
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
}
@@ -0,0 +1,4 @@
//// [indexSignatureWithoutTypeAnnotation1..ts]
//// [indexSignatureWithoutTypeAnnotation1..js]
@@ -0,0 +1,3 @@
=== tests/cases/compiler/indexSignatureWithoutTypeAnnotation1..ts ===
No type information for this code.
@@ -0,0 +1,9 @@
tests/cases/compiler/indexSignatureWithoutTypeAnnotation1.ts(2,3): error TS1021: An index signature must have a type annotation.
==== tests/cases/compiler/indexSignatureWithoutTypeAnnotation1.ts (1 errors) ====
class C {
[a: number];
~~~~~~~~~~~~
!!! error TS1021: An index signature must have a type annotation.
}
@@ -1,17 +1,17 @@
=== tests/cases/compiler/indexSignaturesInferentialTyping.ts ===
function foo<T>(items: { [index: number]: T }): T { return undefined; }
>foo : <T>(items: { [x: number]: T; }) => T
>foo : <T>(items: { [index: number]: T; }) => T
>T : T
>items : { [x: number]: T; }
>items : { [index: number]: T; }
>index : number
>T : T
>T : T
>undefined : undefined
function bar<T>(items: { [index: string]: T }): T { return undefined; }
>bar : <T>(items: { [x: string]: T; }) => T
>bar : <T>(items: { [index: string]: T; }) => T
>T : T
>items : { [x: string]: T; }
>items : { [index: string]: T; }
>index : string
>T : T
>T : T
@@ -20,13 +20,13 @@ function bar<T>(items: { [index: string]: T }): T { return undefined; }
var x1 = foo({ 0: 0, 1: 1 }); // type should be number
>x1 : number
>foo({ 0: 0, 1: 1 }) : number
>foo : <T>(items: { [x: number]: T; }) => T
>foo : <T>(items: { [index: number]: T; }) => T
>{ 0: 0, 1: 1 } : { [x: number]: number; 0: number; 1: number; }
var x2 = foo({ zero: 0, one: 1 });
>x2 : any
>foo({ zero: 0, one: 1 }) : any
>foo : <T>(items: { [x: number]: T; }) => T
>foo : <T>(items: { [index: number]: T; }) => T
>{ zero: 0, one: 1 } : { [x: number]: undefined; zero: number; one: number; }
>zero : number
>one : number
@@ -34,13 +34,13 @@ var x2 = foo({ zero: 0, one: 1 });
var x3 = bar({ 0: 0, 1: 1 });
>x3 : number
>bar({ 0: 0, 1: 1 }) : number
>bar : <T>(items: { [x: string]: T; }) => T
>bar : <T>(items: { [index: string]: T; }) => T
>{ 0: 0, 1: 1 } : { [x: string]: number; 0: number; 1: number; }
var x4 = bar({ zero: 0, one: 1 }); // type should be number
>x4 : number
>bar({ zero: 0, one: 1 }) : number
>bar : <T>(items: { [x: string]: T; }) => T
>bar : <T>(items: { [index: string]: T; }) => T
>{ zero: 0, one: 1 } : { [x: string]: number; zero: number; one: number; }
>zero : number
>one : number
@@ -1,8 +1,8 @@
tests/cases/compiler/indexerAssignability.ts(5,1): error TS2322: Type '{ [x: number]: string; }' is not assignable to type '{ [x: string]: string; }'.
Index signature is missing in type '{ [x: number]: string; }'.
tests/cases/compiler/indexerAssignability.ts(6,1): error TS2322: Type '{}' is not assignable to type '{ [x: string]: string; }'.
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 '{ [x: number]: string; }'.
tests/cases/compiler/indexerAssignability.ts(8,1): error TS2322: Type '{}' is not assignable to type '{ [n: number]: string; }'.
Index signature is missing in type '{}'.
@@ -13,16 +13,16 @@ tests/cases/compiler/indexerAssignability.ts(8,1): error TS2322: Type '{}' is no
a = b;
~
!!! error TS2322: Type '{ [x: number]: string; }' is not assignable to type '{ [x: string]: string; }'.
!!! error TS2322: Index signature is missing in type '{ [x: number]: string; }'.
!!! 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 '{ [x: string]: string; }'.
!!! 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 '{ [x: number]: string; }'.
!!! error TS2322: Type '{}' is not assignable to type '{ [n: number]: string; }'.
!!! error TS2322: Index signature is missing in type '{}'.
c = a;
c = b;
@@ -3,7 +3,7 @@ interface f {
>f : f
groupBy<T>(): { [key: string]: T[]; };
>groupBy : <T>() => { [x: string]: T[]; }
>groupBy : <T>() => { [key: string]: T[]; }
>T : T
>key : string
>T : T
@@ -13,17 +13,17 @@ var a: f;
>f : f
var r = a.groupBy();
>r : { [x: string]: {}[]; }
>a.groupBy() : { [x: string]: {}[]; }
>a.groupBy : <T>() => { [x: string]: T[]; }
>r : { [key: string]: {}[]; }
>a.groupBy() : { [key: string]: {}[]; }
>a.groupBy : <T>() => { [key: string]: T[]; }
>a : f
>groupBy : <T>() => { [x: string]: T[]; }
>groupBy : <T>() => { [key: string]: T[]; }
class c {
>c : c
groupBy<T>(): { [key: string]: T[]; } {
>groupBy : <T>() => { [x: string]: T[]; }
>groupBy : <T>() => { [key: string]: T[]; }
>T : T
>key : string
>T : T
@@ -36,9 +36,9 @@ var a2: c;
>c : c
var r2 = a2.groupBy();
>r2 : { [x: string]: {}[]; }
>a2.groupBy() : { [x: string]: {}[]; }
>a2.groupBy : <T>() => { [x: string]: T[]; }
>r2 : { [key: string]: {}[]; }
>a2.groupBy() : { [key: string]: {}[]; }
>a2.groupBy : <T>() => { [key: string]: T[]; }
>a2 : c
>groupBy : <T>() => { [x: string]: T[]; }
>groupBy : <T>() => { [key: string]: T[]; }
@@ -68,11 +68,10 @@ x = M;
>M : typeof M
x = { f() { } }
>x = { f() { } } : { f: () => void; }
>x = { f() { } } : { f(): void; }
>x : any
>{ f() { } } : { f: () => void; }
>{ f() { } } : { f(): void; }
>f : () => void
>f() { } : () => void
function f<T>(a: T) {
>f : <T>(a: T) => void
@@ -12,7 +12,7 @@ tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(21,5): e
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(26,1): error TS2322: Type 'typeof E' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(27,1): error TS2322: Type 'E' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(29,1): error TS2322: Type '{ f: () => void; }' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(29,1): error TS2322: Type '{ f(): void; }' is not assignable to type 'void'.
==== tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts (13 errors) ====
@@ -72,4 +72,4 @@ tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(29,1): e
x = { f() { } }
~
!!! error TS2322: Type '{ f: () => void; }' is not assignable to type 'void'.
!!! error TS2322: Type '{ f(): void; }' is not assignable to type 'void'.
@@ -5,7 +5,7 @@ tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(7,1): error T
tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(8,1): error TS2322: Type 'E' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(12,1): error TS2322: Type 'C' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(16,1): error TS2322: Type 'I' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(18,1): error TS2322: Type '{ f: () => void; }' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(18,1): error TS2322: Type '{ f(): void; }' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(21,1): error TS2322: Type 'typeof M' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(24,5): error TS2322: Type 'T' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(26,1): error TS2322: Type '<T>(a: T) => void' is not assignable to type 'void'.
@@ -45,7 +45,7 @@ tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(26,1): error
x = { f() {} }
~
!!! error TS2322: Type '{ f: () => void; }' is not assignable to type 'void'.
!!! error TS2322: Type '{ f(): void; }' is not assignable to type 'void'.
module M { export var x = 1; }
x = M;
@@ -0,0 +1,19 @@
//// [letAsIdentifier.ts]
var let = 10;
var a = 10;
let = 30;
let
a;
//// [letAsIdentifier.js]
var let = 10;
var a = 10;
let = 30;
let;
a;
//// [letAsIdentifier.d.ts]
declare var let: number;
declare var a: number;
@@ -0,0 +1,18 @@
=== tests/cases/compiler/letAsIdentifier.ts ===
var let = 10;
>let : number
var a = 10;
>a : number
let = 30;
>let = 30 : number
>let : number
let
>let : number
a;
>a : number
@@ -0,0 +1,30 @@
tests/cases/compiler/letAsIdentifierInStrictMode.ts(2,5): error TS1134: Variable declaration expected.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(2,9): error TS1134: Variable declaration expected.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(2,11): error TS1134: Variable declaration expected.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(4,5): error TS1134: Variable declaration expected.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(4,7): error TS1134: Variable declaration expected.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(3,5): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(6,1): error TS2300: Duplicate identifier 'a'.
==== tests/cases/compiler/letAsIdentifierInStrictMode.ts (7 errors) ====
"use strict";
var let = 10;
~~~
!!! error TS1134: Variable declaration expected.
~
!!! error TS1134: Variable declaration expected.
~~
!!! error TS1134: Variable declaration expected.
var a = 10;
~
!!! error TS2300: Duplicate identifier 'a'.
let = 30;
~
!!! error TS1134: Variable declaration expected.
~~
!!! error TS1134: Variable declaration expected.
let
a;
~
!!! error TS2300: Duplicate identifier 'a'.
@@ -282,7 +282,7 @@ var C = (function () {
})();
// object literals
var o = {
f: function () {
f() {
let l = 0;
n = l;
},
@@ -240,7 +240,7 @@ var C = (function () {
})();
// object literals
var o = {
f: function () {
f() {
let l28 = 0;
},
f2: function () {
@@ -0,0 +1,9 @@
tests/cases/compiler/modifierOnParameter1.ts(2,16): error TS1090: 'declare' modifier cannot appear on a parameter.
==== tests/cases/compiler/modifierOnParameter1.ts (1 errors) ====
class C {
constructor(declare p) { }
~~~~~~~
!!! error TS1090: 'declare' modifier cannot appear on a parameter.
}
@@ -3,10 +3,9 @@ var x = 1
>x : number
var y = { x() { x++; } };
>y : { x: () => void; }
>{ x() { x++; } } : { x: () => void; }
>y : { x(): void; }
>{ x() { x++; } } : { x(): void; }
>x : () => void
>x() { x++; } : () => void
>x++ : number
>x : number
@@ -4,7 +4,7 @@ function then(x) {
>x : any
var match: { [index: number]: string; }
>match : { [x: number]: string; }
>match : { [index: number]: string; }
>index : number
}
@@ -1,10 +1,9 @@
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(27,16): error TS1005: ',' expected.
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(32,23): error TS1109: Expression expected.
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(32,16): error TS2304: Cannot find name 'string'.
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(32,23): error TS1005: '(' expected.
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(37,9): error TS2350: Only a void function can be called with the 'new' keyword.
==== tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts (4 errors) ====
==== tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts (3 errors) ====
class C0 {
@@ -40,9 +39,7 @@ tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(37,9):
var c1: T<{}>;
var c2 = new T<string>; // Parse error
~
!!! error TS1109: Expression expected.
~~~~~~
!!! error TS2304: Cannot find name 'string'.
!!! error TS1005: '(' expected.
// Construct expression of non-void returning function
@@ -7,7 +7,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(21,5): error TS2412: Property '3.0' of type 'MyNumber' is not assignable to numeric index type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(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; }'.
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'.
@@ -108,7 +108,7 @@ 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: 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'.
@@ -1,4 +1,4 @@
tests/cases/compiler/numericIndexerConstraint2.ts(4,1): error TS2322: Type '{ one: number; }' is not assignable to type '{ [x: string]: Foo; }'.
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; }'.
@@ -8,5 +8,5 @@ tests/cases/compiler/numericIndexerConstraint2.ts(4,1): error TS2322: Type '{ on
var a: { one: number; };
x = a;
~
!!! error TS2322: Type '{ one: number; }' is not assignable to type '{ [x: string]: Foo; }'.
!!! error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: Foo; }'.
!!! error TS2322: Index signature is missing in type '{ one: number; }'.
@@ -15,7 +15,7 @@ class B extends A {
}
var x: {
>x : { [x: number]: A; }
>x : { [idx: number]: A; }
[idx: number]: A;
>idx : number
@@ -1,4 +1,4 @@
tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ 0: Date; name: string; }' is not assignable to type '{ [x: number]: string; }'.
tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ 0: Date; name: string; }' is not assignable to type '{ [name: number]: string; }'.
Index signature is missing in type '{ 0: Date; name: string; }'.
@@ -6,5 +6,5 @@ tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ 0:
var x = { name: "x", 0: new Date() };
var z: { [name: number]: string } = x;
~
!!! error TS2322: Type '{ 0: Date; name: string; }' is not assignable to type '{ [x: number]: string; }'.
!!! error TS2322: Type '{ 0: Date; name: string; }' is not assignable to type '{ [name: number]: string; }'.
!!! error TS2322: Index signature is missing in type '{ 0: Date; name: string; }'.
@@ -1,4 +1,4 @@
tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [x: string]: A; [x: number]: B; }'.
tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'.
Index signatures are incompatible.
Type 'A' is not assignable to type 'B'.
@@ -18,7 +18,7 @@ tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{
var o1: { [s: string]: A;[n: number]: B; } = { x: b, 0: a }; // both indexers are A
~~
!!! error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [x: string]: A; [x: number]: B; }'.
!!! error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'.
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type 'A' is not assignable to type 'B'.
o1 = { x: c, 0: a }; // string indexer is any, number indexer is A
@@ -26,7 +26,7 @@ var c: any;
>c : any
var o1: { [s: string]: A;[n: number]: B; } = { x: a, 0: b }; // string indexer is A, number indexer is B
>o1 : { [x: string]: A; [x: number]: B; }
>o1 : { [s: string]: A; [n: number]: B; }
>s : string
>A : A
>n : number
@@ -38,7 +38,7 @@ var o1: { [s: string]: A;[n: number]: B; } = { x: a, 0: b }; // string indexer i
o1 = { x: b, 0: c }; // both indexers are any
>o1 = { x: b, 0: c } : { [x: string]: any; [x: number]: any; 0: any; x: B; }
>o1 : { [x: string]: A; [x: number]: B; }
>o1 : { [s: string]: A; [n: number]: B; }
>{ x: b, 0: c } : { [x: string]: any; [x: number]: any; 0: any; x: B; }
>x : B
>b : B
@@ -46,7 +46,7 @@ o1 = { x: b, 0: c }; // both indexers are any
o1 = { x: c, 0: b }; // string indexer is any, number indexer is B
>o1 = { x: c, 0: b } : { [x: string]: any; [x: number]: B; 0: B; x: any; }
>o1 : { [x: string]: A; [x: number]: B; }
>o1 : { [s: string]: A; [n: number]: B; }
>{ x: c, 0: b } : { [x: string]: any; [x: number]: B; 0: B; x: any; }
>x : any
>c : any

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