diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 5098b16e4bb..a0fd0b243d6 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -66,9 +66,9 @@ module ts { export function bindSourceFile(file: SourceFile) { var parent: Node; - var container: Declaration; + var container: Node; var blockScopeContainer: Node; - var lastContainer: Declaration; + var lastContainer: Node; var symbolCount = 0; var Symbol = objectAllocator.getSymbolConstructor(); @@ -222,7 +222,7 @@ module ts { // All container nodes are kept on a linked list in declaration order. This list is used by the getLocalNameOfContainer function // in the type checker to validate that the local name used for a container is unique. - function bindChildren(node: Declaration, symbolKind: SymbolFlags, isBlockScopeContainer: boolean) { + function bindChildren(node: Node, symbolKind: SymbolFlags, isBlockScopeContainer: boolean) { if (symbolKind & SymbolFlags.HasLocals) { node.locals = {}; } @@ -279,7 +279,7 @@ module ts { break; } case SyntaxKind.TypeLiteral: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.InterfaceDeclaration: declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); break; @@ -341,7 +341,7 @@ module ts { typeLiteralSymbol.members[node.kind === SyntaxKind.FunctionType ? "__call" : "__new"] = symbol } - function bindAnonymousDeclaration(node: Node, symbolKind: SymbolFlags, name: string, isBlockScopeContainer: boolean) { + function bindAnonymousDeclaration(node: Declaration, symbolKind: SymbolFlags, name: string, isBlockScopeContainer: boolean) { var symbol = createSymbol(symbolKind, name); addDeclarationToSymbol(symbol, node, symbolKind); bindChildren(node, symbolKind, isBlockScopeContainer); @@ -434,14 +434,14 @@ module ts { break; case SyntaxKind.TypeLiteral: - bindAnonymousDeclaration(node, SymbolFlags.TypeLiteral, "__type", /*isBlockScopeContainer*/ false); + bindAnonymousDeclaration(node, SymbolFlags.TypeLiteral, "__type", /*isBlockScopeContainer*/ false); break; - case SyntaxKind.ObjectLiteral: - bindAnonymousDeclaration(node, SymbolFlags.ObjectLiteral, "__object", /*isBlockScopeContainer*/ false); + case SyntaxKind.ObjectLiteralExpression: + bindAnonymousDeclaration(node, SymbolFlags.ObjectLiteral, "__object", /*isBlockScopeContainer*/ false); break; case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: - bindAnonymousDeclaration(node, SymbolFlags.Function, "__function", /*isBlockScopeContainer*/ true); + bindAnonymousDeclaration(node, SymbolFlags.Function, "__function", /*isBlockScopeContainer*/ true); break; case SyntaxKind.CatchBlock: bindCatchVariableDeclaration(node); @@ -471,7 +471,7 @@ module ts { break; case SyntaxKind.SourceFile: if (isExternalModule(node)) { - bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + removeFileExtension((node).filename) + '"', /*isBlockScopeContainer*/ true); + bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + removeFileExtension((node).filename) + '"', /*isBlockScopeContainer*/ true); break; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6afbbcdd510..738c684f554 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -935,7 +935,7 @@ module ts { return { accessibility: SymbolAccessibility.Accessible }; - function getExternalModuleContainer(declaration: Declaration) { + function getExternalModuleContainer(declaration: Node) { for (; declaration; declaration = declaration.parent) { if (hasExternalModuleSymbol(declaration)) { return getSymbolOfNode(declaration); @@ -944,8 +944,8 @@ module ts { } } - function hasExternalModuleSymbol(declaration: Declaration) { - return (declaration.kind === SyntaxKind.ModuleDeclaration && declaration.name.kind === SyntaxKind.StringLiteral) || + function hasExternalModuleSymbol(declaration: Node) { + return (declaration.kind === SyntaxKind.ModuleDeclaration && (declaration).name.kind === SyntaxKind.StringLiteral) || (declaration.kind === SyntaxKind.SourceFile && isExternalModule(declaration)); } @@ -962,7 +962,7 @@ module ts { // because these kind of aliases can be used to name types in declaration file if (declaration.kind === SyntaxKind.ImportDeclaration && !(declaration.flags & NodeFlags.Export) && - isDeclarationVisible(declaration.parent)) { + isDeclarationVisible(declaration.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { if (!contains(aliasesToMakeVisible, declaration)) { @@ -1061,7 +1061,7 @@ module ts { function getTypeAliasForTypeLiteral(type: Type): Symbol { if (type.symbol && type.symbol.flags & SymbolFlags.TypeLiteral) { var node = type.symbol.declarations[0].parent; - while (node.kind === SyntaxKind.ParenType) { + while (node.kind === SyntaxKind.ParenthesizedType) { node = node.parent; } if (node.kind === SyntaxKind.TypeAliasDeclaration) { @@ -1575,7 +1575,7 @@ module ts { } // Container of resolvedExportSymbol is visible - return forEach(resolvedExportSymbol.declarations, declaration => { + return forEach(resolvedExportSymbol.declarations, (declaration: Node) => { while (declaration) { if (declaration === node) { return true; @@ -1605,7 +1605,7 @@ module ts { return isGlobalSourceFile(parent) || isUsedInExportAssignment(node); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent); + return isDeclarationVisible(parent); case SyntaxKind.Property: case SyntaxKind.Method: @@ -1622,7 +1622,7 @@ module ts { case SyntaxKind.Parameter: case SyntaxKind.ModuleBlock: case SyntaxKind.TypeParameter: - return isDeclarationVisible(node.parent); + return isDeclarationVisible(node.parent); // Source file is always visible case SyntaxKind.SourceFile: @@ -1937,8 +1937,9 @@ module ts { } type.baseTypes = []; var declaration = getDeclarationOfKind(symbol, SyntaxKind.ClassDeclaration); - if (declaration.baseType) { - var baseType = getTypeFromTypeReferenceNode(declaration.baseType); + var baseTypeNode = getClassBaseTypeNode(declaration); + if (baseTypeNode) { + var baseType = getTypeFromTypeReferenceNode(baseTypeNode); if (baseType !== unknownType) { if (getTargetType(baseType).flags & TypeFlags.Class) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -1949,7 +1950,7 @@ module ts { } } else { - error(declaration.baseType, Diagnostics.A_class_may_only_extend_another_class); + error(baseTypeNode, Diagnostics.A_class_may_only_extend_another_class); } } } @@ -1977,8 +1978,8 @@ module ts { } type.baseTypes = []; forEach(symbol.declarations, declaration => { - if (declaration.kind === SyntaxKind.InterfaceDeclaration && (declaration).baseTypes) { - forEach((declaration).baseTypes, node => { + if (declaration.kind === SyntaxKind.InterfaceDeclaration && getInterfaceBaseTypeNodes(declaration)) { + forEach(getInterfaceBaseTypeNodes(declaration), node => { var baseType = getTypeFromTypeReferenceNode(node); if (baseType !== unknownType) { if (getTargetType(baseType).flags & (TypeFlags.Class | TypeFlags.Interface)) { @@ -3041,8 +3042,8 @@ module ts { return getTypeFromTupleTypeNode(node); case SyntaxKind.UnionType: return getTypeFromUnionTypeNode(node); - case SyntaxKind.ParenType: - return getTypeFromTypeNode((node).type); + case SyntaxKind.ParenthesizedType: + return getTypeFromTypeNode((node).type); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: case SyntaxKind.TypeLiteral: @@ -3223,11 +3224,11 @@ module ts { case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: return !(node).typeParameters && !forEach((node).parameters, p => p.type); - case SyntaxKind.ObjectLiteral: - return forEach((node).properties, p => + case SyntaxKind.ObjectLiteralExpression: + return forEach((node).properties, p => p.kind === SyntaxKind.PropertyAssignment && isContextSensitiveExpression((p).initializer)); - case SyntaxKind.ArrayLiteral: - return forEach((node).elements, e => isContextSensitiveExpression(e)); + case SyntaxKind.ArrayLiteralExpression: + return forEach((node).elements, e => isContextSensitiveExpression(e)); case SyntaxKind.ConditionalExpression: return isContextSensitiveExpression((node).whenTrue) || isContextSensitiveExpression((node).whenFalse); @@ -4302,8 +4303,8 @@ module ts { function isAssignedInBinaryExpression(node: BinaryExpression) { if (node.operator >= SyntaxKind.FirstAssignment && node.operator <= SyntaxKind.LastAssignment) { var n = node.left; - while (n.kind === SyntaxKind.ParenExpression) { - n = (n).expression; + while (n.kind === SyntaxKind.ParenthesizedExpression) { + n = (n).expression; } if (n.kind === SyntaxKind.Identifier && getResolvedSymbol(n) === symbol) { return true; @@ -4325,16 +4326,19 @@ module ts { return isAssignedInBinaryExpression(node); case SyntaxKind.VariableDeclaration: return isAssignedInVariableDeclaration(node); - case SyntaxKind.ArrayLiteral: - case SyntaxKind.ObjectLiteral: - case SyntaxKind.PropertyAccess: - case SyntaxKind.IndexedAccess: + case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.ObjectLiteralExpression: + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ElementAccessExpression: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: - case SyntaxKind.TypeAssertion: - case SyntaxKind.ParenExpression: - case SyntaxKind.PrefixOperator: - case SyntaxKind.PostfixOperator: + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.ParenthesizedExpression: + case SyntaxKind.PrefixUnaryExpression: + case SyntaxKind.DeleteExpression: + case SyntaxKind.TypeOfExpression: + case SyntaxKind.VoidExpression: + case SyntaxKind.PostfixUnaryExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.Block: case SyntaxKind.VariableStatement: @@ -4416,19 +4420,25 @@ module ts { return type; function narrowTypeByEquality(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { - var left = expr.left; - var right = expr.right; // Check that we have 'typeof ' on the left and string literal on the right - if (left.kind !== SyntaxKind.PrefixOperator || left.operator !== SyntaxKind.TypeOfKeyword || - left.operand.kind !== SyntaxKind.Identifier || right.kind !== SyntaxKind.StringLiteral || - getResolvedSymbol(left.operand) !== symbol) { + if (expr.left.kind !== SyntaxKind.TypeOfExpression || expr.right.kind !== SyntaxKind.StringLiteral) { return type; } + + var left = expr.left; + var right = expr.right; + if (left.expression.kind !== SyntaxKind.Identifier || + getResolvedSymbol(left.expression) !== symbol) { + + return type; + } + var t = right.text; var checkType: Type = t === "string" ? stringType : t === "number" ? numberType : t === "boolean" ? booleanType : emptyObjectType; if (expr.operator === SyntaxKind.ExclamationEqualsEqualsToken) { assumeTrue = !assumeTrue; } + if (assumeTrue) { // The assumed result is true. If check was for a primitive type, that type is the narrowed type. Otherwise we can // remove the primitive types from the narrowed type. @@ -4493,8 +4503,8 @@ module ts { // Narrow the given type based on the given expression having the assumed boolean value function narrowType(type: Type, expr: Expression, assumeTrue: boolean): Type { switch (expr.kind) { - case SyntaxKind.ParenExpression: - return narrowType(type, (expr).expression, assumeTrue); + case SyntaxKind.ParenthesizedExpression: + return narrowType(type, (expr).expression, assumeTrue); case SyntaxKind.BinaryExpression: var operator = (expr).operator; if (operator === SyntaxKind.EqualsEqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) { @@ -4510,9 +4520,9 @@ module ts { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case SyntaxKind.PrefixOperator: - if ((expr).operator === SyntaxKind.ExclamationToken) { - return narrowType(type, (expr).operand, !assumeTrue); + case SyntaxKind.PrefixUnaryExpression: + if ((expr).operator === SyntaxKind.ExclamationToken) { + return narrowType(type,(expr).operand, !assumeTrue); } break; } @@ -4622,10 +4632,10 @@ module ts { } function checkSuperExpression(node: Node): Type { - var isCallExpression = node.parent.kind === SyntaxKind.CallExpression && (node.parent).func === node; + var isCallExpression = node.parent.kind === SyntaxKind.CallExpression && (node.parent).expression === node; var enclosingClass = getAncestor(node, SyntaxKind.ClassDeclaration); var baseClass: Type; - if (enclosingClass && enclosingClass.baseType) { + if (enclosingClass && getClassBaseTypeNode(enclosingClass)) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); baseClass = classType.baseTypes.length && classType.baseTypes[0]; } @@ -4717,8 +4727,8 @@ module ts { // Return contextual type of parameter or undefined if no contextual type is available function getContextuallyTypedParameterType(parameter: ParameterDeclaration): Type { - var func = parameter.parent; - if (func.kind === SyntaxKind.FunctionExpression || func.kind === SyntaxKind.ArrowFunction) { + if (isFunctionExpressionOrArrowFunction(parameter.parent)) { + var func = parameter.parent; if (isContextSensitiveExpression(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -4768,7 +4778,7 @@ module ts { } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature // and that call signature is non-generic, return statements are contextually typed by the return type of the signature - var signature = getContextualSignature(func); + var signature = getContextualSignatureForFunctionLikeDeclaration(func); if (signature) { return getReturnTypeOfSignature(signature); } @@ -4861,7 +4871,7 @@ module ts { // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForPropertyExpression(node: Expression): Type { var declaration = node.parent; - var objectLiteral = declaration.parent; + var objectLiteral = declaration.parent; var type = getContextualType(objectLiteral); // TODO(jfreeman): Handle this case for computed names and symbols var name = (declaration.name).text; @@ -4877,7 +4887,7 @@ module ts { // the type of the property with the numeric name N in T, if one exists. Otherwise, it is the type of the numeric // index signature in T, if one exists. function getContextualTypeForElementExpression(node: Expression): Type { - var arrayLiteral = node.parent; + var arrayLiteral = node.parent; var type = getContextualType(arrayLiteral); if (type) { var index = indexOf(arrayLiteral.elements, node); @@ -4914,13 +4924,13 @@ module ts { case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: return getContextualTypeForArgument(node); - case SyntaxKind.TypeAssertion: + case SyntaxKind.TypeAssertionExpression: return getTypeFromTypeNode((parent).type); case SyntaxKind.BinaryExpression: return getContextualTypeForBinaryOperand(node); case SyntaxKind.PropertyAssignment: return getContextualTypeForPropertyExpression(node); - case SyntaxKind.ArrayLiteral: + case SyntaxKind.ArrayLiteralExpression: return getContextualTypeForElementExpression(node); case SyntaxKind.ConditionalExpression: return getContextualTypeForConditionalOperand(node); @@ -4940,12 +4950,21 @@ module ts { } } + function isFunctionExpressionOrArrowFunction(node: Node): boolean { + return node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction; + } + + function getContextualSignatureForFunctionLikeDeclaration(node: FunctionLikeDeclaration): Signature { + // Only function expressions and arrow functions are contextually typed. + return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; + } + // Return the contextual signature for a given expression node. A contextual type provides a // contextual signature if it has a single call signature and if that call signature is non-generic. // 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: Expression): Signature { + function getContextualSignature(node: FunctionExpression): Signature { var type = getContextualType(node); if (!type) { return undefined; @@ -4997,7 +5016,7 @@ module ts { return mapper && mapper !== identityMapper; } - function checkArrayLiteral(node: ArrayLiteral, contextualMapper?: TypeMapper): Type { + function checkArrayLiteral(node: ArrayLiteralExpression, contextualMapper?: TypeMapper): Type { var elements = node.elements; if (!elements.length) { return createArrayType(undefinedType); @@ -5035,7 +5054,7 @@ module ts { return (+name).toString() === name; } - function checkObjectLiteral(node: ObjectLiteral, contextualMapper?: TypeMapper): Type { + function checkObjectLiteral(node: ObjectLiteralExpression, contextualMapper?: TypeMapper): Type { var members = node.symbol.members; var properties: SymbolTable = {}; var contextualType = getContextualType(node); @@ -5050,7 +5069,9 @@ module ts { } else { Debug.assert(memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment); - type = checkExpression(memberDecl.name, contextualMapper); + type = memberDecl.name.kind === SyntaxKind.ComputedPropertyName + ? unknownType + : checkExpression(memberDecl.name, contextualMapper); } var prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name); prop.declarations = member.declarations; @@ -5112,7 +5133,7 @@ module ts { return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & SymbolFlags.Prototype ? NodeFlags.Public | NodeFlags.Static : 0; } - function checkClassPropertyAccess(node: PropertyAccess, type: Type, prop: Symbol) { + function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol) { var flags = getDeclarationFlagsFromSymbol(prop); // Public properties are always accessible if (!(flags & (NodeFlags.Private | NodeFlags.Protected))) { @@ -5132,7 +5153,7 @@ module ts { } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (node.left.kind === SyntaxKind.SuperKeyword) { + if (left.kind === SyntaxKind.SuperKeyword) { return; } // A protected property is accessible in the declaring class and classes derived from it @@ -5150,8 +5171,16 @@ module ts { } } - function checkPropertyAccess(node: PropertyAccess) { - var type = checkExpression(node.left); + function checkPropertyAccessExpression(node: PropertyAccessExpression) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + } + + function checkQualifiedName(node: QualifiedName) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + } + + function checkPropertyAccessExpressionOrQualifiedName(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, right: Identifier) { + var type = checkExpression(left); if (type === unknownType) return type; if (type !== anyType) { var apparentType = getApparentType(getWidenedType(type)); @@ -5159,10 +5188,10 @@ module ts { // handle cases when type is Type parameter with invalid constraint return unknownType; } - var prop = getPropertyOfType(apparentType, node.right.text); + var prop = getPropertyOfType(apparentType, right.text); if (!prop) { - if (node.right.text) { - error(node.right, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(node.right), typeToString(type)); + if (right.text) { + error(right, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(right), typeToString(type)); } return unknownType; } @@ -5175,11 +5204,11 @@ module ts { // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (node.left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.Method) { - error(node.right, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + if (left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.Method) { + error(right, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { - checkClassPropertyAccess(node, type, prop); + checkClassPropertyAccess(node, left, type, prop); } } return getTypeOfSymbol(prop); @@ -5187,17 +5216,21 @@ module ts { return anyType; } - function isValidPropertyAccess(node: PropertyAccess, propertyName: string): boolean { - var type = checkExpression(node.left); + function isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean { + var left = node.kind === SyntaxKind.PropertyAccessExpression + ? (node).expression + : (node).left; + + var type = checkExpression(left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & SymbolFlags.Class) { - if (node.left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.Method) { + if (left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.Method) { return false; } else { var diagnosticsCount = diagnostics.length; - checkClassPropertyAccess(node, type, prop); + checkClassPropertyAccess(node, left, type, prop); return diagnostics.length === diagnosticsCount } } @@ -5205,15 +5238,15 @@ module ts { return true; } - function checkIndexedAccess(node: IndexedAccess): Type { + function checkIndexedAccess(node: ElementAccessExpression): Type { // Obtain base constraint such that we can bail out if the constraint is an unknown type - var objectType = getApparentType(checkExpression(node.object)); - var indexType = checkExpression(node.index); + var objectType = getApparentType(checkExpression(node.expression)); + var indexType = checkExpression(node.argumentExpression); if (objectType === unknownType) return unknownType; - if (isConstEnumObjectType(objectType) && node.index.kind !== SyntaxKind.StringLiteral) { - error(node.index, Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); + if (isConstEnumObjectType(objectType) && node.argumentExpression.kind !== SyntaxKind.StringLiteral) { + error(node.argumentExpression, Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); } // TypeScript 1.0 spec (April 2014): 4.10 Property Access @@ -5226,8 +5259,8 @@ module ts { // - Otherwise, if IndexExpr is of type Any, the String or Number primitive type, or an enum type, the property access is of type Any. // See if we can index as a property. - if (node.index.kind === SyntaxKind.StringLiteral || node.index.kind === SyntaxKind.NumericLiteral) { - var name = (node.index).text; + if (node.argumentExpression.kind === SyntaxKind.StringLiteral || node.argumentExpression.kind === SyntaxKind.NumericLiteral) { + var name = (node.argumentExpression).text; var prop = getPropertyOfType(objectType, name); if (prop) { getNodeLinks(node).resolvedSymbol = prop; @@ -5474,7 +5507,7 @@ module ts { // String literals get string literal types unless we're reporting errors argType = arg.kind === SyntaxKind.StringLiteral && !reportErrors ? getStringLiteralType(arg) - : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } // Use argument expression as error location when reporting errors @@ -5626,7 +5659,7 @@ module ts { Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); - reportNoCommonSupertypeError(inferenceCandidates, (node).func || (node).tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, (node).expression || (node).tag, diagnosticChainHead); } } else { @@ -5756,15 +5789,15 @@ module ts { } function resolveCallExpression(node: CallExpression, candidatesOutArray: Signature[]): Signature { - if (node.func.kind === SyntaxKind.SuperKeyword) { - var superType = checkSuperExpression(node.func); + if (node.expression.kind === SyntaxKind.SuperKeyword) { + var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { return resolveCall(node, getSignaturesOfType(superType, SignatureKind.Construct), candidatesOutArray); } return resolveUntypedCall(node); } - var funcType = checkExpression(node.func); + var funcType = checkExpression(node.expression); var apparentType = getApparentType(funcType); if (apparentType === unknownType) { @@ -5808,7 +5841,7 @@ module ts { } function resolveNewExpression(node: NewExpression, candidatesOutArray: Signature[]): Signature { - var expressionType = checkExpression(node.func); + var expressionType = checkExpression(node.expression); // TS 1.0 spec: 4.11 // If ConstructExpr is of type Any, Args can be any argument // list and the result of the operation is of type Any. @@ -5908,7 +5941,7 @@ module ts { function checkCallExpression(node: CallExpression): Type { var signature = getResolvedSignature(node); - if (node.func.kind === SyntaxKind.SuperKeyword) { + if (node.expression.kind === SyntaxKind.SuperKeyword) { return voidType; } if (node.kind === SyntaxKind.NewExpression) { @@ -5933,7 +5966,7 @@ module ts { } function checkTypeAssertion(node: TypeAssertion): Type { - var exprType = checkExpression(node.operand); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (fullTypeCheck && targetType !== unknownType) { var widenedType = getWidenedType(exprType, /*supressNoImplicitAnyErrors*/ true); @@ -5965,9 +5998,9 @@ module ts { } function getReturnTypeFromBody(func: FunctionLikeDeclaration, contextualMapper?: TypeMapper): Type { - var contextualSignature = getContextualSignature(func); + var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (func.body.kind !== SyntaxKind.FunctionBlock) { - var unwidenedType = checkAndMarkExpression(func.body, contextualMapper); + var unwidenedType = checkAndMarkExpression(func.body, contextualMapper); var widenedType = getWidenedType(unwidenedType); if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { @@ -6123,7 +6156,7 @@ module ts { checkSourceElement(node.body); } else { - var exprType = checkExpression(node.body); + var exprType = checkExpression(node.body); if (node.type) { checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, /*headMessage*/ undefined); } @@ -6162,17 +6195,17 @@ module ts { // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & SymbolFlags.Variable) !== 0; - case SyntaxKind.PropertyAccess: + case SyntaxKind.PropertyAccessExpression: var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~SymbolFlags.EnumMember) !== 0; - case SyntaxKind.IndexedAccess: + case SyntaxKind.ElementAccessExpression: // old compiler doesn't check indexed assess return true; - case SyntaxKind.ParenExpression: - return isReferenceOrErrorExpression((n).expression); + case SyntaxKind.ParenthesizedExpression: + return isReferenceOrErrorExpression((n).expression); default: return false; } @@ -6181,20 +6214,20 @@ module ts { function isConstVariableReference(n: Node): boolean { switch (n.kind) { case SyntaxKind.Identifier: - case SyntaxKind.PropertyAccess: + case SyntaxKind.PropertyAccessExpression: var symbol = findSymbol(n); return symbol && (symbol.flags & SymbolFlags.Variable) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0; - case SyntaxKind.IndexedAccess: - var index = (n).index; - var symbol = findSymbol((n).object); + case SyntaxKind.ElementAccessExpression: + var index = (n).argumentExpression; + var symbol = findSymbol((n).expression); if (symbol && index.kind === SyntaxKind.StringLiteral) { var name = (index).text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name); return prop && (prop.flags & SymbolFlags.Variable) !== 0 && (getDeclarationFlagsFromSymbol(prop) & NodeFlags.Const) !== 0; } return false; - case SyntaxKind.ParenExpression: - return isConstVariableReference((n).expression); + case SyntaxKind.ParenthesizedExpression: + return isConstVariableReference((n).expression); default: return false; } @@ -6211,7 +6244,22 @@ module ts { return true; } - function checkPrefixExpression(node: UnaryExpression): Type { + function checkDeleteExpression(node: DeleteExpression): Type { + var operandType = checkExpression(node.expression); + return booleanType; + } + + function checkTypeOfExpression(node: TypeOfExpression): Type { + var operandType = checkExpression(node.expression); + return stringType; + } + + function checkVoidExpression(node: VoidExpression): Type { + var operandType = checkExpression(node.expression); + return undefinedType; + } + + function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { var operandType = checkExpression(node.operand); switch (node.operator) { case SyntaxKind.PlusToken: @@ -6219,12 +6267,7 @@ module ts { case SyntaxKind.TildeToken: return numberType; case SyntaxKind.ExclamationToken: - case SyntaxKind.DeleteKeyword: return booleanType; - case SyntaxKind.TypeOfKeyword: - return stringType; - case SyntaxKind.VoidKeyword: - return undefinedType; case SyntaxKind.PlusPlusToken: case SyntaxKind.MinusMinusToken: var ok = checkArithmeticOperandType(node.operand, operandType, Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); @@ -6239,7 +6282,7 @@ module ts { return unknownType; } - function checkPostfixExpression(node: UnaryExpression): Type { + function checkPostfixUnaryExpression(node: PostfixUnaryExpression): Type { var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -6490,12 +6533,12 @@ 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, contextualMapper?: TypeMapper): Type { + function checkExpression(node: Expression | QualifiedName, contextualMapper?: TypeMapper): Type { var type = checkExpressionNode(node, contextualMapper); - if (contextualMapper && contextualMapper !== identityMapper) { + if (contextualMapper && contextualMapper !== identityMapper && node.kind !== SyntaxKind.QualifiedName) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { - var contextualType = getContextualType(node); + var contextualType = getContextualType(node); if (contextualType) { var contextualSignature = getSingleCallSignature(contextualType); if (contextualSignature && !contextualSignature.typeParameters) { @@ -6511,9 +6554,9 @@ module ts { // - 'object' in indexed access // - target in rhs of import statement var ok = - (node.parent.kind === SyntaxKind.PropertyAccess && (node.parent).left === node) || - (node.parent.kind === SyntaxKind.IndexedAccess && (node.parent).object === node) || - ((node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName) && isInRightSideOfImportOrExportAssignment(node)); + (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).expression === node) || + (node.parent.kind === SyntaxKind.ElementAccessExpression && (node.parent).expression === node) || + ((node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); @@ -6522,7 +6565,7 @@ module ts { return type; } - function checkExpressionNode(node: Expression, contextualMapper: TypeMapper): Type { + function checkExpressionNode(node: Expression | QualifiedName, contextualMapper: TypeMapper): Type { switch (node.kind) { case SyntaxKind.Identifier: return checkIdentifier(node); @@ -6545,31 +6588,37 @@ module ts { case SyntaxKind.RegularExpressionLiteral: return globalRegExpType; case SyntaxKind.QualifiedName: - return checkPropertyAccess(node); - case SyntaxKind.ArrayLiteral: - return checkArrayLiteral(node, contextualMapper); - case SyntaxKind.ObjectLiteral: - return checkObjectLiteral(node, contextualMapper); - case SyntaxKind.PropertyAccess: - return checkPropertyAccess(node); - case SyntaxKind.IndexedAccess: - return checkIndexedAccess(node); + return checkQualifiedName(node); + case SyntaxKind.ArrayLiteralExpression: + return checkArrayLiteral(node, contextualMapper); + case SyntaxKind.ObjectLiteralExpression: + return checkObjectLiteral(node, contextualMapper); + case SyntaxKind.PropertyAccessExpression: + return checkPropertyAccessExpression(node); + case SyntaxKind.ElementAccessExpression: + return checkIndexedAccess(node); case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: return checkCallExpression(node); case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); - case SyntaxKind.TypeAssertion: + case SyntaxKind.TypeAssertionExpression: return checkTypeAssertion(node); - case SyntaxKind.ParenExpression: - return checkExpression((node).expression); + case SyntaxKind.ParenthesizedExpression: + return checkExpression((node).expression); case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: return checkFunctionExpression(node, contextualMapper); - case SyntaxKind.PrefixOperator: - return checkPrefixExpression(node); - case SyntaxKind.PostfixOperator: - return checkPostfixExpression(node); + case SyntaxKind.TypeOfExpression: + return checkTypeOfExpression(node); + case SyntaxKind.DeleteExpression: + return checkDeleteExpression(node); + case SyntaxKind.VoidExpression: + return checkVoidExpression(node); + case SyntaxKind.PrefixUnaryExpression: + return checkPrefixUnaryExpression(node); + case SyntaxKind.PostfixUnaryExpression: + return checkPostfixUnaryExpression(node); case SyntaxKind.BinaryExpression: return checkBinaryExpression(node, contextualMapper); case SyntaxKind.ConditionalExpression: @@ -6744,7 +6793,7 @@ module ts { } function isSuperCallExpression(n: Node): boolean { - return n.kind === SyntaxKind.CallExpression && (n).func.kind === SyntaxKind.SuperKeyword; + return n.kind === SyntaxKind.CallExpression && (n).expression.kind === SyntaxKind.SuperKeyword; } function containsSuperCall(n: Node): boolean { @@ -6755,7 +6804,7 @@ module ts { case SyntaxKind.FunctionExpression: case SyntaxKind.FunctionDeclaration: case SyntaxKind.ArrowFunction: - case SyntaxKind.ObjectLiteral: return false; + case SyntaxKind.ObjectLiteralExpression: return false; default: return forEachChild(n, containsSuperCall); } } @@ -6778,7 +6827,7 @@ module ts { // TS 1.0 spec (April 2014): 8.3.2 // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. - if ((node.parent).baseType) { + if (getClassBaseTypeNode(node.parent)) { if (containsSuperCall(node.body)) { // The first statement in the body of a constructor must be a super call if both of the following are true: @@ -7422,7 +7471,7 @@ module ts { return; } - if (enclosingClass.baseType) { + if (getClassBaseTypeNode(enclosingClass)) { var isDeclaration = node.kind !== SyntaxKind.Identifier; if (isDeclaration) { error(node, Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); @@ -7662,7 +7711,7 @@ module ts { checkTypeAssignableTo(caseType, expressionType, clause.expression, /*headMessage*/ undefined); } } - checkBlock(clause); + forEach(clause.statements, checkSourceElement); }); } @@ -7790,9 +7839,10 @@ module ts { var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); var staticType = getTypeOfSymbol(symbol); - if (node.baseType) { + var baseTypeNode = getClassBaseTypeNode(node); + if (baseTypeNode) { emitExtends = emitExtends || !isInAmbientContext(node); - checkTypeReference(node.baseType); + checkTypeReference(baseTypeNode); } if (type.baseTypes.length) { if (fullTypeCheck) { @@ -7801,18 +7851,20 @@ module ts { var staticBaseType = getTypeOfSymbol(baseType.symbol); checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(node, node.baseType.typeName, SymbolFlags.Value)) { - error(node.baseType, Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + if (baseType.symbol !== resolveEntityName(node, baseTypeNode.typeName, SymbolFlags.Value)) { + error(baseTypeNode, Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); } checkKindsOfPropertyMemberOverrides(type, baseType); } // Check that base type can be evaluated as expression - checkExpression(node.baseType.typeName); + checkExpression(baseTypeNode.typeName); } - if (node.implementedTypes) { - forEach(node.implementedTypes, typeRefNode => { + + var implementedTypeNodes = getClassImplementedTypeNodes(node); + if (implementedTypeNodes) { + forEach(implementedTypeNodes, typeRefNode => { checkTypeReference(typeRefNode); if (fullTypeCheck) { var t = getTypeFromTypeReferenceNode(typeRefNode); @@ -8007,7 +8059,7 @@ module ts { } } } - forEach(node.baseTypes, checkTypeReference); + forEach(getInterfaceBaseTypeNodes(node), checkTypeReference); forEach(node.members, checkSourceElement); if (fullTypeCheck) { @@ -8077,12 +8129,12 @@ module ts { function evalConstant(e: Node): number { switch (e.kind) { - case SyntaxKind.PrefixOperator: - var value = evalConstant((e).operand); + case SyntaxKind.PrefixUnaryExpression: + var value = evalConstant((e).operand); if (value === undefined) { return undefined; } - switch ((e).operator) { + switch ((e).operator) { case SyntaxKind.PlusToken: return value; case SyntaxKind.MinusToken: return -value; case SyntaxKind.TildeToken: return enumIsConst ? ~value : undefined; @@ -8117,11 +8169,11 @@ module ts { return undefined; case SyntaxKind.NumericLiteral: return +(e).text; - case SyntaxKind.ParenExpression: - return enumIsConst ? evalConstant((e).expression) : undefined; + case SyntaxKind.ParenthesizedExpression: + return enumIsConst ? evalConstant((e).expression) : undefined; case SyntaxKind.Identifier: - case SyntaxKind.IndexedAccess: - case SyntaxKind.PropertyAccess: + case SyntaxKind.ElementAccessExpression: + case SyntaxKind.PropertyAccessExpression: if (!enumIsConst) { return undefined; } @@ -8138,16 +8190,16 @@ module ts { propertyName = (e).text; } else { - if (e.kind === SyntaxKind.IndexedAccess) { - if ((e).index.kind !== SyntaxKind.StringLiteral) { + if (e.kind === SyntaxKind.ElementAccessExpression) { + if ((e).argumentExpression.kind !== SyntaxKind.StringLiteral) { return undefined; } - var enumType = getTypeOfNode((e).object); - propertyName = ((e).index).text; + var enumType = getTypeOfNode((e).expression); + propertyName = ((e).argumentExpression).text; } else { - var enumType = getTypeOfNode((e).left); - propertyName = (e).right.text; + var enumType = getTypeOfNode((e).expression); + propertyName = (e).name.text; } if (enumType !== currentType) { return undefined; @@ -8383,8 +8435,8 @@ module ts { return checkTupleType(node); case SyntaxKind.UnionType: return checkUnionType(node); - case SyntaxKind.ParenType: - return checkSourceElement((node).type); + case SyntaxKind.ParenthesizedType: + return checkSourceElement((node).type); case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); case SyntaxKind.Block: @@ -8468,18 +8520,21 @@ module ts { break; case SyntaxKind.Parameter: case SyntaxKind.Property: - case SyntaxKind.ArrayLiteral: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.PropertyAssignment: - case SyntaxKind.PropertyAccess: - case SyntaxKind.IndexedAccess: + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ElementAccessExpression: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.TaggedTemplateExpression: - case SyntaxKind.TypeAssertion: - case SyntaxKind.ParenExpression: - case SyntaxKind.PrefixOperator: - case SyntaxKind.PostfixOperator: + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.ParenthesizedExpression: + case SyntaxKind.TypeOfExpression: + case SyntaxKind.VoidExpression: + case SyntaxKind.DeleteExpression: + case SyntaxKind.PrefixUnaryExpression: + case SyntaxKind.PostfixUnaryExpression: case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.Block: @@ -8525,7 +8580,10 @@ module ts { if (!(links.flags & NodeCheckFlags.TypeChecked)) { emitExtends = false; potentialThisCollisions.length = 0; - checkBody(node); + + forEach(node.statements, checkSourceElement); + checkFunctionExpressionBodies(node); + if (isExternalModule(node)) { var symbol = getExportAssignmentSymbol(node.symbol); if (symbol && symbol.flags & SymbolFlags.Import) { @@ -8533,11 +8591,16 @@ module ts { getSymbolLinks(symbol).referenced = true; } } + if (potentialThisCollisions.length) { forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } - if (emitExtends) links.flags |= NodeCheckFlags.EmitExtends; + + if (emitExtends) { + links.flags |= NodeCheckFlags.EmitExtends; + } + links.flags |= NodeCheckFlags.TypeChecked; } } @@ -8705,7 +8768,7 @@ module ts { case SyntaxKind.BooleanKeyword: return true; case SyntaxKind.VoidKeyword: - return node.parent.kind !== SyntaxKind.PrefixOperator; + return node.parent.kind !== SyntaxKind.VoidExpression; case SyntaxKind.StringLiteral: // Specialized signatures can have string literals as their parameters' type names return node.parent.kind === SyntaxKind.Parameter; @@ -8754,7 +8817,7 @@ module ts { case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: return node === (parent).type; - case SyntaxKind.TypeAssertion: + case SyntaxKind.TypeAssertionExpression: return node === (parent).type; case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: @@ -8784,27 +8847,29 @@ module ts { } function isRightSideOfQualifiedNameOrPropertyAccess(node: Node) { - return (node.parent.kind === SyntaxKind.QualifiedName || node.parent.kind === SyntaxKind.PropertyAccess) && - (node.parent).right === node; + return (node.parent.kind === SyntaxKind.QualifiedName && (node.parent).right === node) || + (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node); } - function getSymbolOfEntityName(entityName: EntityName): Symbol { + function getSymbolOfEntityNameOrPropertyAccessExpression(entityName: EntityName | PropertyAccessExpression): Symbol { if (isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) { return getSymbolOfNode(entityName.parent); } if (entityName.parent.kind === SyntaxKind.ExportAssignment) { - return resolveEntityName(/*location*/ entityName.parent.parent, entityName, + return resolveEntityName(/*location*/ entityName.parent.parent, entityName, /*all meanings*/ SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Import); } - if (isInRightSideOfImportOrExportAssignment(entityName)) { - // Since we already checked for ExportAssignment, this really could only be an Import - return getSymbolOfPartOfRightHandSideOfImport(entityName); + if (entityName.kind !== SyntaxKind.PropertyAccessExpression) { + if (isInRightSideOfImportOrExportAssignment(entityName)) { + // Since we already checked for ExportAssignment, this really could only be an Import + return getSymbolOfPartOfRightHandSideOfImport(entityName); + } } if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { - entityName = entityName.parent; + entityName = entityName.parent; } if (isExpression(entityName)) { @@ -8812,12 +8877,19 @@ module ts { // Include Import in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. var meaning: SymbolFlags = SymbolFlags.Value | SymbolFlags.Import; - return resolveEntityName(entityName, entityName, meaning); + return resolveEntityName(entityName, entityName, meaning); } - else if (entityName.kind === SyntaxKind.QualifiedName || entityName.kind === SyntaxKind.PropertyAccess) { + else if (entityName.kind === SyntaxKind.PropertyAccessExpression) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { - checkPropertyAccess(entityName); + checkPropertyAccessExpression(entityName); + } + return getNodeLinks(entityName).resolvedSymbol; + } + else if (entityName.kind === SyntaxKind.QualifiedName) { + var symbol = getNodeLinks(entityName).resolvedSymbol; + if (!symbol) { + checkQualifiedName(entityName); } return getNodeLinks(entityName).resolvedSymbol; } @@ -8826,12 +8898,12 @@ module ts { return; } } - else if (isTypeReferenceIdentifier(entityName)) { + else if (isTypeReferenceIdentifier(entityName)) { var meaning = entityName.parent.kind === SyntaxKind.TypeReference ? SymbolFlags.Type : SymbolFlags.Namespace; // Include Import in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= SymbolFlags.Import; - return resolveEntityName(entityName, entityName, meaning); + return resolveEntityName(entityName, entityName, meaning); } // Do we want to return undefined here? @@ -8851,19 +8923,19 @@ module ts { if (node.kind === SyntaxKind.Identifier && isInRightSideOfImportOrExportAssignment(node)) { return node.parent.kind === SyntaxKind.ExportAssignment - ? getSymbolOfEntityName(node) + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImport(node); } switch (node.kind) { case SyntaxKind.Identifier: - case SyntaxKind.PropertyAccess: + case SyntaxKind.PropertyAccessExpression: case SyntaxKind.QualifiedName: - return getSymbolOfEntityName(node); + return getSymbolOfEntityNameOrPropertyAccessExpression(node); case SyntaxKind.ThisKeyword: case SyntaxKind.SuperKeyword: - var type = checkExpression(node); + var type = checkExpression(node); return type.symbol; case SyntaxKind.ConstructorKeyword: @@ -8885,8 +8957,8 @@ module ts { // Intentional fall-through case SyntaxKind.NumericLiteral: // index access - if (node.parent.kind == SyntaxKind.IndexedAccess && (node.parent).index === node) { - var objectType = checkExpression((node.parent).object); + if (node.parent.kind == SyntaxKind.ElementAccessExpression && (node.parent).argumentExpression === node) { + var objectType = checkExpression((node.parent).expression); if (objectType === unknownType) return undefined; var apparentType = getApparentType(objectType); if (apparentType === unknownType) return undefined; @@ -8954,7 +9026,7 @@ module ts { function getTypeOfExpression(expr: Expression): Type { if (isRightSideOfQualifiedNameOrPropertyAccess(expr)) { - expr = expr.parent; + expr = expr.parent; } return checkExpression(expr); } @@ -9138,7 +9210,7 @@ module ts { return getNodeLinks(node).enumMemberValue; } - function getConstantValue(node: PropertyAccess | IndexedAccess): number { + function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & SymbolFlags.EnumMember)) { var declaration = symbol.valueDeclaration; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 4b4909a54f3..c17cf94e8c0 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -134,6 +134,11 @@ module ts { Computed_property_names_are_not_allowed_in_interfaces: { code: 1169, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in interfaces." }, Computed_property_names_are_not_allowed_in_type_literals: { code: 1170, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in type literals." }, A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." }, + extends_clause_already_seen: { code: 1172, category: DiagnosticCategory.Error, key: "'extends' clause already seen." }, + extends_clause_must_precede_implements_clause: { code: 1173, category: DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause." }, + Classes_can_only_extend_a_single_class: { code: 1174, category: DiagnosticCategory.Error, key: "Classes can only extend a single class." }, + implements_clause_already_seen: { code: 1175, category: DiagnosticCategory.Error, key: "'implements' clause already seen." }, + Interface_declaration_cannot_have_implements_clause: { code: 1176, category: DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c05d612b534..3d5be6d566a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -527,6 +527,26 @@ "category": "Error", "code": 1171 }, + "'extends' clause already seen.": { + "category": "Error", + "code": 1172 + }, + "'extends' clause must precede 'implements' clause.": { + "category": "Error", + "code": 1173 + }, + "Classes can only extend a single class.": { + "category": "Error", + "code": 1174 + }, + "'implements' clause already seen.": { + "category": "Error", + "code": 1175 + }, + "Interface declaration cannot have 'implements' clause.": { + "category": "Error", + "code": 1176 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 2f573e57af7..df99de098f3 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -357,7 +357,7 @@ module ts { var currentSourceFile: SourceFile; var reportedDeclarationError = false; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration: Declaration) { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments; var aliasDeclarationEmitInfo: AliasDeclarationEmitInfo[] = []; @@ -485,7 +485,7 @@ module ts { emitSeparatedList(nodes, ", ", eachNodeEmitFn); } - function writeJsDocComments(declaration: Declaration) { + function writeJsDocComments(declaration: Node) { if (declaration) { var jsDocComments = getJsDocComments(declaration, currentSourceFile); emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); @@ -518,8 +518,8 @@ module ts { return emitTupleType(type); case SyntaxKind.UnionType: return emitUnionType(type); - case SyntaxKind.ParenType: - return emitParenType(type); + case SyntaxKind.ParenthesizedType: + return emitParenType(type); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: return emitSignatureDeclarationWithJsDocComments(type); @@ -583,7 +583,7 @@ module ts { emitSeparatedList(type.types, " | ", emitType); } - function emitParenType(type: ParenTypeNode) { + function emitParenType(type: ParenthesizedTypeNode) { write("("); emitType(type.type); write(")"); @@ -615,7 +615,7 @@ module ts { writeLine(); } - function emitModuleElementDeclarationFlags(node: Declaration) { + function emitModuleElementDeclarationFlags(node: Node) { // If the node is parented in the current source file we need to emit export declare or just export if (node.parent === currentSourceFile) { // If the node is exported @@ -701,7 +701,7 @@ module ts { write(" {"); writeLine(); increaseIndent(); - emitLines((node.body).statements); + emitLines((node.body).statements); decreaseIndent(); write("}"); writeLine(); @@ -851,11 +851,11 @@ module ts { function getHeritageClauseVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { var diagnosticMessage: DiagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.kind === SyntaxKind.ClassDeclaration) { + if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? - Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : - Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; + Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : + Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } else { // interface is inaccessible @@ -865,7 +865,7 @@ module ts { return { diagnosticMessage, errorNode: node, - typeName: (node.parent).name + typeName: (node.parent.parent).name }; } } @@ -890,10 +890,11 @@ module ts { var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - if (node.baseType) { - emitHeritageClause([node.baseType], /*isImplementsList*/ false); + var baseTypeNode = getClassBaseTypeNode(node); + if (baseTypeNode) { + emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); } - emitHeritageClause(node.implementedTypes, /*isImplementsList*/ true); + emitHeritageClause(getClassImplementedTypeNodes(node), /*isImplementsList*/ true); write(" {"); writeLine(); increaseIndent(); @@ -915,7 +916,7 @@ module ts { var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - emitHeritageClause(node.baseTypes, /*isImplementsList*/ false); + emitHeritageClause(getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); write(" {"); writeLine(); increaseIndent(); @@ -927,7 +928,7 @@ module ts { } } - function emitPropertyDeclaration(node: PropertyDeclaration) { + function emitPropertyDeclaration(node: Declaration) { emitJsDocComments(node); emitClassMemberDeclarationFlags(node); emitVariableDeclaration(node); @@ -1996,7 +1997,7 @@ module ts { // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== SyntaxKind.ParenExpression + var needsParens = templateSpan.expression.kind !== SyntaxKind.ParenthesizedExpression && comparePrecedenceToBinaryPlus(templateSpan.expression) !== Comparison.GreaterThan; write(" + "); @@ -2027,8 +2028,8 @@ module ts { switch (parent.kind) { case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: - return (parent).func === template; - case SyntaxKind.ParenExpression: + return (parent).expression === template; + case SyntaxKind.ParenthesizedExpression: return false; case SyntaxKind.TaggedTemplateExpression: Debug.fail("Path should be unreachable; tagged templates not supported pre-ES6."); @@ -2170,7 +2171,7 @@ module ts { } } - function emitArrayLiteral(node: ArrayLiteral) { + function emitArrayLiteral(node: ArrayLiteralExpression) { if (node.flags & NodeFlags.MultiLine) { write("["); increaseIndent(); @@ -2186,7 +2187,7 @@ module ts { } } - function emitObjectLiteral(node: ObjectLiteral) { + function emitObjectLiteral(node: ObjectLiteralExpression) { if (!node.properties.length) { write("{}"); } @@ -2249,48 +2250,54 @@ module ts { } } - function tryEmitConstantValue(node: PropertyAccess | IndexedAccess): boolean { + function tryEmitConstantValue(node: PropertyAccessExpression | ElementAccessExpression): boolean { var constantValue = resolver.getConstantValue(node); if (constantValue !== undefined) { - var propertyName = node.kind === SyntaxKind.PropertyAccess ? declarationNameToString((node).right) : getTextOfNode((node).index); + var propertyName = node.kind === SyntaxKind.PropertyAccessExpression ? declarationNameToString((node).name) : getTextOfNode((node).argumentExpression); write(constantValue.toString() + " /* " + propertyName + " */"); return true; } return false; } - function emitPropertyAccess(node: PropertyAccess) { + function emitPropertyAccess(node: PropertyAccessExpression) { if (tryEmitConstantValue(node)) { return; } + emit(node.expression); + write("."); + emit(node.name); + } + + function emitQualifiedName(node: QualifiedName) { emit(node.left); write("."); emit(node.right); } - function emitIndexedAccess(node: IndexedAccess) { + function emitIndexedAccess(node: ElementAccessExpression) { if (tryEmitConstantValue(node)) { return; } - emit(node.object); + emit(node.expression); write("["); - emit(node.index); + emit(node.argumentExpression); write("]"); } function emitCallExpression(node: CallExpression) { var superCall = false; - if (node.func.kind === SyntaxKind.SuperKeyword) { + if (node.expression.kind === SyntaxKind.SuperKeyword) { write("_super"); superCall = true; } else { - emit(node.func); - superCall = node.func.kind === SyntaxKind.PropertyAccess && (node.func).left.kind === SyntaxKind.SuperKeyword; + emit(node.expression); + superCall = node.expression.kind === SyntaxKind.PropertyAccessExpression && (node.expression).expression.kind === SyntaxKind.SuperKeyword; } if (superCall) { write(".call("); - emitThis(node.func); + emitThis(node.expression); if (node.arguments.length) { write(", "); emitCommaList(node.arguments, /*includeTrailingComma*/ false); @@ -2306,7 +2313,7 @@ module ts { function emitNewExpression(node: NewExpression) { write("new "); - emit(node.func); + emit(node.expression); if (node.arguments) { write("("); emitCommaList(node.arguments, /*includeTrailingComma*/ false); @@ -2321,14 +2328,14 @@ module ts { emit(node.template); } - function emitParenExpression(node: ParenExpression) { - if (node.expression.kind === SyntaxKind.TypeAssertion) { - var operand = (node.expression).operand; + function emitParenExpression(node: ParenthesizedExpression) { + if (node.expression.kind === SyntaxKind.TypeAssertionExpression) { + var operand = (node.expression).expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind == SyntaxKind.TypeAssertion) { - operand = (operand).operand; + while (operand.kind == SyntaxKind.TypeAssertionExpression) { + operand = (operand).expression; } // We have an expression of the form: (SubExpr) @@ -2339,7 +2346,12 @@ module ts { // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== SyntaxKind.PrefixOperator && operand.kind !== SyntaxKind.PostfixOperator && operand.kind !== SyntaxKind.NewExpression && + if (operand.kind !== SyntaxKind.PrefixUnaryExpression && + operand.kind !== SyntaxKind.VoidExpression && + operand.kind !== SyntaxKind.TypeOfExpression && + operand.kind !== SyntaxKind.DeleteExpression && + operand.kind !== SyntaxKind.PostfixUnaryExpression && + operand.kind !== SyntaxKind.NewExpression && !(operand.kind === SyntaxKind.CallExpression && node.parent.kind === SyntaxKind.NewExpression) && !(operand.kind === SyntaxKind.FunctionExpression && node.parent.kind === SyntaxKind.CallExpression)) { emit(operand); @@ -2351,10 +2363,26 @@ module ts { write(")"); } - function emitUnaryExpression(node: UnaryExpression) { - if (node.kind === SyntaxKind.PrefixOperator) { - write(tokenToString(node.operator)); - } + function emitDeleteExpression(node: DeleteExpression) { + write(tokenToString(SyntaxKind.DeleteKeyword)); + write(" "); + emit(node.expression); + } + + function emitVoidExpression(node: VoidExpression) { + write(tokenToString(SyntaxKind.VoidKeyword)); + write(" "); + emit(node.expression); + } + + function emitTypeOfExpression(node: TypeOfExpression) { + write(tokenToString(SyntaxKind.TypeOfKeyword)); + write(" "); + emit(node.expression); + } + + function emitPrefixUnaryExpression(node: PrefixUnaryExpression) { + write(tokenToString(node.operator)); // In some cases, we need to emit a space between the operator and the operand. One obvious case // is when the operator is an identifier, like delete or typeof. We also need to do this for plus // and minus expressions in certain cases. Specifically, consider the following two cases (parens @@ -2367,11 +2395,8 @@ module ts { // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operator >= SyntaxKind.Identifier) { - write(" "); - } - else if (node.kind === SyntaxKind.PrefixOperator && node.operand.kind === SyntaxKind.PrefixOperator) { - var operand = node.operand; + if (node.operand.kind === SyntaxKind.PrefixUnaryExpression) { + var operand = node.operand; if (node.operator === SyntaxKind.PlusToken && (operand.operator === SyntaxKind.PlusToken || operand.operator === SyntaxKind.PlusPlusToken)) { write(" "); } @@ -2380,11 +2405,14 @@ module ts { } } emit(node.operand); - if (node.kind === SyntaxKind.PostfixOperator) { - write(tokenToString(node.operator)); - } } + function emitPostfixUnaryExpression(node: PostfixUnaryExpression) { + emit(node.operand); + write(tokenToString(node.operator)); + } + + function emitBinaryExpression(node: BinaryExpression) { emit(node.left); if (node.operator !== SyntaxKind.CommaToken) write(" "); @@ -2860,7 +2888,7 @@ module ts { if (statement && statement.kind === SyntaxKind.ExpressionStatement) { var expr = (statement).expression; if (expr && expr.kind === SyntaxKind.CallExpression) { - var func = (expr).func; + var func = (expr).expression; if (func && func.kind === SyntaxKind.SuperKeyword) { return statement; } @@ -3006,19 +3034,20 @@ module ts { write("var "); emit(node.name); write(" = (function ("); - if (node.baseType) { + var baseTypeNode = getClassBaseTypeNode(node); + if (baseTypeNode) { write("_super"); } write(") {"); increaseIndent(); scopeEmitStart(node); - if (node.baseType) { + if (baseTypeNode) { writeLine(); - emitStart(node.baseType); + emitStart(baseTypeNode); write("__extends("); emit(node.name); write(", _super);"); - emitEnd(node.baseType); + emitEnd(baseTypeNode); } writeLine(); emitConstructorOfClass(); @@ -3037,8 +3066,8 @@ module ts { scopeEmitEnd(); emitStart(node); write(")("); - if (node.baseType) { - emit(node.baseType.typeName); + if (baseTypeNode) { + emit(baseTypeNode.typeName); } write(");"); emitEnd(node); @@ -3079,7 +3108,7 @@ module ts { if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); - if (node.baseType) { + if (baseTypeNode) { var superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); @@ -3089,11 +3118,11 @@ module ts { emitParameterPropertyAssignments(ctor); } else { - if (node.baseType) { + if (baseTypeNode) { writeLine(); - emitStart(node.baseType); + emitStart(baseTypeNode); write("_super.apply(this, arguments);"); - emitEnd(node.baseType); + emitEnd(baseTypeNode); } } emitMemberAssignments(node, /*nonstatic*/0); @@ -3231,7 +3260,7 @@ module ts { emit(node.body); decreaseIndent(); writeLine(); - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; emitToken(SyntaxKind.CloseBraceToken, moduleBlock.statements.end); scopeEmitEnd(); } @@ -3377,7 +3406,7 @@ module ts { } } - function emitDirectivePrologues(statements: Statement[], startWithNewLine: boolean): number { + function emitDirectivePrologues(statements: Node[], startWithNewLine: boolean): number { for (var i = 0; i < statements.length; ++i) { if (isPrologueDirective(statements[i])) { if (startWithNewLine || i > 0) { @@ -3471,38 +3500,45 @@ module ts { case SyntaxKind.TemplateSpan: return emitTemplateSpan(node); case SyntaxKind.QualifiedName: - return emitPropertyAccess(node); - case SyntaxKind.ArrayLiteral: - return emitArrayLiteral(node); - case SyntaxKind.ObjectLiteral: - return emitObjectLiteral(node); + return emitQualifiedName(node); + case SyntaxKind.ArrayLiteralExpression: + return emitArrayLiteral(node); + case SyntaxKind.ObjectLiteralExpression: + return emitObjectLiteral(node); case SyntaxKind.PropertyAssignment: return emitPropertyAssignment(node); case SyntaxKind.ShorthandPropertyAssignment: return emitShortHandPropertyAssignment(node); case SyntaxKind.ComputedPropertyName: return emitComputedPropertyName(node); - case SyntaxKind.PropertyAccess: - return emitPropertyAccess(node); - case SyntaxKind.IndexedAccess: - return emitIndexedAccess(node); + case SyntaxKind.PropertyAccessExpression: + return emitPropertyAccess(node); + case SyntaxKind.ElementAccessExpression: + return emitIndexedAccess(node); case SyntaxKind.CallExpression: return emitCallExpression(node); case SyntaxKind.NewExpression: return emitNewExpression(node); case SyntaxKind.TaggedTemplateExpression: return emitTaggedTemplateExpression(node); - case SyntaxKind.TypeAssertion: - return emit((node).operand); - case SyntaxKind.ParenExpression: - return emitParenExpression(node); + case SyntaxKind.TypeAssertionExpression: + return emit((node).expression); + case SyntaxKind.ParenthesizedExpression: + return emitParenExpression(node); case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: return emitFunctionDeclaration(node); - case SyntaxKind.PrefixOperator: - case SyntaxKind.PostfixOperator: - return emitUnaryExpression(node); + case SyntaxKind.DeleteExpression: + return emitDeleteExpression(node); + case SyntaxKind.TypeOfExpression: + return emitTypeOfExpression(node); + case SyntaxKind.VoidExpression: + return emitVoidExpression(node); + case SyntaxKind.PrefixUnaryExpression: + return emitPrefixUnaryExpression(node); + case SyntaxKind.PostfixUnaryExpression: + return emitPostfixUnaryExpression(node); case SyntaxKind.BinaryExpression: return emitBinaryExpression(node); case SyntaxKind.ConditionalExpression: diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c677f0916c8..2b8acf0feb1 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -126,15 +126,15 @@ module ts { return (file.flags & NodeFlags.DeclarationFile) !== 0; } - export function isConstEnumDeclaration(node: Declaration): boolean { + export function isConstEnumDeclaration(node: Node): boolean { return node.kind === SyntaxKind.EnumDeclaration && isConst(node); } - export function isConst(node: Declaration): boolean { + export function isConst(node: Node): boolean { return !!(node.flags & NodeFlags.Const); } - export function isLet(node: Declaration): boolean { + export function isLet(node: Node): boolean { return !!(node.flags & NodeFlags.Let); } @@ -171,8 +171,8 @@ module ts { } } - export function getJsDocComments(node: Declaration, sourceFileOfNode: SourceFile) { - return filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), comment => isJsDocComment(comment)); + export function getJsDocComments(node: Node, sourceFileOfNode: SourceFile) { + return filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); function isJsDocComment(comment: CommentRange) { // True if the comment starts with '/**' but not if it is '/**/' @@ -253,34 +253,41 @@ module ts { return children((node).elementTypes); case SyntaxKind.UnionType: return children((node).types); - case SyntaxKind.ParenType: - return child((node).type); - case SyntaxKind.ArrayLiteral: - return children((node).elements); - case SyntaxKind.ObjectLiteral: - return children((node).properties); - case SyntaxKind.PropertyAccess: - return child((node).left) || - child((node).right); - case SyntaxKind.IndexedAccess: - return child((node).object) || - child((node).index); + case SyntaxKind.ParenthesizedType: + return child((node).type); + case SyntaxKind.ArrayLiteralExpression: + return children((node).elements); + case SyntaxKind.ObjectLiteralExpression: + return children((node).properties); + case SyntaxKind.PropertyAccessExpression: + return child((node).expression) || + child((node).name); + case SyntaxKind.ElementAccessExpression: + return child((node).expression) || + child((node).argumentExpression); case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: - return child((node).func) || + return child((node).expression) || children((node).typeArguments) || children((node).arguments); case SyntaxKind.TaggedTemplateExpression: return child((node).tag) || child((node).template); - case SyntaxKind.TypeAssertion: + case SyntaxKind.TypeAssertionExpression: return child((node).type) || - child((node).operand); - case SyntaxKind.ParenExpression: - return child((node).expression); - case SyntaxKind.PrefixOperator: - case SyntaxKind.PostfixOperator: - return child((node).operand); + child((node).expression); + case SyntaxKind.ParenthesizedExpression: + return child((node).expression); + case SyntaxKind.DeleteExpression: + return child((node).expression); + case SyntaxKind.TypeOfExpression: + return child((node).expression); + case SyntaxKind.VoidExpression: + return child((node).expression); + case SyntaxKind.PrefixUnaryExpression: + return child((node).operand); + case SyntaxKind.PostfixUnaryExpression: + return child((node).operand); case SyntaxKind.BinaryExpression: return child((node).left) || child((node).right); @@ -354,13 +361,12 @@ module ts { case SyntaxKind.ClassDeclaration: return child((node).name) || children((node).typeParameters) || - child((node).baseType) || - children((node).implementedTypes) || + children((node).heritageClauses) || children((node).members); case SyntaxKind.InterfaceDeclaration: return child((node).name) || - children((node).typeParameters) || - children((node).baseTypes) || + children((node).typeParameters) || + children((node).heritageClauses) || children((node).members); case SyntaxKind.TypeAliasDeclaration: return child((node).name) || @@ -386,6 +392,8 @@ module ts { return child((node).expression) || child((node).literal); case SyntaxKind.ComputedPropertyName: return child((node).expression); + case SyntaxKind.HeritageClause: + return children((node).types); } } @@ -398,7 +406,7 @@ module ts { function traverse(node: Node): T { switch (node.kind) { case SyntaxKind.ReturnStatement: - return visitor(node); + return visitor(node); case SyntaxKind.Block: case SyntaxKind.FunctionBlock: case SyntaxKind.IfStatement: @@ -437,11 +445,11 @@ module ts { return false; } - export function getContainingFunction(node: Node): SignatureDeclaration { + export function getContainingFunction(node: Node): FunctionLikeDeclaration { while (true) { node = node.parent; if (!node || isAnyFunction(node)) { - return node; + return node; } } } @@ -496,7 +504,7 @@ module ts { } // Will either be a CallExpression or NewExpression. - return (node).func; + return (node).expression; } export function isExpression(node: Node): boolean { @@ -507,19 +515,22 @@ module ts { case SyntaxKind.TrueKeyword: case SyntaxKind.FalseKeyword: case SyntaxKind.RegularExpressionLiteral: - case SyntaxKind.ArrayLiteral: - case SyntaxKind.ObjectLiteral: - case SyntaxKind.PropertyAccess: - case SyntaxKind.IndexedAccess: + case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.ObjectLiteralExpression: + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ElementAccessExpression: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.TaggedTemplateExpression: - case SyntaxKind.TypeAssertion: - case SyntaxKind.ParenExpression: + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.ParenthesizedExpression: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: - case SyntaxKind.PrefixOperator: - case SyntaxKind.PostfixOperator: + case SyntaxKind.VoidExpression: + case SyntaxKind.DeleteExpression: + case SyntaxKind.TypeOfExpression: + case SyntaxKind.PrefixUnaryExpression: + case SyntaxKind.PostfixUnaryExpression: case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.TemplateExpression: @@ -527,7 +538,10 @@ module ts { case SyntaxKind.OmittedExpression: return true; case SyntaxKind.QualifiedName: - while (node.parent.kind === SyntaxKind.QualifiedName) node = node.parent; + while (node.parent.kind === SyntaxKind.QualifiedName) { + node = node.parent; + } + return node.parent.kind === SyntaxKind.TypeQuery; case SyntaxKind.Identifier: if (node.parent.kind === SyntaxKind.TypeQuery) { @@ -562,8 +576,8 @@ module ts { case SyntaxKind.ForInStatement: return (parent).variable === node || (parent).expression === node; - case SyntaxKind.TypeAssertion: - return node === (parent).operand; + case SyntaxKind.TypeAssertionExpression: + return node === (parent).expression; case SyntaxKind.TemplateSpan: return node === (parent).expression; default: @@ -668,6 +682,33 @@ module ts { return false; } + export function getClassBaseTypeNode(node: ClassDeclaration) { + var heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + + export function getClassImplementedTypeNodes(node: ClassDeclaration) { + var heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ImplementsKeyword); + return heritageClause ? heritageClause.types : undefined; + } + + export function getInterfaceBaseTypeNodes(node: InterfaceDeclaration) { + var heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword); + return heritageClause ? heritageClause.types : undefined; + } + + export function getHeritageClause(clauses: NodeArray, kind: SyntaxKind) { + if (clauses) { + for (var i = 0, n = clauses.length; i < n; i++) { + if (clauses[i].token === kind) { + return clauses[i]; + } + } + } + + return undefined; + } + export function tryResolveScriptReference(program: Program, sourceFile: SourceFile, reference: FileReference) { if (!program.getCompilerOptions().noResolve) { var referenceFileName = isRootedDiskPath(reference.filename) ? reference.filename : combinePaths(getDirectoryPath(sourceFile.filename), reference.filename); @@ -728,6 +769,7 @@ module ts { TypeParameters, // Type parameters in type parameter list TypeArguments, // Type arguments in type argument list TupleElementTypes, // Element types in tuple element type list + HeritageClauses, // Heritage clauses for a class or interface declaration. Count // Number of parsing contexts } @@ -1142,12 +1184,18 @@ module ts { return inStrictModeContext() ? token > SyntaxKind.LastFutureReservedWord : token > SyntaxKind.LastReservedWord; } - function parseExpected(t: SyntaxKind): boolean { + function parseExpected(t: SyntaxKind, diagnosticMessage?: DiagnosticMessage): boolean { if (token === t) { nextToken(); return true; } - error(Diagnostics._0_expected, tokenToString(t)); + + if (diagnosticMessage) { + error(diagnosticMessage); + } + else { + error(Diagnostics._0_expected, tokenToString(t)); + } return false; } @@ -1343,6 +1391,8 @@ module ts { case ParsingContext.TypeArguments: case ParsingContext.TupleElementTypes: return token === SyntaxKind.CommaToken || isStartOfType(); + case ParsingContext.HeritageClauses: + return isHeritageClause(); } Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -1385,6 +1435,9 @@ module ts { case ParsingContext.TypeArguments: // Tokens other than '>' are here for better error recovery return token === SyntaxKind.GreaterThanToken || token === SyntaxKind.OpenParenToken; + case ParsingContext.HeritageClauses: + return token === SyntaxKind.OpenBraceToken || token === SyntaxKind.CloseBraceToken; + } } @@ -1536,19 +1589,63 @@ module ts { while (parseOptional(SyntaxKind.DotToken)) { var node = createNode(SyntaxKind.QualifiedName, entity.pos); node.left = entity; - node.right = allowReservedWords ? parseIdentifierName() : parseIdentifier(); + node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); } return entity; } - function parseTokenNode(): Node { - var node = createNode(token); + function parseRightSideOfDot(allowIdentifierNames: boolean): Identifier { + // Technically a keyword is valid here as all keywords are identifier names. + // However, often we'll encounter this in error situations when the keyword + // is actually starting another valid construct. + // + // So, we check for the following specific case: + // + // name. + // keyword identifierNameOrKeyword + // + // Note: the newlines are important here. For example, if that above code + // were rewritten into: + // + // name.keyword + // identifierNameOrKeyword + // + // Then we would consider it valid. That's because ASI would take effect and + // the code would be implicitly: "name.keyword; identifierNameOrKeyword". + // In the first case though, ASI will not take effect because there is not a + // line terminator after the keyword. + if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { + var matchesPattern = lookAhead(() => { + nextToken(); + return !scanner.hasPrecedingLineBreak() && (scanner.isIdentifier() || scanner.isReservedWord()); + }); + + if (matchesPattern) { + errorAtPos(scanner.getTokenPos(), 0, Diagnostics.Identifier_expected); + return createMissingNode(); + } + } + + return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); + } + + function parseTokenNode(): PrimaryExpression { + var node = createNode(token); nextToken(); return finishNode(node); } - function parseTemplateExpression() { + function parseExpectedTokenNode(kind: SyntaxKind): Node { + if (token === kind) { + return parseTokenNode(); + } + + parseExpected(kind); + return createMissingNode(); + } + + function parseTemplateExpression(): TemplateExpression { var template = createNode(SyntaxKind.TemplateExpression); template.head = parseLiteralNode(); @@ -1659,7 +1756,7 @@ module ts { // // // We do *not* want to consume the > as we're consuming the expression for "". - node.expression = parseUnaryExpression(); + node.expression = parseUnaryExpressionOrHigher(); } } @@ -1874,8 +1971,8 @@ module ts { }); } - function parseIndexSignatureMember(fullStart: number, modifiers: ModifiersArray): SignatureDeclaration { - var node = createNode(SyntaxKind.IndexSignature, fullStart); + function parseIndexSignatureDeclaration(fullStart: number, modifiers: ModifiersArray): IndexSignatureDeclaration { + var node = createNode(SyntaxKind.IndexSignature, fullStart); setModifiers(node, modifiers); node.parameters = parseBracketedList(ParsingContext.Parameters, parseParameter, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken); node.type = parseTypeAnnotation(); @@ -1932,7 +2029,7 @@ module ts { return parseSignatureMember(SyntaxKind.CallSignature, SyntaxKind.ColonToken); case SyntaxKind.OpenBracketToken: // Indexer or computed property - return isIndexSignature() ? parseIndexSignatureMember(scanner.getStartPos(), /*modifiers:*/ undefined) : parsePropertyOrMethod(); + return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*modifiers:*/ undefined) : parsePropertyOrMethod(); case SyntaxKind.NewKeyword: if (lookAhead(() => nextToken() === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken)) { return parseSignatureMember(SyntaxKind.ConstructSignature, SyntaxKind.ColonToken); @@ -1960,7 +2057,7 @@ module ts { parseExpected(SyntaxKind.CloseBraceToken); } else { - members = createMissingList(); + members = createMissingList(); } return members; @@ -1972,8 +2069,8 @@ module ts { return finishNode(node); } - function parseParenType(): ParenTypeNode { - var node = createNode(SyntaxKind.ParenType); + function parseParenType(): ParenthesizedTypeNode { + var node = createNode(SyntaxKind.ParenthesizedType); parseExpected(SyntaxKind.OpenParenToken); node.type = parseType(); parseExpected(SyntaxKind.CloseParenToken); @@ -2184,9 +2281,9 @@ module ts { // AssignmentExpression[in] // Expression[in] , AssignmentExpression[in] - var expr = parseAssignmentExpression(); + var expr = parseAssignmentExpressionOrHigher(); while (parseOptional(SyntaxKind.CommaToken)) { - expr = makeBinaryExpression(expr, SyntaxKind.CommaToken, parseAssignmentExpression()); + expr = makeBinaryExpression(expr, SyntaxKind.CommaToken, parseAssignmentExpressionOrHigher()); } return expr; } @@ -2212,10 +2309,10 @@ module ts { // = AssignmentExpression[?In, ?Yield] parseExpected(SyntaxKind.EqualsToken); - return parseAssignmentExpression(); + return parseAssignmentExpressionOrHigher(); } - function parseAssignmentExpression(): Expression { + function parseAssignmentExpressionOrHigher(): Expression { // AssignmentExpression[in,yield]: // 1) ConditionalExpression[?in,?yield] // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] @@ -2240,9 +2337,16 @@ module ts { return arrowExpression; } - // Now try to handle the rest of the cases. First, see if we can parse out up to and - // including a conditional expression. - var expr = parseConditionalExpression(); + // Now try to see if we're in production '1', '2' or '3'. A conditional expression can + // start with a LogicalOrExpression, while the assignment productions can only start with + // LeftHandSideExpressions. + // + // So, first, we try to just parse out a BinaryExpression. If we get something that is a + // LeftHandSide or higher, then we can try to parse out the assignment expression part. + // Otherwise, we try to parse out the conditional expression bit. We want to allow any + // binary expression here, so we pass in the 'lowest' precedence here so that it matches + // and consumes anything. + var expr = parseBinaryExpressionOrHigher(/*precedence:*/ 0); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single @@ -2254,14 +2358,17 @@ module ts { // Now see if we might be in cases '2' or '3'. // If the expression was a LHS expression, and we have an assignment operator, then // we're in '2' or '3'. Consume the assignment and return. - if (isLeftHandSideExpression(expr) && isAssignmentOperator(token)) { + // + // Note: we call reScanGreaterToken so that we get an appropriately merged token + // for cases like > > = becoming >>= + if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) { var operator = token; nextToken(); - return makeBinaryExpression(expr, operator, parseAssignmentExpression()); + return makeBinaryExpression(expr, operator, parseAssignmentExpressionOrHigher()); } - // otherwise this was production '1'. Return whatever we parsed so far. - return expr; + // It wasn't an assignment or a lambda. This is a conditional expression: + return parseConditionalExpressionRest(expr); } function isYieldExpression(): boolean { @@ -2313,7 +2420,7 @@ module ts { if (!scanner.hasPrecedingLineBreak() && (token === SyntaxKind.AsteriskToken || isStartOfExpression())) { node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); - node.expression = parseAssignmentExpression(); + node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } else { @@ -2362,7 +2469,7 @@ module ts { } else { // If not, we're probably better off bailing out and returning a bogus function expression. - return makeFunctionExpression(SyntaxKind.ArrowFunction, pos, /*asteriskToken:*/ undefined, /*name:*/ undefined, sig, createMissingNode()); + return makeFunctionExpression(SyntaxKind.ArrowFunction, pos, /*asteriskToken:*/ undefined, /*name:*/ undefined, sig, createMissingNode()); } } @@ -2476,7 +2583,7 @@ module ts { } function parseArrowExpressionTail(pos: number, sig: ParsedSignature): FunctionExpression { - var body: Node; + var body: Block | Expression; if (token === SyntaxKind.OpenBraceToken) { body = parseFunctionBlock(/*allowYield:*/ false, /* ignoreMissingOpenBrace */ false); @@ -2499,40 +2606,56 @@ module ts { body = parseFunctionBlock(/*allowYield:*/ false, /* ignoreMissingOpenBrace */ true); } else { - body = parseAssignmentExpression(); + body = parseAssignmentExpressionOrHigher(); } return makeFunctionExpression(SyntaxKind.ArrowFunction, pos, /*asteriskToken:*/ undefined, /*name:*/ undefined, sig, body); } - function parseConditionalExpression(): Expression { + function parseConditionalExpressionRest(leftOperand: Expression): Expression { + // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. + if (!parseOptional(SyntaxKind.QuestionToken)) { + return leftOperand; + } + // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - - var expr = parseBinaryOperators(parseUnaryExpression(), /*minPrecedence:*/ 0); - while (parseOptional(SyntaxKind.QuestionToken)) { - var node = createNode(SyntaxKind.ConditionalExpression, expr.pos); - node.condition = expr; - node.whenTrue = allowInAnd(parseAssignmentExpression); - parseExpected(SyntaxKind.ColonToken); - node.whenFalse = parseAssignmentExpression(); - expr = finishNode(node); - } - return expr; + var node = createNode(SyntaxKind.ConditionalExpression, leftOperand.pos); + node.condition = leftOperand; + node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(SyntaxKind.ColonToken); + node.whenFalse = parseAssignmentExpressionOrHigher(); + return finishNode(node); } - function parseBinaryOperators(expr: Expression, minPrecedence: number): Expression { + function parseBinaryExpressionOrHigher(precedence: number): Expression { + var leftOperand = parseUnaryExpressionOrHigher(); + return parseBinaryExpressionRest(precedence, leftOperand); + } + + function parseBinaryExpressionRest(precedence: number, leftOperand: Expression): Expression { while (true) { + // We either have a binary operator here, or we're finished. We call + // reScanGreaterToken so that we merge token sequences like > and = into >= + reScanGreaterToken(); - var precedence = getOperatorPrecedence(); - if (precedence && precedence > minPrecedence && (!inDisallowInContext() || token !== SyntaxKind.InKeyword)) { - var operator = token; - nextToken(); - expr = makeBinaryExpression(expr, operator, parseBinaryOperators(parseUnaryExpression(), precedence)); - continue; + var newPrecedence = getOperatorPrecedence(); + + // Check the precedence to see if we should "take" this operator + if (newPrecedence <= precedence) { + break; } - return expr; + + if (token === SyntaxKind.InKeyword && inDisallowInContext()) { + break; + } + + var operator = token; + nextToken(); + leftOperand = makeBinaryExpression(leftOperand, operator, parseBinaryExpressionOrHigher(newPrecedence)); } + + return leftOperand; } function getOperatorPrecedence(): number { @@ -2571,7 +2694,10 @@ module ts { case SyntaxKind.PercentToken: return 10; } - return undefined; + + // -1 is lower than all other precedences. Returning it will cause binary expression + // parsing to stop. + return -1; } function makeBinaryExpression(left: Expression, operator: SyntaxKind, right: Expression): BinaryExpression { @@ -2582,159 +2708,271 @@ module ts { return finishNode(node); } - function parseUnaryExpression(): Expression { - var pos = getNodePos(); + function parsePrefixUnaryExpression() { + var node = createNode(SyntaxKind.PrefixUnaryExpression); + var operator = token; + nextToken(); + node.operator = operator; + node.operand = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + + function parseDeleteExpression() { + var node = createNode(SyntaxKind.DeleteExpression); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + + function parseTypeOfExpression() { + var node = createNode(SyntaxKind.TypeOfExpression); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + + function parseVoidExpression() { + var node = createNode(SyntaxKind.VoidExpression); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + + function parseUnaryExpressionOrHigher(): UnaryExpression { switch (token) { case SyntaxKind.PlusToken: case SyntaxKind.MinusToken: case SyntaxKind.TildeToken: case SyntaxKind.ExclamationToken: - case SyntaxKind.DeleteKeyword: - case SyntaxKind.TypeOfKeyword: - case SyntaxKind.VoidKeyword: case SyntaxKind.PlusPlusToken: case SyntaxKind.MinusMinusToken: - var operator = token; - nextToken(); - return makeUnaryExpression(SyntaxKind.PrefixOperator, pos, operator, parseUnaryExpression()); + return parsePrefixUnaryExpression(); + case SyntaxKind.DeleteKeyword: + return parseDeleteExpression(); + case SyntaxKind.TypeOfKeyword: + return parseTypeOfExpression(); + case SyntaxKind.VoidKeyword: + return parseVoidExpression(); case SyntaxKind.LessThanToken: return parseTypeAssertion(); + default: + return parsePostfixExpressionOrHigher(); } + } - var primaryExpression = parsePrimaryExpression(); - // TS 1.0 spec (2014): 4.8 - // CallExpression: ( Modified ) - // super ( ArgumentListopt ) - // super . IdentifierName - var illegalUsageOfSuperKeyword = - primaryExpression.kind === SyntaxKind.SuperKeyword && token !== SyntaxKind.OpenParenToken && token !== SyntaxKind.DotToken; + function parsePostfixExpressionOrHigher(): PostfixExpression { + var expression = parseLeftHandSideExpressionOrHigher(); - if (illegalUsageOfSuperKeyword) { - error(Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - } - - var expr = parseCallAndAccess(primaryExpression, /* inNewExpression */ false); - - Debug.assert(isLeftHandSideExpression(expr)); + Debug.assert(isLeftHandSideExpression(expression)); if ((token === SyntaxKind.PlusPlusToken || token === SyntaxKind.MinusMinusToken) && !scanner.hasPrecedingLineBreak()) { - var operator = token; + var node = createNode(SyntaxKind.PostfixUnaryExpression, expression.pos); + node.operand = expression; + node.operator = token; nextToken(); - expr = makeUnaryExpression(SyntaxKind.PostfixOperator, expr.pos, operator, expr); + return finishNode(node); } - return expr; + return expression; + } + + function parseLeftHandSideExpressionOrHigher(): LeftHandSideExpression { + // Original Ecma: + // LeftHandSideExpression: See 11.2 + // NewExpression + // CallExpression + // + // Our simplification: + // + // LeftHandSideExpression: See 11.2 + // MemberExpression + // CallExpression + // + // See comment in parseMemberExpressionOrHigher on how we replaced NewExpression with + // MemberExpression to make our lives easier. + // + // to best understand the below code, it's important to see how CallExpression expands + // out into its own productions: + // + // CallExpression: + // MemberExpression Arguments + // CallExpression Arguments + // CallExpression[Expression] + // CallExpression.IdentifierName + // super ( ArgumentListopt ) + // super.IdentifierName + // + // Because of the recursion in these calls, we need to bottom out first. There are two + // bottom out states we can run into. Either we see 'super' which must start either of + // the last two CallExpression productions. Or we have a MemberExpression which either + // completes the LeftHandSideExpression, or starts the beginning of the first four + // CallExpression productions. + var expression: MemberExpression; + if (token === SyntaxKind.SuperKeyword) { + expression = parseSuperExpression(); + } + else { + expression = parseMemberExpressionOrHigher(); + } + + // Now, we *may* be complete. However, we might have consumed the start of a + // CallExpression. As such, we need to consume the rest of it here to be complete. + return parseCallExpressionRest(expression); + } + + function parseMemberExpressionOrHigher(): MemberExpression { + // Note: to make our lives simpler, we decompose the the NewExpression productions and + // place ObjectCreationExpression and FunctionExpression into PrimaryExpression. + // like so: + // + // PrimaryExpression : See 11.1 + // this + // Identifier + // Literal + // ArrayLiteral + // ObjectLiteral + // (Expression) + // FunctionExpression + // new MemberExpression Arguments? + // + // MemberExpression : See 11.2 + // PrimaryExpression + // MemberExpression[Expression] + // MemberExpression.IdentifierName + // + // CallExpression : See 11.2 + // MemberExpression + // CallExpression Arguments + // CallExpression[Expression] + // CallExpression.IdentifierName + // + // Technically this is ambiguous. i.e. CallExpression defines: + // + // CallExpression: + // CallExpression Arguments + // + // If you see: "new Foo()" + // + // Then that could be treated as a single ObjectCreationExpression, or it could be + // treated as the invocation of "new Foo". We disambiguate that in code (to match + // the original grammar) by making sure that if we see an ObjectCreationExpression + // we always consume arguments if they are there. So we treat "new Foo()" as an + // object creation only, and not at all as an invocation) Another way to think + // about this is that for every "new" that we see, we will consume an argument list if + // it is there as part of the *associated* object creation node. Any additional + // argument lists we see, will become invocation expressions. + // + // Because there are no other places in the grammar now that refer to FunctionExpression + // or ObjectCreationExpression, it is safe to push down into the PrimaryExpression + // production. + // + // Because CallExpression and MemberExpression are left recursive, we need to bottom out + // of the recursion immediately. So we parse out a primary expression to start with. + var expression = parsePrimaryExpression(); + return parseMemberExpressionRest(expression); + } + + function parseSuperExpression(): MemberExpression { + var expression = parseTokenNode(); + if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.DotToken) { + return expression; + } + + // If we have seen "super" it must be followed by '(' or '.'. + // If it wasn't then just try to parse out a '.' and report an error. + var node = createNode(SyntaxKind.PropertyAccessExpression, expression.pos); + node.expression = expression; + parseExpected(SyntaxKind.DotToken, Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(/*allowIdentifierNames:*/ true); + return finishNode(node); } function parseTypeAssertion(): TypeAssertion { - var node = createNode(SyntaxKind.TypeAssertion); + var node = createNode(SyntaxKind.TypeAssertionExpression); parseExpected(SyntaxKind.LessThanToken); node.type = parseType(); parseExpected(SyntaxKind.GreaterThanToken); - node.operand = parseUnaryExpression(); + node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } - function makeUnaryExpression(kind: SyntaxKind, pos: number, operator: SyntaxKind, operand: Expression): UnaryExpression { - var node = createNode(kind, pos); - node.operator = operator; - node.operand = operand; - return finishNode(node); - } - - function parseCallAndAccess(expr: Expression, inNewExpression: boolean): Expression { + function parseMemberExpressionRest(expression: LeftHandSideExpression): MemberExpression { while (true) { var dotOrBracketStart = scanner.getTokenPos(); if (parseOptional(SyntaxKind.DotToken)) { - var propertyAccess = createNode(SyntaxKind.PropertyAccess, expr.pos); - // Technically a keyword is valid here as all keywords are identifier names. - // However, often we'll encounter this in error situations when the keyword - // is actually starting another valid construct. - // - // So, we check for the following specific case: - // - // name. - // keyword identifierNameOrKeyword - // - // Note: the newlines are important here. For example, if that above code - // were rewritten into: - // - // name.keyword - // identifierNameOrKeyword - // - // Then we would consider it valid. That's because ASI would take effect and - // the code would be implicitly: "name.keyword; identifierNameOrKeyword". - // In the first case though, ASI will not take effect because there is not a - // line terminator after the keyword. - var id: Identifier; - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { - var matchesPattern = lookAhead(() => { - nextToken(); - return !scanner.hasPrecedingLineBreak() && (scanner.isIdentifier() || scanner.isReservedWord); - }); - - if (matchesPattern) { - errorAtPos(dotOrBracketStart + 1, 0, Diagnostics.Identifier_expected); - id = createMissingNode(); - } - } - - propertyAccess.left = expr; - propertyAccess.right = id || parseIdentifierName(); - expr = finishNode(propertyAccess); + var propertyAccess = createNode(SyntaxKind.PropertyAccessExpression, expression.pos); + propertyAccess.expression = expression; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames:*/ true); + expression = finishNode(propertyAccess); continue; } if (parseOptional(SyntaxKind.OpenBracketToken)) { - var indexedAccess = createNode(SyntaxKind.IndexedAccess, expr.pos); - indexedAccess.object = expr; + var indexedAccess = createNode(SyntaxKind.ElementAccessExpression, expression.pos); + indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. - if (inNewExpression && parseOptional(SyntaxKind.CloseBracketToken)) { - indexedAccess.index = createMissingNode(); - } - else { - indexedAccess.index = allowInAnd(parseExpression); - if (indexedAccess.index.kind === SyntaxKind.StringLiteral || indexedAccess.index.kind === SyntaxKind.NumericLiteral) { - var literal = indexedAccess.index; + if (token !== SyntaxKind.CloseBracketToken) { + indexedAccess.argumentExpression = allowInAnd(parseExpression); + if (indexedAccess.argumentExpression.kind === SyntaxKind.StringLiteral || indexedAccess.argumentExpression.kind === SyntaxKind.NumericLiteral) { + var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } - parseExpected(SyntaxKind.CloseBracketToken); - } - - expr = finishNode(indexedAccess); - continue; - } - - // Try to parse a Call Expression unless we are in a New Expression. - // If we are parsing a New Expression, then parentheses are optional, - // and is taken care of by the 'parseNewExpression' caller. - if ((token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) && !inNewExpression) { - var callExpr = createNode(SyntaxKind.CallExpression, expr.pos); - callExpr.func = expr; - if (token === SyntaxKind.LessThanToken) { - if (!(callExpr.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) return expr; } else { - parseExpected(SyntaxKind.OpenParenToken); + indexedAccess.argumentExpression = createMissingNode(); } - callExpr.arguments = parseDelimitedList(ParsingContext.ArgumentExpressions, parseArgumentExpression); - parseExpected(SyntaxKind.CloseParenToken); - expr = finishNode(callExpr); + + parseExpected(SyntaxKind.CloseBracketToken); + expression = finishNode(indexedAccess); continue; } if (token === SyntaxKind.NoSubstitutionTemplateLiteral || token === SyntaxKind.TemplateHead) { - var tagExpression = createNode(SyntaxKind.TaggedTemplateExpression, expr.pos); - tagExpression.tag = expr; + var tagExpression = createNode(SyntaxKind.TaggedTemplateExpression, expression.pos); + tagExpression.tag = expression; tagExpression.template = token === SyntaxKind.NoSubstitutionTemplateLiteral ? parseLiteralNode() : parseTemplateExpression(); - expr = finishNode(tagExpression); + expression = finishNode(tagExpression); continue; } - return expr; + return expression; + } + } + + function parseCallExpressionRest(expression: LeftHandSideExpression): LeftHandSideExpression { + while (true) { + expression = parseMemberExpressionRest(expression); + + if (token === SyntaxKind.LessThanToken) { + // Might be arithmetic, or it might be a type argument list. + var typeArguments = tryParse(parseTypeArgumentsAndOpenParen); + if (!typeArguments) { + return expression; + } + + var callExpr = createNode(SyntaxKind.CallExpression, expression.pos); + callExpr.expression = expression; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseDelimitedList(ParsingContext.ArgumentExpressions, parseArgumentExpression); + parseExpected(SyntaxKind.CloseParenToken); + expression = finishNode(callExpr); + continue; + } + + if (token === SyntaxKind.OpenParenToken) { + var callExpr = createNode(SyntaxKind.CallExpression, expression.pos); + callExpr.expression = expression; + parseExpected(SyntaxKind.OpenParenToken); + callExpr.arguments = parseDelimitedList(ParsingContext.ArgumentExpressions, parseArgumentExpression); + parseExpected(SyntaxKind.CloseParenToken); + expression = finishNode(callExpr); + continue; + } + + return expression; } } @@ -2765,7 +3003,7 @@ module ts { return parseType(); } - function parsePrimaryExpression(): Expression { + function parsePrimaryExpression(): PrimaryExpression { switch (token) { case SyntaxKind.ThisKeyword: case SyntaxKind.SuperKeyword: @@ -2778,11 +3016,11 @@ module ts { case SyntaxKind.NoSubstitutionTemplateLiteral: return parseLiteralNode(); case SyntaxKind.OpenParenToken: - return parseParenExpression(); + return parseParenthesizedExpression(); case SyntaxKind.OpenBracketToken: - return parseArrayLiteral(); + return parseArrayLiteralExpression(); case SyntaxKind.OpenBraceToken: - return parseObjectLiteral(); + return parseObjectLiteralExpression(); case SyntaxKind.FunctionKeyword: return parseFunctionExpression(); case SyntaxKind.NewKeyword: @@ -2802,11 +3040,11 @@ module ts { } } error(Diagnostics.Expression_expected); - return createMissingNode(); + return createMissingNode(); } - function parseParenExpression(): ParenExpression { - var node = createNode(SyntaxKind.ParenExpression); + function parseParenthesizedExpression(): ParenthesizedExpression { + var node = createNode(SyntaxKind.ParenthesizedExpression); parseExpected(SyntaxKind.OpenParenToken); node.expression = allowInAnd(parseExpression); parseExpected(SyntaxKind.CloseParenToken); @@ -2815,8 +3053,8 @@ module ts { function parseAssignmentExpressionOrOmittedExpression(): Expression { return token === SyntaxKind.CommaToken - ? createNode(SyntaxKind.OmittedExpression) - : parseAssignmentExpression(); + ? createNode(SyntaxKind.OmittedExpression) + : parseAssignmentExpressionOrHigher(); } function parseArrayLiteralElement(): Expression { @@ -2827,8 +3065,8 @@ module ts { return allowInAnd(parseAssignmentExpressionOrOmittedExpression); } - function parseArrayLiteral(): ArrayLiteral { - var node = createNode(SyntaxKind.ArrayLiteral); + function parseArrayLiteralExpression(): ArrayLiteralExpression { + var node = createNode(SyntaxKind.ArrayLiteralExpression); parseExpected(SyntaxKind.OpenBracketToken); if (scanner.hasPrecedingLineBreak()) node.flags |= NodeFlags.MultiLine; node.elements = parseDelimitedList(ParsingContext.ArrayLiteralMembers, parseArrayLiteralElement); @@ -2875,14 +3113,14 @@ module ts { node = createNode(SyntaxKind.PropertyAssignment, nodePos); node.name = propertyName; parseExpected(SyntaxKind.ColonToken); - (node).initializer = allowInAnd(parseAssignmentExpression); + (node).initializer = allowInAnd(parseAssignmentExpressionOrHigher); } node.flags = flags; return finishNode(node); } - function parseObjectLiteralMember(): Node { + function parseObjectLiteralMember(): Declaration { var initialPos = getNodePos(); var initialToken = token; if (parseContextualModifier(SyntaxKind.GetKeyword) || parseContextualModifier(SyntaxKind.SetKeyword)) { @@ -2892,8 +3130,8 @@ module ts { return parsePropertyAssignment(); } - function parseObjectLiteral(): ObjectLiteral { - var node = createNode(SyntaxKind.ObjectLiteral); + function parseObjectLiteralExpression(): ObjectLiteralExpression { + var node = createNode(SyntaxKind.ObjectLiteralExpression); parseExpected(SyntaxKind.OpenBraceToken); if (scanner.hasPrecedingLineBreak()) { node.flags |= NodeFlags.MultiLine; @@ -2924,7 +3162,7 @@ module ts { return isIdentifier() ? parseIdentifier() : undefined; } - function makeFunctionExpression(kind: SyntaxKind, pos: number, asteriskToken: Node, name: Identifier, sig: ParsedSignature, body: Node): FunctionExpression { + function makeFunctionExpression(kind: SyntaxKind, pos: number, asteriskToken: Node, name: Identifier, sig: ParsedSignature, body: Block | Expression): FunctionExpression { var node = createNode(kind, pos); node.asteriskToken = asteriskToken; node.name = name; @@ -2938,8 +3176,8 @@ module ts { function parseNewExpression(): NewExpression { var node = createNode(SyntaxKind.NewExpression); parseExpected(SyntaxKind.NewKeyword); - node.func = parseCallAndAccess(parsePrimaryExpression(), /* inNewExpression */ true); - if (parseOptional(SyntaxKind.OpenParenToken) || token === SyntaxKind.LessThanToken && (node.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) { + node.expression = parseMemberExpressionOrHigher(); + if (parseOptional(SyntaxKind.OpenParenToken) || (token === SyntaxKind.LessThanToken && (node.typeArguments = tryParse(parseTypeArgumentsAndOpenParen)))) { node.arguments = parseDelimitedList(ParsingContext.ArgumentExpressions, parseArgumentExpression); parseExpected(SyntaxKind.CloseParenToken); } @@ -2991,9 +3229,7 @@ module ts { function parseDoStatement(): DoStatement { var node = createNode(SyntaxKind.DoStatement); parseExpected(SyntaxKind.DoKeyword); - node.statement = parseStatement(); - parseExpected(SyntaxKind.WhileKeyword); parseExpected(SyntaxKind.OpenParenToken); node.expression = allowInAnd(parseExpression); @@ -3013,9 +3249,7 @@ module ts { parseExpected(SyntaxKind.OpenParenToken); node.expression = allowInAnd(parseExpression); parseExpected(SyntaxKind.CloseParenToken); - node.statement = parseStatement(); - return finishNode(node); } @@ -3389,8 +3623,8 @@ module ts { return finishNode(node); } - function parseFunctionDeclaration(fullStart: number, modifiers: ModifiersArray): FunctionLikeDeclaration { - var node = createNode(SyntaxKind.FunctionDeclaration, fullStart); + function parseFunctionDeclaration(fullStart: number, modifiers: ModifiersArray): FunctionDeclaration { + var node = createNode(SyntaxKind.FunctionDeclaration, fullStart); setModifiers(node, modifiers); parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); @@ -3409,7 +3643,7 @@ module ts { return finishNode(node); } - function parsePropertyMemberDeclaration(fullStart: number, modifiers: ModifiersArray): Declaration { + function parsePropertyMemberDeclaration(fullStart: number, modifiers: ModifiersArray): ClassElement { var flags = modifiers ? modifiers.flags : 0; var asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); var name = parsePropertyName(); @@ -3531,7 +3765,7 @@ module ts { return modifiers; } - function parseClassMemberDeclaration(): Declaration { + function parseClassElement(): ClassElement { var fullStart = getNodePos(); var modifiers = parseModifiers(); if (parseContextualModifier(SyntaxKind.GetKeyword)) { @@ -3544,7 +3778,7 @@ module ts { return parseConstructorDeclaration(fullStart, modifiers); } if (isIndexSignature()) { - return parseIndexSignatureMember(fullStart, modifiers); + return parseIndexSignatureDeclaration(fullStart, modifiers); } // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name @@ -3563,20 +3797,8 @@ module ts { parseExpected(SyntaxKind.ClassKeyword); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause:*/ true); - // TODO(jfreeman): Parse arbitrary sequence of heritage clauses and error for order and duplicates - - // ClassTail[Yield,GeneratorParameter] : See 14.5 - // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } - // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } - - node.baseType = inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseClassBaseType) - : parseClassBaseType(); - - if (parseOptional(SyntaxKind.ImplementsKeyword)) { - node.implementedTypes = parseDelimitedList(ParsingContext.BaseTypeReferences, parseTypeReference); - } if (parseExpected(SyntaxKind.OpenBraceToken)) { // ClassTail[Yield,GeneratorParameter] : See 14.5 // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } @@ -3588,13 +3810,47 @@ module ts { parseExpected(SyntaxKind.CloseBraceToken); } else { - node.members = createMissingList(); + node.members = createMissingList(); } return finishNode(node); } + function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray { + // ClassTail[Yield,GeneratorParameter] : See 14.5 + // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } + // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } + + if (isHeritageClause()) { + return isClassHeritageClause && inGeneratorParameterContext() + ? doOutsideOfYieldContext(parseHeritageClausesWorker) + : parseHeritageClausesWorker(); + } + + return undefined; + } + + function parseHeritageClausesWorker() { + return parseList(ParsingContext.HeritageClauses, /*checkForStrictMode:*/ false, parseHeritageClause); + } + + function parseHeritageClause() { + if (token === SyntaxKind.ExtendsKeyword || token === SyntaxKind.ImplementsKeyword) { + var node = createNode(SyntaxKind.HeritageClause); + node.token = token; + nextToken(); + node.types = parseDelimitedList(ParsingContext.BaseTypeReferences, parseTypeReference); + return finishNode(node); + } + + return undefined; + } + + function isHeritageClause(): boolean { + return token === SyntaxKind.ExtendsKeyword || token === SyntaxKind.ImplementsKeyword; + } + function parseClassMembers() { - return parseList(ParsingContext.ClassMembers, /*checkForStrictMode*/ false, parseClassMemberDeclaration); + return parseList(ParsingContext.ClassMembers, /*checkForStrictMode*/ false, parseClassElement); } function parseClassBaseType(): TypeReferenceNode { @@ -3607,10 +3863,7 @@ module ts { parseExpected(SyntaxKind.InterfaceKeyword); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - // TODO(jfreeman): Parse arbitrary sequence of heritage clauses and error for order and duplicates - if (parseOptional(SyntaxKind.ExtendsKeyword)) { - node.baseTypes = parseDelimitedList(ParsingContext.BaseTypeReferences, parseTypeReference); - } + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause:*/ false); node.members = parseObjectType(); return finishNode(node); } @@ -3655,8 +3908,8 @@ module ts { return finishNode(node); } - function parseModuleBody(): Block { - var node = createNode(SyntaxKind.ModuleBlock, scanner.getStartPos()); + function parseModuleBlock(): ModuleBlock { + var node = createNode(SyntaxKind.ModuleBlock, scanner.getStartPos()); if (parseExpected(SyntaxKind.OpenBraceToken)) { node.statements = parseList(ParsingContext.ModuleElements, /*checkForStrictMode*/ false, parseModuleElement); parseExpected(SyntaxKind.CloseBraceToken); @@ -3673,7 +3926,7 @@ module ts { node.name = parseIdentifier(); node.body = parseOptional(SyntaxKind.DotToken) ? parseInternalModuleTail(getNodePos(), NodeFlags.Export) - : parseModuleBody(); + : parseModuleBlock(); return finishNode(node); } @@ -3681,7 +3934,7 @@ module ts { var node = createNode(SyntaxKind.ModuleDeclaration, fullStart); node.flags = flags; node.name = parseStringLiteral(); - node.body = parseModuleBody(); + node.body = parseModuleBlock(); return finishNode(node); } @@ -3748,7 +4001,7 @@ module ts { } } - function parseDeclaration(): Statement { + function parseDeclaration(): ModuleElement { var fullStart = getNodePos(); var modifiers = parseModifiers(); if (token === SyntaxKind.ExportKeyword) { @@ -3759,7 +4012,7 @@ module ts { } var flags = modifiers ? modifiers.flags : 0; - var result: Declaration; + var result: ModuleElement; switch (token) { case SyntaxKind.VarKeyword: case SyntaxKind.LetKeyword: @@ -3818,7 +4071,7 @@ module ts { return parseSourceElementOrModuleElement(); } - function parseSourceElementOrModuleElement(): Statement { + function parseSourceElementOrModuleElement(): ModuleElement { return isDeclarationStart() ? parseDeclaration() : parseStatement(); @@ -3934,14 +4187,14 @@ module ts { function isLeftHandSideExpression(expr: Expression): boolean { if (expr) { switch (expr.kind) { - case SyntaxKind.PropertyAccess: - case SyntaxKind.IndexedAccess: + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ElementAccessExpression: case SyntaxKind.NewExpression: case SyntaxKind.CallExpression: case SyntaxKind.TaggedTemplateExpression: - case SyntaxKind.ArrayLiteral: - case SyntaxKind.ParenExpression: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.ParenthesizedExpression: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.FunctionExpression: case SyntaxKind.Identifier: case SyntaxKind.Missing: @@ -4044,23 +4297,25 @@ module ts { case SyntaxKind.ClassDeclaration: return checkClassDeclaration(node); case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(node); case SyntaxKind.Constructor: return checkConstructor(node); + case SyntaxKind.DeleteExpression: return checkDeleteExpression( node); + case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(node); case SyntaxKind.ExportAssignment: return checkExportAssignment(node); case SyntaxKind.ForInStatement: return checkForInStatement(node); case SyntaxKind.ForStatement: return checkForStatement(node); case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); case SyntaxKind.FunctionExpression: return checkFunctionExpression(node); case SyntaxKind.GetAccessor: return checkGetAccessor(node); - case SyntaxKind.IndexedAccess: return checkIndexedAccess(node); + case SyntaxKind.HeritageClause: return checkHeritageClause(node); case SyntaxKind.IndexSignature: return checkIndexSignature(node); case SyntaxKind.InterfaceDeclaration: return checkInterfaceDeclaration(node); case SyntaxKind.LabeledStatement: return checkLabeledStatement(node); case SyntaxKind.Method: return checkMethod(node); case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(node); - case SyntaxKind.ObjectLiteral: return checkObjectLiteral(node); + case SyntaxKind.ObjectLiteralExpression: return checkObjectLiteralExpression(node); case SyntaxKind.NumericLiteral: return checkNumericLiteral(node); case SyntaxKind.Parameter: return checkParameter(node); - case SyntaxKind.PostfixOperator: return checkPostfixOperator(node); - case SyntaxKind.PrefixOperator: return checkPrefixOperator(node); + case SyntaxKind.PostfixUnaryExpression: return checkPostfixUnaryExpression(node); + case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(node); case SyntaxKind.Property: return checkProperty(node); case SyntaxKind.PropertyAssignment: return checkPropertyAssignment(node); case SyntaxKind.ReturnStatement: return checkReturnStatement(node); @@ -4177,7 +4432,7 @@ module ts { } function checkBreakOrContinueStatement(node: BreakOrContinueStatement): boolean { - var current = node; + var current: Node = node; while (current) { if (isAnyFunction(current)) { return grammarErrorOnNode(node, Diagnostics.Jump_target_cannot_cross_function_boundary); @@ -4297,8 +4552,45 @@ module ts { } function checkClassDeclaration(node: ClassDeclaration) { - return checkForDisallowedTrailingComma(node.implementedTypes) || - checkForAtLeastOneHeritageClause(node.implementedTypes, "implements"); + return checkClassDeclarationHeritageClauses(node); + } + + function checkClassDeclarationHeritageClauses(node: ClassDeclaration): boolean { + var seenExtendsClause = false; + var seenImplementsClause = false; + + if (node.heritageClauses) { + for (var i = 0, n = node.heritageClauses.length; i < n; i++) { + Debug.assert(i <= 2); + var heritageClause = node.heritageClauses[i]; + + if (heritageClause.token === SyntaxKind.ExtendsKeyword) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen); + } + + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_must_precede_implements_clause); + } + + if (heritageClause.types.length > 1) { + return grammarErrorOnFirstToken(heritageClause.types[1], Diagnostics.Classes_can_only_extend_a_single_class); + } + + seenExtendsClause = true; + } + else { + Debug.assert(heritageClause.token === SyntaxKind.ImplementsKeyword); + if (seenImplementsClause) { + return grammarErrorOnFirstToken(heritageClause, Diagnostics.implements_clause_already_seen); + } + + seenImplementsClause = true; + } + } + } + + return false; } function checkForAtLeastOneHeritageClause(types: NodeArray, listType: string): boolean { @@ -4326,6 +4618,14 @@ module ts { } } + function checkDeleteExpression(node: DeleteExpression) { + if (node.parserContextFlags & ParserContextFlags.StrictMode && node.expression.kind === SyntaxKind.Identifier) { + // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its + // UnaryExpression is a direct reference to a variable, function argument, or function name + return grammarErrorOnNode(node.expression, Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); + } + } + function checkEnumDeclaration(enumDecl: EnumDeclaration): boolean { var enumIsConst = (enumDecl.flags & NodeFlags.Const) !== 0; @@ -4367,8 +4667,8 @@ module ts { return /^[0-9]+([eE]\+?[0-9]+)?$/.test(literalExpression.text); } - if (expression.kind === SyntaxKind.PrefixOperator) { - var unaryExpression = expression; + if (expression.kind === SyntaxKind.PrefixUnaryExpression) { + var unaryExpression = expression; if (unaryExpression.operator === SyntaxKind.PlusToken || unaryExpression.operator === SyntaxKind.MinusToken) { expression = unaryExpression.operand; } @@ -4433,17 +4733,26 @@ module ts { checkAccessor(node); } - function checkIndexedAccess(node: IndexedAccess) { - if (node.index.kind === SyntaxKind.Missing && - node.parent.kind === SyntaxKind.NewExpression && - (node.parent).func === node) { - - var start = skipTrivia(sourceText, node.parent.pos); - var end = node.end; - return grammarErrorAtPos(start, end - start, Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + function checkElementAccessExpression(node: ElementAccessExpression) { + if (node.argumentExpression.kind === SyntaxKind.Missing) { + if (node.parent.kind === SyntaxKind.NewExpression && (node.parent).expression === node) { + var start = skipTrivia(sourceText, node.expression.end); + var end = node.end; + return grammarErrorAtPos(start, end - start, Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + } + else { + var start = node.end - "]".length; + var end = node.end; + return grammarErrorAtPos(start, end - start, Diagnostics.Expression_expected); + } } } + function checkHeritageClause(node: HeritageClause): boolean { + return checkForDisallowedTrailingComma(node.types) || + checkForAtLeastOneHeritageClause(node.types, tokenToString(node.token)); + } + function checkIndexSignature(node: SignatureDeclaration): boolean { return checkIndexSignatureParameters(node) || checkForIndexSignatureModifiers(node); @@ -4489,8 +4798,32 @@ module ts { } function checkInterfaceDeclaration(node: InterfaceDeclaration) { - return checkForDisallowedTrailingComma(node.baseTypes) || - checkForAtLeastOneHeritageClause(node.baseTypes, "extends"); + return checkInterfaceDeclarationHeritageClauses(node); + } + + function checkInterfaceDeclarationHeritageClauses(node: InterfaceDeclaration): boolean { + var seenExtendsClause = false; + + if (node.heritageClauses) { + for (var i = 0, n = node.heritageClauses.length; i < n; i++) { + Debug.assert(i <= 1); + var heritageClause = node.heritageClauses[i]; + + if (heritageClause.token === SyntaxKind.ExtendsKeyword) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen); + } + + seenExtendsClause = true; + } + else { + Debug.assert(heritageClause.token === SyntaxKind.ImplementsKeyword); + return grammarErrorOnFirstToken(heritageClause, Diagnostics.Interface_declaration_cannot_have_implements_clause); + } + } + } + + return false; } function checkMethod(node: MethodDeclaration) { @@ -4545,7 +4878,7 @@ module ts { function checkModuleDeclarationStatements(node: ModuleDeclaration): boolean { if (node.name.kind === SyntaxKind.Identifier && node.body.kind === SyntaxKind.ModuleBlock) { - var statements = (node.body).statements; + var statements = (node.body).statements; for (var i = 0, n = statements.length; i < n; i++) { var statement = statements[i]; @@ -4560,7 +4893,7 @@ module ts { } } - function checkObjectLiteral(node: ObjectLiteral): boolean { + function checkObjectLiteralExpression(node: ObjectLiteralExpression): boolean { var seen: Map = {}; var Property = 1; var GetAccessor = 2; @@ -4826,7 +5159,7 @@ module ts { } } - function checkPostfixOperator(node: UnaryExpression) { + function checkPostfixUnaryExpression(node: PostfixUnaryExpression) { // The identifier eval or arguments may not appear as the LeftHandSideExpression of an // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. @@ -4835,7 +5168,7 @@ module ts { } } - function checkPrefixOperator(node: UnaryExpression) { + function checkPrefixUnaryExpression(node: PrefixUnaryExpression) { if (node.parserContextFlags & ParserContextFlags.StrictMode) { // The identifier eval or arguments may not appear as the LeftHandSideExpression of an // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression @@ -4843,11 +5176,6 @@ module ts { if ((node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) && isEvalOrArgumentsIdentifier(node.operand)) { return reportInvalidUseInStrictMode(node.operand); } - else if (node.operator === SyntaxKind.DeleteKeyword && node.operand.kind === SyntaxKind.Identifier) { - // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its - // UnaryExpression is a direct reference to a variable, function argument, or function name - return grammarErrorOnNode(node.operand, Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 597d85ccca0..81b96ed3072 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -163,29 +163,31 @@ module ts { ArrayType, TupleType, UnionType, - ParenType, + ParenthesizedType, // Expression - ArrayLiteral, - ObjectLiteral, - PropertyAssignment, - ShorthandPropertyAssignment, - PropertyAccess, - IndexedAccess, + ArrayLiteralExpression, + ObjectLiteralExpression, + PropertyAccessExpression, + ElementAccessExpression, CallExpression, NewExpression, TaggedTemplateExpression, - TypeAssertion, - ParenExpression, + TypeAssertionExpression, + ParenthesizedExpression, FunctionExpression, ArrowFunction, - PrefixOperator, - PostfixOperator, + DeleteExpression, + TypeOfExpression, + VoidExpression, + PrefixUnaryExpression, + PostfixUnaryExpression, BinaryExpression, ConditionalExpression, TemplateExpression, - TemplateSpan, YieldExpression, OmittedExpression, + // Misc + TemplateSpan, // Element Block, VariableStatement, @@ -201,8 +203,6 @@ module ts { ReturnStatement, WithStatement, SwitchStatement, - CaseClause, - DefaultClause, LabeledStatement, ThrowStatement, TryStatement, @@ -221,6 +221,13 @@ module ts { ModuleBlock, ImportDeclaration, ExportAssignment, + // Clauses + CaseClause, + DefaultClause, + HeritageClause, + // Property assignments + PropertyAssignment, + ShorthandPropertyAssignment, // Enum EnumMember, // Top-level nodes @@ -240,7 +247,7 @@ module ts { FirstFutureReservedWord = ImplementsKeyword, LastFutureReservedWord = YieldKeyword, FirstTypeNode = TypeReference, - LastTypeNode = ParenType, + LastTypeNode = ParenthesizedType, FirstPunctuation = OpenBraceToken, LastPunctuation = CaretEqualsToken, FirstToken = EndOfFileToken, @@ -310,7 +317,7 @@ module ts { flags: number; } - export interface Identifier extends Node { + export interface Identifier extends PrimaryExpression { text: string; // Text of identifier (with escapes converted to characters) } @@ -331,6 +338,7 @@ module ts { export type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName; export interface Declaration extends Node { + _declarationBrand: any; name?: DeclarationName; } @@ -346,7 +354,8 @@ module ts { expression?: Expression; } - export interface SignatureDeclaration extends Declaration, ParsedSignature { } + export interface SignatureDeclaration extends Declaration, ParsedSignature { + } export interface VariableDeclaration extends Declaration { name: Identifier; @@ -354,7 +363,7 @@ module ts { initializer?: Expression; } - export interface PropertyDeclaration extends Declaration { + export interface PropertyDeclaration extends Declaration, ClassElement { type?: TypeNode; initializer?: Expression; } @@ -374,27 +383,33 @@ module ts { * AccessorDeclaration */ export interface FunctionLikeDeclaration extends SignatureDeclaration { + _functionLikeDeclarationBrand: any; + asteriskToken?: Node; body?: Block | Expression; } - export interface FunctionDeclaration extends FunctionLikeDeclaration { + export interface FunctionDeclaration extends FunctionLikeDeclaration, Statement { name: Identifier; body?: Block; } - export interface MethodDeclaration extends FunctionLikeDeclaration { + export interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement { body?: Block; } - export interface ConstructorDeclaration extends Node, ParsedSignature { + export interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { body?: Block; } - export interface AccessorDeclaration extends FunctionLikeDeclaration { + export interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement { body?: Block; } + export interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement { + _indexSignatureDeclarationBrand: any; + } + export interface TypeNode extends Node { } export interface TypeReferenceNode extends TypeNode { @@ -406,7 +421,7 @@ module ts { exprName: EntityName; } - export interface TypeLiteralNode extends TypeNode { + export interface TypeLiteralNode extends TypeNode, Declaration { members: NodeArray; } @@ -422,7 +437,7 @@ module ts { types: NodeArray; } - export interface ParenTypeNode extends TypeNode { + export interface ParenthesizedTypeNode extends TypeNode { type: TypeNode; } @@ -430,13 +445,58 @@ module ts { text: string; } + // Note: 'brands' in our syntax nodes serve to give us a small amount of nominal typing. + // Consider 'Expression'. Without the brand, 'Expression' is actually no different + // (structurally) than 'Node'. Because of this you can pass any Node to a function that + // takes an Expression without any error. By using the 'brands' we ensure that the type + // checker actually thinks you have something of the right type. Note: the brands are + // never actually given values. At runtime they have zero cost. + export interface Expression extends Node { + _expressionBrand: any; contextualType?: Type; // Used to temporarily assign a contextual type during overload resolution } export interface UnaryExpression extends Expression { + _unaryExpressionBrand: any; + } + + export interface PrefixUnaryExpression extends UnaryExpression { operator: SyntaxKind; - operand: Expression; + operand: UnaryExpression; + } + + export interface PostfixUnaryExpression extends PostfixExpression { + operand: LeftHandSideExpression; + operator: SyntaxKind; + } + + export interface PostfixExpression extends UnaryExpression { + _postfixExpressionBrand: any; + } + + export interface LeftHandSideExpression extends PostfixExpression { + _leftHandSideExpressionBrand: any; + } + + export interface MemberExpression extends LeftHandSideExpression { + _memberExpressionBrand: any; + } + + export interface PrimaryExpression extends MemberExpression { + _primaryExpressionBrand: any; + } + + export interface DeleteExpression extends UnaryExpression { + expression: UnaryExpression; + } + + export interface TypeOfExpression extends UnaryExpression { + expression: UnaryExpression; + } + + export interface VoidExpression extends UnaryExpression { + expression: UnaryExpression; } export interface YieldExpression extends Expression { @@ -456,7 +516,7 @@ module ts { whenFalse: Expression; } - export interface FunctionExpression extends Expression, FunctionLikeDeclaration { + export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { name?: Identifier; body: Block | Expression; // Required, whereas the member inherited from FunctionDeclaration is optional } @@ -464,11 +524,11 @@ module ts { // The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral, // or any literal of a template, this means quotes have been removed and escapes have been converted to actual characters. // For a NumericLiteral, the stored value is the toString() representation of the number. For example 1, 1.00, and 1e0 are all stored as just "1". - export interface LiteralExpression extends Expression { + export interface LiteralExpression extends PrimaryExpression { text: string; } - export interface TemplateExpression extends Expression { + export interface TemplateExpression extends PrimaryExpression { head: LiteralExpression; templateSpans: NodeArray; } @@ -480,49 +540,51 @@ module ts { literal: LiteralExpression; } - export interface ParenExpression extends Expression { + export interface ParenthesizedExpression extends PrimaryExpression { expression: Expression; } - export interface ArrayLiteral extends Expression { + export interface ArrayLiteralExpression extends PrimaryExpression { elements: NodeArray; } - export interface ObjectLiteral extends Expression { - properties: NodeArray; + export interface ObjectLiteralExpression extends PrimaryExpression, Declaration { + properties: NodeArray; } - export interface PropertyAccess extends Expression { - left: Expression; - right: Identifier; + export interface PropertyAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + name: Identifier; } - export interface IndexedAccess extends Expression { - object: Expression; - index: Expression; + export interface ElementAccessExpression extends MemberExpression { + expression: LeftHandSideExpression; + argumentExpression: Expression; } - export interface CallExpression extends Expression { - func: Expression; + export interface CallExpression extends LeftHandSideExpression { + expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments: NodeArray; } - export interface NewExpression extends CallExpression { } + export interface NewExpression extends CallExpression, PrimaryExpression { } - export interface TaggedTemplateExpression extends Expression { - tag: Expression; + export interface TaggedTemplateExpression extends MemberExpression { + tag: LeftHandSideExpression; template: LiteralExpression | TemplateExpression; } export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression; - export interface TypeAssertion extends Expression { + export interface TypeAssertion extends UnaryExpression { type: TypeNode; - operand: Expression; + expression: UnaryExpression; } - export interface Statement extends Node { } + export interface Statement extends Node, ModuleElement { + _statementBrand: any; + } export interface Block extends Statement { statements: NodeArray; @@ -605,27 +667,39 @@ module ts { finallyBlock?: Block; } - export interface CatchBlock extends Block { + export interface CatchBlock extends Block, Declaration { variable: Identifier; type?: TypeNode; } - export interface ClassDeclaration extends Declaration { - name: Identifier; - typeParameters?: NodeArray; - baseType?: TypeReferenceNode; - implementedTypes?: NodeArray; - members: NodeArray; + export interface ModuleElement extends Node { + _moduleElementBrand: any; } - export interface InterfaceDeclaration extends Declaration { + export interface ClassDeclaration extends Declaration, ModuleElement { name: Identifier; typeParameters?: NodeArray; - baseTypes?: NodeArray; - members: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; } - export interface TypeAliasDeclaration extends Declaration { + export interface ClassElement extends Declaration { + _classElementBrand: any; + } + + export interface InterfaceDeclaration extends Declaration, ModuleElement { + name: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; + } + + export interface HeritageClause extends Node { + token: SyntaxKind; + types?: NodeArray; + } + + export interface TypeAliasDeclaration extends Declaration, ModuleElement { name: Identifier; type: TypeNode; } @@ -637,23 +711,27 @@ module ts { initializer?: Expression; } - export interface EnumDeclaration extends Declaration { + export interface EnumDeclaration extends Declaration, ModuleElement { name: Identifier; members: NodeArray; } - export interface ModuleDeclaration extends Declaration { + export interface ModuleDeclaration extends Declaration, ModuleElement { name: Identifier | LiteralExpression; - body: Block | ModuleDeclaration; + body: ModuleBlock | ModuleDeclaration; } - export interface ImportDeclaration extends Declaration { + export interface ModuleBlock extends Node, ModuleElement { + statements: NodeArray + } + + export interface ImportDeclaration extends Declaration, ModuleElement { name: Identifier; entityName?: EntityName; externalModuleName?: LiteralExpression; } - export interface ExportAssignment extends Statement { + export interface ExportAssignment extends Statement, ModuleElement { exportName: Identifier; } @@ -665,7 +743,10 @@ module ts { hasTrailingNewLine?: boolean; } - export interface SourceFile extends Block { + // Source files are declarations when they are external modules. + export interface SourceFile extends Declaration { + statements: NodeArray; + filename: string; text: string; getLineAndCharacterFromPosition(position: number): LineAndCharacter; @@ -782,7 +863,7 @@ module ts { isEmitBlocked(sourceFile?: SourceFile): boolean; // Returns the constant value of this enum member, or 'undefined' if the enum member has a computed value. getEnumMemberValue(node: EnumMember): number; - isValidPropertyAccess(node: PropertyAccess, propertyName: string): boolean; + isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; } @@ -873,7 +954,7 @@ module ts { isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; // Returns the constant value this property access resolves to, or 'undefined' for a non-constant - getConstantValue(node: PropertyAccess | IndexedAccess): number; + getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; isEmitBlocked(sourceFile?: SourceFile): boolean; } diff --git a/src/harness/typeWriter.ts b/src/harness/typeWriter.ts index ed8d37c9c7e..83aaaaf920a 100644 --- a/src/harness/typeWriter.ts +++ b/src/harness/typeWriter.ts @@ -29,18 +29,21 @@ class TypeWriterWalker { // old typeWriter baselines, suppress tokens case ts.SyntaxKind.ThisKeyword: case ts.SyntaxKind.SuperKeyword: - case ts.SyntaxKind.ArrayLiteral: - case ts.SyntaxKind.ObjectLiteral: - case ts.SyntaxKind.PropertyAccess: - case ts.SyntaxKind.IndexedAccess: + case ts.SyntaxKind.ArrayLiteralExpression: + case ts.SyntaxKind.ObjectLiteralExpression: + case ts.SyntaxKind.PropertyAccessExpression: + case ts.SyntaxKind.ElementAccessExpression: case ts.SyntaxKind.CallExpression: case ts.SyntaxKind.NewExpression: - case ts.SyntaxKind.TypeAssertion: - case ts.SyntaxKind.ParenExpression: + case ts.SyntaxKind.TypeAssertionExpression: + case ts.SyntaxKind.ParenthesizedExpression: case ts.SyntaxKind.FunctionExpression: case ts.SyntaxKind.ArrowFunction: - case ts.SyntaxKind.PrefixOperator: - case ts.SyntaxKind.PostfixOperator: + case ts.SyntaxKind.TypeOfExpression: + case ts.SyntaxKind.VoidExpression: + case ts.SyntaxKind.DeleteExpression: + case ts.SyntaxKind.PrefixUnaryExpression: + case ts.SyntaxKind.PostfixUnaryExpression: case ts.SyntaxKind.BinaryExpression: case ts.SyntaxKind.ConditionalExpression: this.log(node, this.getTypeOfNode(node)); diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index 7867751a96f..d4aa5e40f39 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -242,8 +242,8 @@ module ts.BreakpointResolver { } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === SyntaxKind.TypeAssertion && (node.parent).type === node) { - return spanInNode((node.parent).operand); + if (node.parent.kind === SyntaxKind.TypeAssertionExpression && (node.parent).type === node) { + return spanInNode((node.parent).expression); } // return type of function go to previous token @@ -483,8 +483,8 @@ module ts.BreakpointResolver { } function spanInGreaterThanOrLessThanToken(node: Node): TextSpan { - if (node.parent.kind === SyntaxKind.TypeAssertion) { - return spanInNode((node.parent).operand); + if (node.parent.kind === SyntaxKind.TypeAssertionExpression) { + return spanInNode((node.parent).expression); } return spanInNode(node.parent); diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 2485945df0b..7de7baee6ca 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -523,7 +523,7 @@ module ts.formatting { switch (node.kind) { case SyntaxKind.Block: case SyntaxKind.SwitchStatement: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.TryBlock: case SyntaxKind.CatchBlock: case SyntaxKind.FinallyBlock: @@ -613,7 +613,7 @@ module ts.formatting { } static IsObjectContext(context: FormattingContext): boolean { - return context.contextNode.kind === SyntaxKind.ObjectLiteral; + return context.contextNode.kind === SyntaxKind.ObjectLiteralExpression; } static IsFunctionCallContext(context: FormattingContext): boolean { @@ -673,7 +673,7 @@ module ts.formatting { } static IsVoidOpContext(context: FormattingContext): boolean { - return context.currentTokenSpan.kind === SyntaxKind.VoidKeyword && context.currentTokenParent.kind === SyntaxKind.PrefixOperator; + return context.currentTokenSpan.kind === SyntaxKind.VoidKeyword && context.currentTokenParent.kind === SyntaxKind.VoidExpression; } } } \ No newline at end of file diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 27f75b8d20e..7f071e5c224 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -109,13 +109,13 @@ module ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.SwitchStatement: var openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile); var closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; - case SyntaxKind.ArrayLiteral: + case SyntaxKind.ArrayLiteralExpression: var openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile); var closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); diff --git a/src/services/services.ts b/src/services/services.ts index ed8cb03faee..0ef6ab02b72 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -349,7 +349,7 @@ module ts { // If this is dotted module name, get the doc comments from the parent while (declaration.kind === SyntaxKind.ModuleDeclaration && declaration.parent.kind === SyntaxKind.ModuleDeclaration) { - declaration = declaration.parent; + declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration @@ -712,6 +712,7 @@ module ts { } class SourceFileObject extends NodeObject implements SourceFile { + public _declarationBrand: any; public filename: string; public text: string; @@ -771,7 +772,7 @@ module ts { } } else { - namedDeclarations.push(node); + namedDeclarations.push(functionDeclaration); } forEachChild(node, visit); @@ -1927,21 +1928,21 @@ module ts { } function isRightSideOfPropertyAccess(node: Node) { - return node && node.parent && node.parent.kind === SyntaxKind.PropertyAccess && (node.parent).right === node; + return node && node.parent && node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node; } function isCallExpressionTarget(node: Node): boolean { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === SyntaxKind.CallExpression && (node.parent).func === node; + return node && node.parent && node.parent.kind === SyntaxKind.CallExpression && (node.parent).expression === node; } function isNewExpressionTarget(node: Node): boolean { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === SyntaxKind.NewExpression && (node.parent).func === node; + return node && node.parent && node.parent.kind === SyntaxKind.NewExpression && (node.parent).expression === node; } function isNameOfModuleDeclaration(node: Node) { @@ -1970,8 +1971,8 @@ module ts { case SyntaxKind.SetAccessor: case SyntaxKind.ModuleDeclaration: return (node.parent).name === node; - case SyntaxKind.IndexedAccess: - return (node.parent).index === node; + case SyntaxKind.ElementAccessExpression: + return (node.parent).argumentExpression === node; } } @@ -2373,9 +2374,12 @@ module ts { // other wise, it is a request for all visible symbols in the scope, and the node is the current location var node: Node; var isRightOfDot: boolean; - if (previousToken && previousToken.kind === SyntaxKind.DotToken && - (previousToken.parent.kind === SyntaxKind.PropertyAccess || previousToken.parent.kind === SyntaxKind.QualifiedName)) { - node = (previousToken.parent).left; + if (previousToken && previousToken.kind === SyntaxKind.DotToken && previousToken.parent.kind === SyntaxKind.PropertyAccessExpression) { + node = (previousToken.parent).expression; + isRightOfDot = true; + } + else if (previousToken && previousToken.kind === SyntaxKind.DotToken && previousToken.parent.kind === SyntaxKind.QualifiedName) { + node = (previousToken.parent).left; isRightOfDot = true; } else { @@ -2401,7 +2405,7 @@ module ts { var symbols: Symbol[] = []; isMemberCompletion = true; - if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccess) { + if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression) { var symbol = typeInfoResolver.getSymbolInfo(node); // This is an alias, follow what it aliases @@ -2412,7 +2416,7 @@ module ts { if (symbol && symbol.flags & SymbolFlags.HasExports) { // Extract module or enum members forEachValue(symbol.exports, symbol => { - if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) { + if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) { symbols.push(symbol); } }); @@ -2423,7 +2427,7 @@ module ts { if (type) { // Filter private properties forEach(type.getApparentProperties(), symbol => { - if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) { + if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) { symbols.push(symbol); } }); @@ -2542,7 +2546,7 @@ module ts { return false; } - function getContainingObjectLiteralApplicableForCompletion(previousToken: Node): ObjectLiteral { + function getContainingObjectLiteralApplicableForCompletion(previousToken: Node): ObjectLiteralExpression { // The locations in an object literal expression that are applicable for completion are property name definition locations. if (previousToken) { @@ -2551,8 +2555,8 @@ module ts { switch (previousToken.kind) { case SyntaxKind.OpenBraceToken: // var x = { | case SyntaxKind.CommaToken: // var x = { a: 0, | - if (parent && parent.kind === SyntaxKind.ObjectLiteral) { - return parent; + if (parent && parent.kind === SyntaxKind.ObjectLiteralExpression) { + return parent; } break; } @@ -2878,8 +2882,8 @@ module ts { var type = typeResolver.getNarrowedTypeOfSymbol(symbol, location); if (type) { - if (location.parent && location.parent.kind === SyntaxKind.PropertyAccess) { - var right = (location.parent).right; + if (location.parent && location.parent.kind === SyntaxKind.PropertyAccessExpression) { + var right = (location.parent).name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.kind === SyntaxKind.Missing)){ location = location.parent; @@ -2903,7 +2907,7 @@ module ts { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === SyntaxKind.NewExpression || callExpression.func.kind === SyntaxKind.SuperKeyword; + var useConstructSignatures = callExpression.kind === SyntaxKind.NewExpression || callExpression.expression.kind === SyntaxKind.SuperKeyword; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!contains(allSignatures, signature.target || signature)) { @@ -3201,7 +3205,7 @@ module ts { // Try getting just type at this position and show switch (node.kind) { case SyntaxKind.Identifier: - case SyntaxKind.PropertyAccess: + case SyntaxKind.PropertyAccessExpression: case SyntaxKind.QualifiedName: case SyntaxKind.ThisKeyword: case SyntaxKind.SuperKeyword: @@ -3721,7 +3725,7 @@ module ts { function aggregate(node: Node): void { if (node.kind === SyntaxKind.BreakStatement || node.kind === SyntaxKind.ContinueStatement) { - statementAccumulator.push(node); + statementAccumulator.push(node); } // Do not cross function boundaries. else if (!isAnyFunction(node)) { @@ -3795,7 +3799,7 @@ module ts { } } - function getModifierOccurrences(modifier: SyntaxKind, declaration: Declaration) { + function getModifierOccurrences(modifier: SyntaxKind, declaration: Node) { var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. @@ -4424,11 +4428,11 @@ module ts { if (symbol && symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { forEach(symbol.getDeclarations(), declaration => { if (declaration.kind === SyntaxKind.ClassDeclaration) { - getPropertySymbolFromTypeReference((declaration).baseType); - forEach((declaration).implementedTypes, getPropertySymbolFromTypeReference); + getPropertySymbolFromTypeReference(getClassBaseTypeNode(declaration)); + forEach(getClassImplementedTypeNodes(declaration), getPropertySymbolFromTypeReference); } else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { - forEach((declaration).baseTypes, getPropertySymbolFromTypeReference); + forEach(getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); } @@ -4574,7 +4578,7 @@ module ts { var parent = node.parent; if (parent) { - if (parent.kind === SyntaxKind.PostfixOperator || parent.kind === SyntaxKind.PrefixOperator) { + if (parent.kind === SyntaxKind.PostfixUnaryExpression || parent.kind === SyntaxKind.PrefixUnaryExpression) { return true; } else if (parent.kind === SyntaxKind.BinaryExpression && (parent).left === node) { @@ -4736,7 +4740,7 @@ module ts { return emitOutput; } - function getMeaningFromDeclaration(node: Declaration): SemanticMeaning { + function getMeaningFromDeclaration(node: Node): SemanticMeaning { switch (node.kind) { case SyntaxKind.Parameter: case SyntaxKind.VariableDeclaration: @@ -4879,7 +4883,7 @@ module ts { } switch (node.kind) { - case SyntaxKind.PropertyAccess: + case SyntaxKind.PropertyAccessExpression: case SyntaxKind.QualifiedName: case SyntaxKind.StringLiteral: case SyntaxKind.FalseKeyword: @@ -5063,8 +5067,8 @@ module ts { // the '=' in a variable declaration is special cased here. if (token.parent.kind === SyntaxKind.BinaryExpression || token.parent.kind === SyntaxKind.VariableDeclaration || - token.parent.kind === SyntaxKind.PrefixOperator || - token.parent.kind === SyntaxKind.PostfixOperator || + token.parent.kind === SyntaxKind.PrefixUnaryExpression || + token.parent.kind === SyntaxKind.PostfixUnaryExpression || token.parent.kind === SyntaxKind.ConditionalExpression) { return ClassificationTypeNames.operator; } diff --git a/src/services/smartIndenter.ts b/src/services/smartIndenter.ts index e593c6cfd66..3fbfe142282 100644 --- a/src/services/smartIndenter.ts +++ b/src/services/smartIndenter.ts @@ -227,10 +227,10 @@ module ts.formatting { return (node.parent).typeArguments; } break; - case SyntaxKind.ObjectLiteral: - return (node.parent).properties; - case SyntaxKind.ArrayLiteral: - return (node.parent).elements; + case SyntaxKind.ObjectLiteralExpression: + return (node.parent).properties; + case SyntaxKind.ArrayLiteralExpression: + return (node.parent).elements; case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: @@ -323,19 +323,19 @@ module ts.formatting { case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: - case SyntaxKind.ArrayLiteral: + case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.Block: case SyntaxKind.FunctionBlock: case SyntaxKind.TryBlock: case SyntaxKind.CatchBlock: case SyntaxKind.FinallyBlock: case SyntaxKind.ModuleBlock: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.TypeLiteral: case SyntaxKind.SwitchStatement: case SyntaxKind.DefaultClause: case SyntaxKind.CaseClause: - case SyntaxKind.ParenExpression: + case SyntaxKind.ParenthesizedExpression: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.VariableStatement: @@ -397,7 +397,7 @@ module ts.formatting { case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.Block: case SyntaxKind.CatchBlock: case SyntaxKind.FinallyBlock: @@ -405,7 +405,7 @@ module ts.formatting { case SyntaxKind.ModuleBlock: case SyntaxKind.SwitchStatement: return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile); - case SyntaxKind.ParenExpression: + case SyntaxKind.ParenthesizedExpression: case SyntaxKind.CallSignature: case SyntaxKind.CallExpression: case SyntaxKind.ConstructSignature: @@ -424,7 +424,7 @@ module ts.formatting { return isCompletedNode((n).thenStatement, sourceFile); case SyntaxKind.ExpressionStatement: return isCompletedNode((n).expression, sourceFile); - case SyntaxKind.ArrayLiteral: + case SyntaxKind.ArrayLiteralExpression: return nodeEndsWith(n, SyntaxKind.CloseBracketToken, sourceFile); case SyntaxKind.Missing: return false; diff --git a/tests/baselines/reference/assignmentLHSIsValue.errors.txt b/tests/baselines/reference/assignmentLHSIsValue.errors.txt index 2f65b368532..ea4908f731b 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/assignmentLHSIsValue.errors.txt @@ -20,9 +20,6 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(3 tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(42,30): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(44,13): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(46,21): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(54,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(57,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(58,1): error TS2364: Invalid left-hand side of assignment expression. @@ -40,7 +37,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6 tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: Invalid left-hand side of assignment expression. -==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (40 errors) ==== +==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (37 errors) ==== // expected error for all the LHS of assignments var value; @@ -119,20 +116,14 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7 constructor() { super(); super = value; } ~ !!! error TS1034: 'super' must be followed by an argument list or member access. - ~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. foo() { super = value } ~ !!! error TS1034: 'super' must be followed by an argument list or member access. - ~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. static sfoo() { super = value; } ~ !!! error TS1034: 'super' must be followed by an argument list or member access. - ~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. } // function expression diff --git a/tests/baselines/reference/badArraySyntax.errors.txt b/tests/baselines/reference/badArraySyntax.errors.txt index 500a89d85a9..b22097253fc 100644 --- a/tests/baselines/reference/badArraySyntax.errors.txt +++ b/tests/baselines/reference/badArraySyntax.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/badArraySyntax.ts(6,10): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/compiler/badArraySyntax.ts(7,10): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/compiler/badArraySyntax.ts(8,15): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/compiler/badArraySyntax.ts(9,15): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/compiler/badArraySyntax.ts(10,17): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/badArraySyntax.ts(6,15): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/badArraySyntax.ts(7,15): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/badArraySyntax.ts(8,20): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/badArraySyntax.ts(9,20): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/badArraySyntax.ts(10,40): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ==== tests/cases/compiler/badArraySyntax.ts (5 errors) ==== @@ -12,18 +12,18 @@ tests/cases/compiler/badArraySyntax.ts(10,17): error TS1150: 'new T[]' cannot be var a1: Z[] = []; var a2 = new Z[]; - ~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. var a3 = new Z[](); - ~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. var a4: Z[] = new Z[]; - ~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. var a5: Z[] = new Z[](); - ~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. var a6: Z[][] = new Z [ ] [ ]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. \ No newline at end of file diff --git a/tests/baselines/reference/cannotInvokeNewOnErrorExpression.errors.txt b/tests/baselines/reference/cannotInvokeNewOnErrorExpression.errors.txt index f0397f5ee60..cfb9287cdbc 100644 --- a/tests/baselines/reference/cannotInvokeNewOnErrorExpression.errors.txt +++ b/tests/baselines/reference/cannotInvokeNewOnErrorExpression.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts(5,9): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts(5,21): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts(5,15): error TS2339: Property 'ClassA' does not exist on type 'typeof M'. @@ -8,7 +8,7 @@ tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts(5,15): error TS2339: Pr class ClassA {} } var t = new M.ClassA[]; - ~~~~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~ !!! error TS2339: Property 'ClassA' does not exist on type 'typeof M'. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendingPrimitive.errors.txt b/tests/baselines/reference/classExtendingPrimitive.errors.txt index cab86e9e38e..b27f1bc29d5 100644 --- a/tests/baselines/reference/classExtendingPrimitive.errors.txt +++ b/tests/baselines/reference/classExtendingPrimitive.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(7,19): error TS1003: Identifier expected. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(9,19): error TS1003: Identifier expected. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(7,19): error TS1133: Type reference expected. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(9,19): error TS1133: Type reference expected. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(9,24): error TS1005: ';' expected. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(3,17): error TS2304: Cannot find name 'number'. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(4,18): error TS2304: Cannot find name 'string'. @@ -28,13 +28,13 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla !!! error TS2304: Cannot find name 'Void'. class C4a extends void {} ~~~~ -!!! error TS1003: Identifier expected. +!!! error TS1133: Type reference expected. class C5 extends Null { } ~~~~ !!! error TS2304: Cannot find name 'Null'. class C5a extends null { } ~~~~ -!!! error TS1003: Identifier expected. +!!! error TS1133: Type reference expected. ~ !!! error TS1005: ';' expected. class C6 extends undefined { } diff --git a/tests/baselines/reference/classExtendingPrimitive2.errors.txt b/tests/baselines/reference/classExtendingPrimitive2.errors.txt index 9378c7bdc19..cc7da5de821 100644 --- a/tests/baselines/reference/classExtendingPrimitive2.errors.txt +++ b/tests/baselines/reference/classExtendingPrimitive2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts(3,19): error TS1003: Identifier expected. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts(4,19): error TS1003: Identifier expected. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts(3,19): error TS1133: Type reference expected. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts(4,19): error TS1133: Type reference expected. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts(4,24): error TS1005: ';' expected. @@ -8,9 +8,9 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla class C4a extends void {} ~~~~ -!!! error TS1003: Identifier expected. +!!! error TS1133: Type reference expected. class C5a extends null { } ~~~~ -!!! error TS1003: Identifier expected. +!!! error TS1133: Type reference expected. ~ !!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsEveryObjectType.errors.txt b/tests/baselines/reference/classExtendsEveryObjectType.errors.txt index 35fc2d30a35..031caf19e26 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType.errors.txt +++ b/tests/baselines/reference/classExtendsEveryObjectType.errors.txt @@ -1,5 +1,4 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,18): error TS1003: Identifier expected. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(16,18): error TS1003: Identifier expected. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(16,18): error TS1133: Type reference expected. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(16,20): error TS1005: ';' expected. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(4,17): error TS2311: A class may only extend another class. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(8,18): error TS2304: Cannot find name 'x'. @@ -7,7 +6,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(14,18): error TS2304: Cannot find name 'foo'. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts (7 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts (6 errors) ==== interface I { foo: string; } @@ -16,8 +15,6 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla !!! error TS2311: A class may only extend another class. class C2 extends { foo: string; } { } // error - ~ -!!! error TS1003: Identifier expected. var x: { foo: string; } class C3 extends x { } // error ~ @@ -35,6 +32,6 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla class C6 extends []{ } // error ~ -!!! error TS1003: Identifier expected. +!!! error TS1133: Type reference expected. ~ !!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt b/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt index a60745020e7..ce5d8aed7a9 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt +++ b/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt @@ -1,15 +1,12 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(1,18): error TS1003: Identifier expected. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(3,18): error TS1003: Identifier expected. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(3,18): error TS1133: Type reference expected. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(3,20): error TS1005: ';' expected. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts (3 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts (2 errors) ==== class C2 extends { foo: string; } { } // error - ~ -!!! error TS1003: Identifier expected. class C6 extends []{ } // error ~ -!!! error TS1003: Identifier expected. +!!! error TS1133: Type reference expected. ~ !!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsMultipleBaseClasses.errors.txt b/tests/baselines/reference/classExtendsMultipleBaseClasses.errors.txt index 86b271c9ae8..3c10d6c6e5f 100644 --- a/tests/baselines/reference/classExtendsMultipleBaseClasses.errors.txt +++ b/tests/baselines/reference/classExtendsMultipleBaseClasses.errors.txt @@ -1,12 +1,9 @@ -tests/cases/compiler/classExtendsMultipleBaseClasses.ts(3,18): error TS1005: '{' expected. -tests/cases/compiler/classExtendsMultipleBaseClasses.ts(3,21): error TS1005: ';' expected. +tests/cases/compiler/classExtendsMultipleBaseClasses.ts(3,19): error TS1174: Classes can only extend a single class. -==== tests/cases/compiler/classExtendsMultipleBaseClasses.ts (2 errors) ==== +==== tests/cases/compiler/classExtendsMultipleBaseClasses.ts (1 errors) ==== class A { } class B { } class C extends A,B { } - ~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. \ No newline at end of file + ~ +!!! error TS1174: Classes can only extend a single class. \ No newline at end of file diff --git a/tests/baselines/reference/classHeritageWithTrailingSeparator.errors.txt b/tests/baselines/reference/classHeritageWithTrailingSeparator.errors.txt index 1a323fd5aa4..037a3a351fb 100644 --- a/tests/baselines/reference/classHeritageWithTrailingSeparator.errors.txt +++ b/tests/baselines/reference/classHeritageWithTrailingSeparator.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/classHeritageWithTrailingSeparator.ts(2,18): error TS1005: '{' expected. +tests/cases/compiler/classHeritageWithTrailingSeparator.ts(2,18): error TS1009: Trailing comma not allowed. ==== tests/cases/compiler/classHeritageWithTrailingSeparator.ts (1 errors) ==== class C { foo: number } class D extends C, { ~ -!!! error TS1005: '{' expected. +!!! error TS1009: Trailing comma not allowed. } \ No newline at end of file diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt index b850d0a0d38..af662869b5b 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt @@ -42,12 +42,6 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(55,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(62,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(63,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(69,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(70,9): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(74,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(75,9): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(79,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(80,9): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(91,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(92,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(95,1): error TS2364: Invalid left-hand side of assignment expression. @@ -80,7 +74,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(122,1): error TS2364: Invalid left-hand side of assignment expression. -==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (80 errors) ==== +==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (74 errors) ==== // expected error for all the LHS of compound assignments (arithmetic and addition) var value; @@ -220,39 +214,27 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa super *= value; ~~ !!! error TS1034: 'super' must be followed by an argument list or member access. - ~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. super += value; ~~ !!! error TS1034: 'super' must be followed by an argument list or member access. - ~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. } foo() { super *= value; ~~ !!! error TS1034: 'super' must be followed by an argument list or member access. - ~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. super += value; ~~ !!! error TS1034: 'super' must be followed by an argument list or member access. - ~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. } static sfoo() { super *= value; ~~ !!! error TS1034: 'super' must be followed by an argument list or member access. - ~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. super += value; ~~ !!! error TS1034: 'super' must be followed by an argument list or member access. - ~~~~~ -!!! error TS2364: Invalid left-hand side of assignment expression. } } diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt index 53d24b3d0f8..8d544ff1bcb 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt @@ -42,7 +42,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,9): error TS tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,27): error TS1135: Argument expression expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,33): error TS1005: '(' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,43): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,59): error TS1109: Expression expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,60): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,65): error TS1129: Statement expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,9): error TS1129: Statement expected. @@ -88,7 +87,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,29): error T tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error TS2304: Cannot find name 'string'. -==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (88 errors) ==== +==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (87 errors) ==== declare module "fs" { export class File { constructor(filename: string); @@ -498,8 +497,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error T ~ !!! error TS1005: '(' expected. ~~~ -!!! error TS1109: Expression expected. - ~ !!! error TS1109: Expression expected. ~ !!! error TS1005: ';' expected. diff --git a/tests/baselines/reference/createArray.errors.txt b/tests/baselines/reference/createArray.errors.txt index 2e2b4567567..6f79c4b47d2 100644 --- a/tests/baselines/reference/createArray.errors.txt +++ b/tests/baselines/reference/createArray.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/createArray.ts(1,8): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/compiler/createArray.ts(6,1): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/compiler/createArray.ts(7,8): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/compiler/createArray.ts(8,8): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/createArray.ts(1,18): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/createArray.ts(6,6): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/createArray.ts(7,19): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/createArray.ts(8,18): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/compiler/createArray.ts(1,12): error TS2304: Cannot find name 'number'. tests/cases/compiler/createArray.ts(7,12): error TS2304: Cannot find name 'boolean'. tests/cases/compiler/createArray.ts(8,12): error TS2304: Cannot find name 'string'. @@ -9,7 +9,7 @@ tests/cases/compiler/createArray.ts(8,12): error TS2304: Cannot find name 'strin ==== tests/cases/compiler/createArray.ts (7 errors) ==== var na=new number[]; - ~~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~ !!! error TS2304: Cannot find name 'number'. @@ -18,15 +18,15 @@ tests/cases/compiler/createArray.ts(8,12): error TS2304: Cannot find name 'strin } new C[]; - ~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. var ba=new boolean[]; - ~~~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~~ !!! error TS2304: Cannot find name 'boolean'. var sa=new string[]; - ~~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~ !!! error TS2304: Cannot find name 'string'. diff --git a/tests/baselines/reference/enumConflictsWithGlobalIdentifier.errors.txt b/tests/baselines/reference/enumConflictsWithGlobalIdentifier.errors.txt index e6859558f74..b91ddad3eb4 100644 --- a/tests/baselines/reference/enumConflictsWithGlobalIdentifier.errors.txt +++ b/tests/baselines/reference/enumConflictsWithGlobalIdentifier.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/enumConflictsWithGlobalIdentifier.ts(4,29): error TS1003: Identifier expected. +tests/cases/compiler/enumConflictsWithGlobalIdentifier.ts(5,1): error TS1003: Identifier expected. tests/cases/compiler/enumConflictsWithGlobalIdentifier.ts(4,9): error TS2304: Cannot find name 'IgnoreRulesSpecific'. @@ -7,9 +7,9 @@ tests/cases/compiler/enumConflictsWithGlobalIdentifier.ts(4,9): error TS2304: Ca IgnoreRulesSpecific = 0, } var x = IgnoreRulesSpecific. - -!!! error TS1003: Identifier expected. ~~~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'IgnoreRulesSpecific'. var y = Position.IgnoreRulesSpecific; + +!!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/enumMemberResolution.errors.txt b/tests/baselines/reference/enumMemberResolution.errors.txt index f446c0d7909..18910485236 100644 --- a/tests/baselines/reference/enumMemberResolution.errors.txt +++ b/tests/baselines/reference/enumMemberResolution.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/enumMemberResolution.ts(4,29): error TS1003: Identifier expected. +tests/cases/compiler/enumMemberResolution.ts(5,1): error TS1003: Identifier expected. tests/cases/compiler/enumMemberResolution.ts(4,9): error TS2304: Cannot find name 'IgnoreRulesSpecific'. @@ -7,10 +7,10 @@ tests/cases/compiler/enumMemberResolution.ts(4,9): error TS2304: Cannot find nam IgnoreRulesSpecific = 0 } var x = IgnoreRulesSpecific. // error - -!!! error TS1003: Identifier expected. ~~~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'IgnoreRulesSpecific'. var y = 1; + +!!! error TS1003: Identifier expected. var z = Position2.IgnoreRulesSpecific; // no error \ No newline at end of file diff --git a/tests/baselines/reference/extendsClauseAlreadySeen.errors.txt b/tests/baselines/reference/extendsClauseAlreadySeen.errors.txt index b2df83aeb0f..472462d3dcf 100644 --- a/tests/baselines/reference/extendsClauseAlreadySeen.errors.txt +++ b/tests/baselines/reference/extendsClauseAlreadySeen.errors.txt @@ -1,21 +1,12 @@ -tests/cases/compiler/extendsClauseAlreadySeen.ts(4,19): error TS1005: '{' expected. -tests/cases/compiler/extendsClauseAlreadySeen.ts(4,29): error TS1005: ';' expected. -tests/cases/compiler/extendsClauseAlreadySeen.ts(5,11): error TS1005: ';' expected. -tests/cases/compiler/extendsClauseAlreadySeen.ts(5,5): error TS2304: Cannot find name 'baz'. +tests/cases/compiler/extendsClauseAlreadySeen.ts(4,19): error TS1172: 'extends' clause already seen. -==== tests/cases/compiler/extendsClauseAlreadySeen.ts (4 errors) ==== +==== tests/cases/compiler/extendsClauseAlreadySeen.ts (1 errors) ==== class C { } class D extends C extends C { ~~~~~~~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1172: 'extends' clause already seen. baz() { } - ~ -!!! error TS1005: ';' expected. - ~~~ -!!! error TS2304: Cannot find name 'baz'. } \ No newline at end of file diff --git a/tests/baselines/reference/extendsClauseAlreadySeen2.errors.txt b/tests/baselines/reference/extendsClauseAlreadySeen2.errors.txt index 45971dc62f3..7985c62a365 100644 --- a/tests/baselines/reference/extendsClauseAlreadySeen2.errors.txt +++ b/tests/baselines/reference/extendsClauseAlreadySeen2.errors.txt @@ -1,20 +1,12 @@ -tests/cases/compiler/extendsClauseAlreadySeen2.ts(4,30): error TS1005: '{' expected. -tests/cases/compiler/extendsClauseAlreadySeen2.ts(4,38): error TS2365: Operator '>' cannot be applied to types 'boolean' and '{ baz: () => void; }'. -tests/cases/compiler/extendsClauseAlreadySeen2.ts(4,40): error TS2304: Cannot find name 'string'. +tests/cases/compiler/extendsClauseAlreadySeen2.ts(4,30): error TS1172: 'extends' clause already seen. -==== tests/cases/compiler/extendsClauseAlreadySeen2.ts (3 errors) ==== +==== tests/cases/compiler/extendsClauseAlreadySeen2.ts (1 errors) ==== class C { } class D extends C extends C { ~~~~~~~ -!!! error TS1005: '{' expected. - ~~~~~~~~~~~ - ~~~~~~ -!!! error TS2304: Cannot find name 'string'. +!!! error TS1172: 'extends' clause already seen. baz() { } - ~~~~~~~~~~~~~ - } - ~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '{ baz: () => void; }'. \ No newline at end of file + } \ No newline at end of file diff --git a/tests/baselines/reference/implementClausePrecedingExtends.errors.txt b/tests/baselines/reference/implementClausePrecedingExtends.errors.txt index 0ded03b0808..90062c2ad74 100644 --- a/tests/baselines/reference/implementClausePrecedingExtends.errors.txt +++ b/tests/baselines/reference/implementClausePrecedingExtends.errors.txt @@ -1,16 +1,8 @@ -tests/cases/compiler/implementClausePrecedingExtends.ts(2,22): error TS1005: '{' expected. -tests/cases/compiler/implementClausePrecedingExtends.ts(2,32): error TS1005: ';' expected. -tests/cases/compiler/implementClausePrecedingExtends.ts(2,7): error TS2420: Class 'D' incorrectly implements interface 'C'. - Property 'foo' is missing in type 'D'. +tests/cases/compiler/implementClausePrecedingExtends.ts(2,22): error TS1173: 'extends' clause must precede 'implements' clause. -==== tests/cases/compiler/implementClausePrecedingExtends.ts (3 errors) ==== +==== tests/cases/compiler/implementClausePrecedingExtends.ts (1 errors) ==== class C { foo: number } class D implements C extends C { } ~~~~~~~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS2420: Class 'D' incorrectly implements interface 'C'. -!!! error TS2420: Property 'foo' is missing in type 'D'. \ No newline at end of file +!!! error TS1173: 'extends' clause must precede 'implements' clause. \ No newline at end of file diff --git a/tests/baselines/reference/implementsClauseAlreadySeen.errors.txt b/tests/baselines/reference/implementsClauseAlreadySeen.errors.txt index ca06cf9bb73..80265c0802f 100644 --- a/tests/baselines/reference/implementsClauseAlreadySeen.errors.txt +++ b/tests/baselines/reference/implementsClauseAlreadySeen.errors.txt @@ -1,27 +1,12 @@ -tests/cases/compiler/implementsClauseAlreadySeen.ts(4,22): error TS1005: '{' expected. -tests/cases/compiler/implementsClauseAlreadySeen.ts(4,33): error TS1005: ';' expected. -tests/cases/compiler/implementsClauseAlreadySeen.ts(4,35): error TS1005: ';' expected. -tests/cases/compiler/implementsClauseAlreadySeen.ts(5,11): error TS1005: ';' expected. -tests/cases/compiler/implementsClauseAlreadySeen.ts(4,22): error TS2304: Cannot find name 'implements'. -tests/cases/compiler/implementsClauseAlreadySeen.ts(5,5): error TS2304: Cannot find name 'baz'. +tests/cases/compiler/implementsClauseAlreadySeen.ts(4,22): error TS1175: 'implements' clause already seen. -==== tests/cases/compiler/implementsClauseAlreadySeen.ts (6 errors) ==== +==== tests/cases/compiler/implementsClauseAlreadySeen.ts (1 errors) ==== class C { } class D implements C implements C { ~~~~~~~~~~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1005: ';' expected. - ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'implements'. +!!! error TS1175: 'implements' clause already seen. baz() { } - ~ -!!! error TS1005: ';' expected. - ~~~ -!!! error TS2304: Cannot find name 'baz'. } \ No newline at end of file diff --git a/tests/baselines/reference/interfaceThatInheritsFromItself.errors.txt b/tests/baselines/reference/interfaceThatInheritsFromItself.errors.txt index 7aa5cc04a87..440650717bd 100644 --- a/tests/baselines/reference/interfaceThatInheritsFromItself.errors.txt +++ b/tests/baselines/reference/interfaceThatInheritsFromItself.errors.txt @@ -1,14 +1,10 @@ -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(10,15): error TS1005: '{' expected. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(10,26): error TS1005: ';' expected. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(10,30): error TS1005: ';' expected. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(10,15): error TS1176: Interface declaration cannot have 'implements' clause. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(1,11): error TS2310: Type 'Foo' recursively references itself as a base type. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(4,11): error TS2310: Type 'Foo2' recursively references itself as a base type. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(7,11): error TS2310: Type 'Foo3' recursively references itself as a base type. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(10,15): error TS2304: Cannot find name 'implements'. -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(10,26): error TS2304: Cannot find name 'Bar'. -==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts (8 errors) ==== +==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts (4 errors) ==== interface Foo extends Foo { // error ~~~ !!! error TS2310: Type 'Foo' recursively references itself as a base type. @@ -26,15 +22,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFr interface Bar implements Bar { // error ~~~~~~~~~~ -!!! error TS1005: '{' expected. - ~~~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1005: ';' expected. - ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'implements'. - ~~~ -!!! error TS2304: Cannot find name 'Bar'. +!!! error TS1176: Interface declaration cannot have 'implements' clause. } \ No newline at end of file diff --git a/tests/baselines/reference/interfaceWithImplements1.errors.txt b/tests/baselines/reference/interfaceWithImplements1.errors.txt index bb9465712d8..87faf921e95 100644 --- a/tests/baselines/reference/interfaceWithImplements1.errors.txt +++ b/tests/baselines/reference/interfaceWithImplements1.errors.txt @@ -1,22 +1,10 @@ -tests/cases/compiler/interfaceWithImplements1.ts(3,16): error TS1005: '{' expected. -tests/cases/compiler/interfaceWithImplements1.ts(3,27): error TS1005: ';' expected. -tests/cases/compiler/interfaceWithImplements1.ts(3,32): error TS1005: ';' expected. -tests/cases/compiler/interfaceWithImplements1.ts(3,16): error TS2304: Cannot find name 'implements'. -tests/cases/compiler/interfaceWithImplements1.ts(3,27): error TS2304: Cannot find name 'IFoo'. +tests/cases/compiler/interfaceWithImplements1.ts(3,16): error TS1176: Interface declaration cannot have 'implements' clause. -==== tests/cases/compiler/interfaceWithImplements1.ts (5 errors) ==== +==== tests/cases/compiler/interfaceWithImplements1.ts (1 errors) ==== interface IFoo { } interface IBar implements IFoo { ~~~~~~~~~~ -!!! error TS1005: '{' expected. - ~~~~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1005: ';' expected. - ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'implements'. - ~~~~ -!!! error TS2304: Cannot find name 'IFoo'. +!!! error TS1176: Interface declaration cannot have 'implements' clause. } \ No newline at end of file diff --git a/tests/baselines/reference/libMembers.errors.txt b/tests/baselines/reference/libMembers.errors.txt index 73f5c945f70..a6af67821b3 100644 --- a/tests/baselines/reference/libMembers.errors.txt +++ b/tests/baselines/reference/libMembers.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/libMembers.ts(9,11): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/libMembers.ts(9,16): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/compiler/libMembers.ts(4,3): error TS2339: Property 'subby' does not exist on type 'string'. tests/cases/compiler/libMembers.ts(12,15): error TS2339: Property 'prototype' does not exist on type 'C'. @@ -15,7 +15,7 @@ tests/cases/compiler/libMembers.ts(12,15): error TS2339: Property 'prototype' do export class C { } var a=new C[]; - ~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. a.length; a.push(new C()); diff --git a/tests/baselines/reference/multipleInheritance.errors.txt b/tests/baselines/reference/multipleInheritance.errors.txt index b15a6978ef5..19ef1e755e3 100644 --- a/tests/baselines/reference/multipleInheritance.errors.txt +++ b/tests/baselines/reference/multipleInheritance.errors.txt @@ -1,14 +1,12 @@ -tests/cases/compiler/multipleInheritance.ts(9,19): error TS1005: '{' expected. -tests/cases/compiler/multipleInheritance.ts(9,24): error TS1005: ';' expected. -tests/cases/compiler/multipleInheritance.ts(18,19): error TS1005: '{' expected. -tests/cases/compiler/multipleInheritance.ts(18,24): error TS1005: ';' expected. +tests/cases/compiler/multipleInheritance.ts(9,21): error TS1174: Classes can only extend a single class. +tests/cases/compiler/multipleInheritance.ts(18,21): error TS1174: Classes can only extend a single class. tests/cases/compiler/multipleInheritance.ts(34,7): error TS2415: Class 'Baad' incorrectly extends base class 'Good'. Types of property 'g' are incompatible. Type '(n: number) => number' is not assignable to type '() => number'. tests/cases/compiler/multipleInheritance.ts(35,12): error TS2425: Class 'Good' defines instance member property 'f', but extended class 'Baad' defines it as instance member function. -==== tests/cases/compiler/multipleInheritance.ts (6 errors) ==== +==== tests/cases/compiler/multipleInheritance.ts (4 errors) ==== class B1 { public x; } @@ -18,10 +16,8 @@ tests/cases/compiler/multipleInheritance.ts(35,12): error TS2425: Class 'Good' d } class C extends B1, B2 { // duplicate member - ~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. + ~~ +!!! error TS1174: Classes can only extend a single class. } class D1 extends B1 { @@ -31,10 +27,8 @@ tests/cases/compiler/multipleInheritance.ts(35,12): error TS2425: Class 'Good' d } class E extends D1, D2 { // nope, duplicate member - ~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. + ~~ +!!! error TS1174: Classes can only extend a single class. } class N { diff --git a/tests/baselines/reference/newOperator.errors.txt b/tests/baselines/reference/newOperator.errors.txt index 9232b865648..33e2d806d3e 100644 --- a/tests/baselines/reference/newOperator.errors.txt +++ b/tests/baselines/reference/newOperator.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/newOperator.ts(18,10): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/compiler/newOperator.ts(20,1): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/newOperator.ts(18,20): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/newOperator.ts(22,1): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/compiler/newOperator.ts(44,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/newOperator.ts(3,13): error TS2304: Cannot find name 'ifc'. tests/cases/compiler/newOperator.ts(10,10): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -38,16 +38,14 @@ tests/cases/compiler/newOperator.ts(31,10): error TS2351: Cannot use 'new' with // Various spacing var t3 = new string[]( ); - ~~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~ !!! error TS2304: Cannot find name 'string'. var t4 = new - ~~~ string ~~~~~~ - ~~~~~~ !!! error TS2304: Cannot find name 'string'. [ ~ diff --git a/tests/baselines/reference/objectLitArrayDeclNoNew.errors.txt b/tests/baselines/reference/objectLitArrayDeclNoNew.errors.txt index 01c0fea7a26..0c683946550 100644 --- a/tests/baselines/reference/objectLitArrayDeclNoNew.errors.txt +++ b/tests/baselines/reference/objectLitArrayDeclNoNew.errors.txt @@ -1,8 +1,7 @@ -tests/cases/compiler/objectLitArrayDeclNoNew.ts(22,20): error TS1109: Expression expected. tests/cases/compiler/objectLitArrayDeclNoNew.ts(27,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/objectLitArrayDeclNoNew.ts (2 errors) ==== +==== tests/cases/compiler/objectLitArrayDeclNoNew.ts (1 errors) ==== declare var console; "use strict"; module Test { @@ -25,8 +24,6 @@ tests/cases/compiler/objectLitArrayDeclNoNew.ts(27,1): error TS1128: Declaration var state:IState= null; return { tokens: Gar[],//IToken[], // Missing new. Correct syntax is: tokens: new IToken[] - ~ -!!! error TS1109: Expression expected. endState: state }; } diff --git a/tests/baselines/reference/parserClassDeclaration1.errors.txt b/tests/baselines/reference/parserClassDeclaration1.errors.txt index 9ab40a64262..5d148f9c5f6 100644 --- a/tests/baselines/reference/parserClassDeclaration1.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration1.errors.txt @@ -1,17 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration1.ts(1,19): error TS1005: '{' expected. -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration1.ts(1,29): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration1.ts(1,19): error TS1172: 'extends' clause already seen. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration1.ts(1,17): error TS2304: Cannot find name 'A'. -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration1.ts(1,27): error TS2304: Cannot find name 'B'. -==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration1.ts (4 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration1.ts (2 errors) ==== class C extends A extends B { ~~~~~~~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1172: 'extends' clause already seen. ~ !!! error TS2304: Cannot find name 'A'. - ~ -!!! error TS2304: Cannot find name 'B'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserClassDeclaration2.errors.txt b/tests/baselines/reference/parserClassDeclaration2.errors.txt index 1f8509ce754..31887698f3d 100644 --- a/tests/baselines/reference/parserClassDeclaration2.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration2.errors.txt @@ -1,23 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration2.ts(1,22): error TS1005: '{' expected. -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration2.ts(1,33): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration2.ts(1,35): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration2.ts(1,22): error TS1175: 'implements' clause already seen. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration2.ts(1,20): error TS2304: Cannot find name 'A'. -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration2.ts(1,22): error TS2304: Cannot find name 'implements'. -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration2.ts(1,33): error TS2304: Cannot find name 'B'. -==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration2.ts (6 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration2.ts (2 errors) ==== class C implements A implements B { ~~~~~~~~~~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1175: 'implements' clause already seen. ~ !!! error TS2304: Cannot find name 'A'. - ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'implements'. - ~ -!!! error TS2304: Cannot find name 'B'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserClassDeclaration3.errors.txt b/tests/baselines/reference/parserClassDeclaration3.errors.txt index f7c20f7cde9..38cac10f4df 100644 --- a/tests/baselines/reference/parserClassDeclaration3.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration3.errors.txt @@ -1,15 +1,12 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration3.ts(1,22): error TS1005: '{' expected. -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration3.ts(1,32): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration3.ts(1,22): error TS1173: 'extends' clause must precede 'implements' clause. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration3.ts(1,20): error TS2304: Cannot find name 'A'. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration3.ts(1,30): error TS2304: Cannot find name 'B'. -==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration3.ts (4 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration3.ts (3 errors) ==== class C implements A extends B { ~~~~~~~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1173: 'extends' clause must precede 'implements' clause. ~ !!! error TS2304: Cannot find name 'A'. ~ diff --git a/tests/baselines/reference/parserClassDeclaration4.errors.txt b/tests/baselines/reference/parserClassDeclaration4.errors.txt index 4b4aceea66f..27808412228 100644 --- a/tests/baselines/reference/parserClassDeclaration4.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration4.errors.txt @@ -1,15 +1,12 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration4.ts(1,32): error TS1005: '{' expected. -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration4.ts(1,42): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration4.ts(1,32): error TS1172: 'extends' clause already seen. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration4.ts(1,17): error TS2304: Cannot find name 'A'. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration4.ts(1,30): error TS2304: Cannot find name 'B'. -==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration4.ts (4 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration4.ts (3 errors) ==== class C extends A implements B extends C { ~~~~~~~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1172: 'extends' clause already seen. ~ !!! error TS2304: Cannot find name 'A'. ~ diff --git a/tests/baselines/reference/parserClassDeclaration5.errors.txt b/tests/baselines/reference/parserClassDeclaration5.errors.txt index a6c9ab07621..8cd90d61dee 100644 --- a/tests/baselines/reference/parserClassDeclaration5.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration5.errors.txt @@ -1,23 +1,14 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts(1,32): error TS1005: '{' expected. -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts(1,43): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts(1,45): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts(1,32): error TS1175: 'implements' clause already seen. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts(1,17): error TS2304: Cannot find name 'A'. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts(1,30): error TS2304: Cannot find name 'B'. -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts(1,32): error TS2304: Cannot find name 'implements'. -==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts (6 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts (3 errors) ==== class C extends A implements B implements C { ~~~~~~~~~~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1175: 'implements' clause already seen. ~ !!! error TS2304: Cannot find name 'A'. ~ !!! error TS2304: Cannot find name 'B'. - ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'implements'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserClassDeclaration6.errors.txt b/tests/baselines/reference/parserClassDeclaration6.errors.txt index 3898f34cd7f..af0139d4fe1 100644 --- a/tests/baselines/reference/parserClassDeclaration6.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration6.errors.txt @@ -1,17 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration6.ts(1,18): error TS1005: '{' expected. -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration6.ts(1,22): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration6.ts(1,20): error TS1174: Classes can only extend a single class. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration6.ts(1,17): error TS2304: Cannot find name 'A'. -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration6.ts(1,20): error TS2304: Cannot find name 'B'. -==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration6.ts (4 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration6.ts (2 errors) ==== class C extends A, B { - ~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. + ~ +!!! error TS1174: Classes can only extend a single class. ~ !!! error TS2304: Cannot find name 'A'. - ~ -!!! error TS2304: Cannot find name 'B'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause1.errors.txt b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause1.errors.txt index 1e484aff5c0..299143e84c9 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause1.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause1.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause1.ts(1,17): error TS1003: Identifier expected. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause1.ts(1,16): error TS1097: 'extends' list cannot be empty. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause1.ts (1 errors) ==== class C extends { - ~ -!!! error TS1003: Identifier expected. + +!!! error TS1097: 'extends' list cannot be empty. } \ No newline at end of file diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.errors.txt b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.errors.txt index f70f239ac6f..9e4d8b76d75 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause2.ts(1,18): error TS1005: '{' expected. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause2.ts(1,18): error TS1009: Trailing comma not allowed. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause2.ts(1,17): error TS2304: Cannot find name 'A'. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause2.ts (2 errors) ==== class C extends A, { ~ -!!! error TS1005: '{' expected. +!!! error TS1009: Trailing comma not allowed. ~ !!! error TS2304: Cannot find name 'A'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause3.errors.txt b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause3.errors.txt index 8eedcc53f1d..c259e1804f8 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause3.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause3.errors.txt @@ -1,17 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause3.ts(1,28): error TS1005: '{' expected. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause3.ts(1,30): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause3.ts(1,17): error TS2304: Cannot find name 'implements'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause3.ts(1,16): error TS1097: 'extends' list cannot be empty. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause3.ts(1,28): error TS2304: Cannot find name 'A'. -==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause3.ts (4 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause3.ts (2 errors) ==== class C extends implements A { - ~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. - ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'implements'. + +!!! error TS1097: 'extends' list cannot be empty. ~ !!! error TS2304: Cannot find name 'A'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.errors.txt b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.errors.txt index b95f08f2264..7ffab4742f3 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.errors.txt @@ -1,20 +1,17 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts(1,18): error TS1005: '{' expected. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts(1,31): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts(1,18): error TS1009: Trailing comma not allowed. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts(1,32): error TS1009: Trailing comma not allowed. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts(1,17): error TS2304: Cannot find name 'A'. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts(1,20): error TS2304: Cannot find name 'implements'. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts(1,31): error TS2304: Cannot find name 'B'. -==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts (5 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts (4 errors) ==== class C extends A, implements B, { ~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1009: Trailing comma not allowed. + ~ +!!! error TS1009: Trailing comma not allowed. ~ !!! error TS2304: Cannot find name 'A'. - ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'implements'. ~ !!! error TS2304: Cannot find name 'B'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserInterfaceDeclaration1.errors.txt b/tests/baselines/reference/parserInterfaceDeclaration1.errors.txt index 0e1dbdb58dc..8c8f317b11a 100644 --- a/tests/baselines/reference/parserInterfaceDeclaration1.errors.txt +++ b/tests/baselines/reference/parserInterfaceDeclaration1.errors.txt @@ -1,17 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration1.ts(1,23): error TS1005: '{' expected. -tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration1.ts(1,33): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration1.ts(1,23): error TS1172: 'extends' clause already seen. tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration1.ts(1,21): error TS2304: Cannot find name 'A'. -tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration1.ts(1,31): error TS2304: Cannot find name 'B'. -==== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration1.ts (4 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration1.ts (2 errors) ==== interface I extends A extends B { ~~~~~~~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. +!!! error TS1172: 'extends' clause already seen. ~ !!! error TS2304: Cannot find name 'A'. - ~ -!!! error TS2304: Cannot find name 'B'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserInterfaceDeclaration2.errors.txt b/tests/baselines/reference/parserInterfaceDeclaration2.errors.txt index 7b917b3be8c..9080fac53d2 100644 --- a/tests/baselines/reference/parserInterfaceDeclaration2.errors.txt +++ b/tests/baselines/reference/parserInterfaceDeclaration2.errors.txt @@ -1,20 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration2.ts(1,13): error TS1005: '{' expected. -tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration2.ts(1,24): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration2.ts(1,26): error TS1005: ';' expected. -tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration2.ts(1,13): error TS2304: Cannot find name 'implements'. -tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration2.ts(1,24): error TS2304: Cannot find name 'A'. +tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration2.ts(1,13): error TS1176: Interface declaration cannot have 'implements' clause. -==== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration2.ts (5 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration2.ts (1 errors) ==== interface I implements A { ~~~~~~~~~~ -!!! error TS1005: '{' expected. - ~ -!!! error TS1005: ';' expected. - ~ -!!! error TS1005: ';' expected. - ~~~~~~~~~~ -!!! error TS2304: Cannot find name 'implements'. - ~ -!!! error TS2304: Cannot find name 'A'. +!!! error TS1176: Interface declaration cannot have 'implements' clause. } \ No newline at end of file diff --git a/tests/baselines/reference/parserObjectCreationArrayLiteral1.errors.txt b/tests/baselines/reference/parserObjectCreationArrayLiteral1.errors.txt index f0ca8d45b7a..04be3a6d041 100644 --- a/tests/baselines/reference/parserObjectCreationArrayLiteral1.errors.txt +++ b/tests/baselines/reference/parserObjectCreationArrayLiteral1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral1.ts(1,1): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral1.ts(1,8): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral1.ts(1,5): error TS2304: Cannot find name 'Foo'. ==== tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral1.ts (2 errors) ==== new Foo[]; - ~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~ !!! error TS2304: Cannot find name 'Foo'. \ No newline at end of file diff --git a/tests/baselines/reference/parserObjectCreationArrayLiteral3.errors.txt b/tests/baselines/reference/parserObjectCreationArrayLiteral3.errors.txt index 3187d985cc2..89f861cfcdb 100644 --- a/tests/baselines/reference/parserObjectCreationArrayLiteral3.errors.txt +++ b/tests/baselines/reference/parserObjectCreationArrayLiteral3.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral3.ts(1,1): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral3.ts(1,8): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral3.ts(1,5): error TS2304: Cannot find name 'Foo'. ==== tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral3.ts (2 errors) ==== new Foo[](); - ~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~ !!! error TS2304: Cannot find name 'Foo'. \ No newline at end of file diff --git a/tests/baselines/reference/parserRealSource10.errors.txt b/tests/baselines/reference/parserRealSource10.errors.txt index 4184d9ac23e..aabafd751e7 100644 --- a/tests/baselines/reference/parserRealSource10.errors.txt +++ b/tests/baselines/reference/parserRealSource10.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(4,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. -tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(127,29): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(128,32): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(129,37): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(130,31): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(449,31): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(127,42): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(128,42): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(129,47): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(130,42): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(449,40): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(128,36): error TS2304: Cannot find name 'string'. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(129,41): error TS2304: Cannot find name 'number'. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(130,35): error TS2304: Cannot find name 'boolean'. @@ -472,20 +472,20 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(356,53): error } export var tokenTable = new TokenInfo[]; - ~~~~~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. export var nodeTypeTable = new string[]; - ~~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~ !!! error TS2304: Cannot find name 'string'. export var nodeTypeToTokTable = new number[]; - ~~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~ !!! error TS2304: Cannot find name 'number'. export var noRegexTable = new boolean[]; - ~~~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~~ !!! error TS2304: Cannot find name 'boolean'. @@ -1474,7 +1474,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(356,53): error // TODO: new with length TokenID.LimFixed export var staticTokens = new Token[]; - ~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. export function initializeStaticTokens() { for (var i = 0; i <= TokenID.LimFixed; i++) { diff --git a/tests/baselines/reference/parserRealSource11.errors.txt b/tests/baselines/reference/parserRealSource11.errors.txt index c76206b821f..966da980097 100644 --- a/tests/baselines/reference/parserRealSource11.errors.txt +++ b/tests/baselines/reference/parserRealSource11.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(4,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(193,33): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(193,40): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(867,29): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1009,31): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1024,33): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1009,45): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1024,47): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(13,22): error TS2304: Cannot find name 'Type'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(14,24): error TS2304: Cannot find name 'ASTFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(17,38): error TS2304: Cannot find name 'CompilerDiagnostics'. @@ -793,7 +793,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error ~~~~~~~~~~~ !!! error TS2304: Cannot find name 'SymbolScope'. public members: AST[] = new AST[]; - ~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. constructor () { @@ -2029,7 +2029,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error !!! error TS2304: Cannot find name 'Symbol'. if (this.envids == null) { this.envids = new Identifier[]; - ~~~~~~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. } this.envids[this.envids.length] = id; @@ -2048,7 +2048,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error !!! error TS2304: Cannot find name 'Symbol'. if (this.jumpRefs == null) { this.jumpRefs = new Identifier[]; - ~~~~~~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. } var id = new Identifier(sym.name); diff --git a/tests/baselines/reference/parserRealSource4.errors.txt b/tests/baselines/reference/parserRealSource4.errors.txt index 5974d62df47..e0ae0d2221e 100644 --- a/tests/baselines/reference/parserRealSource4.errors.txt +++ b/tests/baselines/reference/parserRealSource4.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource4.ts(4,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. -tests/cases/conformance/parser/ecmascript5/parserRealSource4.ts(195,24): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/conformance/parser/ecmascript5/parserRealSource4.ts(195,37): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ==== tests/cases/conformance/parser/ecmascript5/parserRealSource4.ts (2 errors) ==== @@ -200,7 +200,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource4.ts(195,24): error T export class HashTable { public itemCount: number = 0; public table = new HashEntry[]; - ~~~~~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. constructor (public size: number, public hashFn: (key) =>number, diff --git a/tests/baselines/reference/parserRealSource7.errors.txt b/tests/baselines/reference/parserRealSource7.errors.txt index 773dd499425..7fddac2c467 100644 --- a/tests/baselines/reference/parserRealSource7.errors.txt +++ b/tests/baselines/reference/parserRealSource7.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(4,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. -tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(16,33): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(16,45): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(12,38): error TS2304: Cannot find name 'ASTList'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(12,62): error TS2304: Cannot find name 'TypeLink'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(16,37): error TS2304: Cannot find name 'TypeLink'. @@ -326,7 +326,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error T var len = bases.members.length; if (baseTypeLinks == null) { baseTypeLinks = new TypeLink[]; - ~~~~~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~~~ !!! error TS2304: Cannot find name 'TypeLink'. diff --git a/tests/baselines/reference/parserRealSource9.errors.txt b/tests/baselines/reference/parserRealSource9.errors.txt index 0dc0de6c12c..1880a72f189 100644 --- a/tests/baselines/reference/parserRealSource9.errors.txt +++ b/tests/baselines/reference/parserRealSource9.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(4,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. -tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(12,31): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(12,39): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(8,38): error TS2304: Cannot find name 'TypeChecker'. tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(9,48): error TS2304: Cannot find name 'TypeLink'. tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(9,67): error TS2304: Cannot find name 'SymbolScope'. @@ -56,7 +56,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(200,48): error T !!! error TS2304: Cannot find name 'Type'. if (typeLinks) { extendsList = new Type[]; - ~~~~~~~~~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~ !!! error TS2304: Cannot find name 'Type'. diff --git a/tests/baselines/reference/superWithTypeArgument.errors.txt b/tests/baselines/reference/superWithTypeArgument.errors.txt index 6cbfc250174..b399d5bd03d 100644 --- a/tests/baselines/reference/superWithTypeArgument.errors.txt +++ b/tests/baselines/reference/superWithTypeArgument.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/superWithTypeArgument.ts(7,14): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superWithTypeArgument.ts(7,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/superWithTypeArgument.ts(6,5): error TS2377: Constructors for derived classes must contain a 'super' call. ==== tests/cases/compiler/superWithTypeArgument.ts (2 errors) ==== @@ -9,10 +9,12 @@ tests/cases/compiler/superWithTypeArgument.ts(7,9): error TS2346: Supplied param class D extends C { constructor() { + ~~~~~~~~~~~~~~~ super(); ~ !!! error TS1034: 'super' must be followed by an argument list or member access. - ~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. + ~~~~~~~~~~~~~~~~~~~ } + ~~~~~ +!!! error TS2377: Constructors for derived classes must contain a 'super' call. } \ No newline at end of file diff --git a/tests/baselines/reference/superWithTypeArgument2.errors.txt b/tests/baselines/reference/superWithTypeArgument2.errors.txt index acf29177e8f..6ef9a302666 100644 --- a/tests/baselines/reference/superWithTypeArgument2.errors.txt +++ b/tests/baselines/reference/superWithTypeArgument2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/superWithTypeArgument2.ts(7,14): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superWithTypeArgument2.ts(7,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/superWithTypeArgument2.ts(6,5): error TS2377: Constructors for derived classes must contain a 'super' call. ==== tests/cases/compiler/superWithTypeArgument2.ts (2 errors) ==== @@ -9,10 +9,12 @@ tests/cases/compiler/superWithTypeArgument2.ts(7,9): error TS2346: Supplied para class D extends C { constructor(x) { + ~~~~~~~~~~~~~~~~ super(x); ~ !!! error TS1034: 'super' must be followed by an argument list or member access. - ~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. + ~~~~~~~~~~~~~~~~~~~~ } + ~~~~~ +!!! error TS2377: Constructors for derived classes must contain a 'super' call. } \ No newline at end of file diff --git a/tests/baselines/reference/superWithTypeArgument3.errors.txt b/tests/baselines/reference/superWithTypeArgument3.errors.txt index d3bb986bd8a..db8e2962227 100644 --- a/tests/baselines/reference/superWithTypeArgument3.errors.txt +++ b/tests/baselines/reference/superWithTypeArgument3.errors.txt @@ -1,7 +1,8 @@ tests/cases/compiler/superWithTypeArgument3.ts(8,14): error TS1034: 'super' must be followed by an argument list or member access. +tests/cases/compiler/superWithTypeArgument3.ts(7,5): error TS2377: Constructors for derived classes must contain a 'super' call. -==== tests/cases/compiler/superWithTypeArgument3.ts (1 errors) ==== +==== tests/cases/compiler/superWithTypeArgument3.ts (2 errors) ==== class C { foo: T; bar(x: U) { } @@ -9,10 +10,14 @@ tests/cases/compiler/superWithTypeArgument3.ts(8,14): error TS1034: 'super' must class D extends C { constructor() { + ~~~~~~~~~~~~~~~ super(); ~ !!! error TS1034: 'super' must be followed by an argument list or member access. + ~~~~~~~~~~~~~~~~~~~ } + ~~~~~ +!!! error TS2377: Constructors for derived classes must contain a 'super' call. bar() { super.bar(null); } diff --git a/tests/baselines/reference/thisInInvalidContexts.errors.txt b/tests/baselines/reference/thisInInvalidContexts.errors.txt index df4c946fa1b..3490e7bd80a 100644 --- a/tests/baselines/reference/thisInInvalidContexts.errors.txt +++ b/tests/baselines/reference/thisInInvalidContexts.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(38,25): error TS1003: Identifier expected. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(38,25): error TS1133: Type reference expected. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(38,30): error TS1005: ';' expected. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(3,16): error TS2334: 'this' cannot be referenced in a static property initializer. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(22,15): error TS2332: 'this' cannot be referenced in current location. @@ -53,7 +53,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): class ErrClass3 extends this { ~~~~ -!!! error TS1003: Identifier expected. +!!! error TS1133: Type reference expected. ~ !!! error TS1005: ';' expected. diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt index 4cbfad2caf9..46d24e035c2 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS1003: Identifier expected. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS1133: Type reference expected. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,30): error TS1005: ';' expected. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(48,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(48,10): error TS1003: Identifier expected. @@ -55,7 +55,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod class ErrClass3 extends this { ~~~~ -!!! error TS1003: Identifier expected. +!!! error TS1133: Type reference expected. ~ !!! error TS1005: ';' expected. diff --git a/tests/cases/fourslash/completionListInExtendsClause.ts b/tests/cases/fourslash/completionListInExtendsClause.ts index 97ebc51701c..ee2acc6a12c 100644 --- a/tests/cases/fourslash/completionListInExtendsClause.ts +++ b/tests/cases/fourslash/completionListInExtendsClause.ts @@ -27,6 +27,5 @@ verify.completionListIsEmpty(); goTo.marker("3"); verify.completionListIsEmpty(); -// This needs comletion list filtering based on location to work goTo.marker("4"); -verify.not.completionListIsEmpty(); \ No newline at end of file +verify.completionListIsEmpty(); \ No newline at end of file