diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 42bcd8ac610..eaad8593eee 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -88,6 +88,12 @@ namespace ts { let container: Node; let blockScopeContainer: Node; let lastContainer: Node; + + // If this file is an external module, then it is automatically in strict-mode according to + // ES6. If it is not an external module, then we'll determine if it is in strict mode or + // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). + let inStrictMode = !!file.externalModuleIndicator; + let symbolCount = 0; let Symbol = objectAllocator.getSymbolConstructor(); let classifiableNames: Map = {}; @@ -531,6 +537,51 @@ namespace ts { typeLiteralSymbol.members = { [symbol.name]: symbol }; } + function bindObjectLiteralExpression(node: ObjectLiteralExpression) { + const enum ElementKind { + Property = 1, + Accessor = 2 + } + + if (inStrictMode) { + let seen: Map = {}; + + for (let prop of node.properties) { + if (prop.name.kind !== SyntaxKind.Identifier) { + continue; + } + + let identifier = prop.name; + + // ECMA-262 11.1.5 Object Initialiser + // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true + // a.This production is contained in strict code and IsDataDescriptor(previous) is true and + // IsDataDescriptor(propId.descriptor) is true. + // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. + // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. + // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true + // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields + let currentKind = prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment || prop.kind === SyntaxKind.MethodDeclaration + ? ElementKind.Property + : ElementKind.Accessor; + + let existingKind = seen[identifier.text]; + if (!existingKind) { + seen[identifier.text] = currentKind; + continue; + } + + if (currentKind === ElementKind.Property && existingKind === ElementKind.Property) { + let span = getErrorSpanForNode(file, identifier); + file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, + Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); + } + } + } + + return bindAnonymousDeclaration(node, SymbolFlags.ObjectLiteral, "__object"); + } + function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string) { let symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); @@ -563,20 +614,135 @@ namespace ts { // The binder visits every node in the syntax tree so it is a convenient place to perform a single localized // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node: Identifier) { - if (node.parserContextFlags & ParserContextFlags.StrictMode && + if (inStrictMode && node.originalKeywordKind >= SyntaxKind.FirstFutureReservedWord && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord && !isIdentifierName(node)) { + // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { - let message = getAncestor(node, SyntaxKind.ClassDeclaration) || getAncestor(node, SyntaxKind.ClassExpression) ? - Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode : - Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; - file.bindDiagnostics.push(createDiagnosticForNode(node, message, declarationNameToString(node))); + file.bindDiagnostics.push(createDiagnosticForNode(node, + getStrictModeIdentifierMessage(node), declarationNameToString(node))); } } } + function getStrictModeIdentifierMessage(node: Node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (getAncestor(node, SyntaxKind.ClassDeclaration) || getAncestor(node, SyntaxKind.ClassExpression)) { + return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; + } + + if (file.externalModuleIndicator) { + return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; + } + + return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; + } + + function checkStrictModeBinaryExpression(node: BinaryExpression) { + if (inStrictMode && isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operatorToken.kind)) { + // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) + checkStrictModeEvalOrArguments(node, node.left); + } + } + + function checkStrictModeCatchClause(node: CatchClause) { + // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the + // Catch production is eval or arguments + if (inStrictMode && node.variableDeclaration) { + checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); + } + } + + function checkStrictModeDeleteExpression(node: DeleteExpression) { + // Grammar checking + if (inStrictMode && 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 + let span = getErrorSpanForNode(file, node.expression); + file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); + } + } + + function isEvalOrArgumentsIdentifier(node: Node): boolean { + return node.kind === SyntaxKind.Identifier && + ((node).text === "eval" || (node).text === "arguments"); + } + + function checkStrictModeEvalOrArguments(contextNode: Node, name: Node) { + if (name && name.kind === SyntaxKind.Identifier) { + let identifier = name; + if (isEvalOrArgumentsIdentifier(identifier)) { + // We check first if the name is inside class declaration or class expression; if so give explicit message + // otherwise report generic error message. + let span = getErrorSpanForNode(file, name); + file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, + getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); + } + } + } + + function getStrictModeEvalOrArgumentsMessage(node: Node) { + // Provide specialized messages to help the user understand why we think they're in + // strict mode. + if (getAncestor(node, SyntaxKind.ClassDeclaration) || getAncestor(node, SyntaxKind.ClassExpression)) { + return Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + } + + if (file.externalModuleIndicator) { + return Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; + } + + return Diagnostics.Invalid_use_of_0_in_strict_mode; + } + + function checkStrictModeFunctionName(node: FunctionLikeDeclaration) { + if (inStrictMode) { + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)) + checkStrictModeEvalOrArguments(node, node.name); + } + } + + function checkStrictModeNumericLiteral(node: LiteralExpression) { + if (inStrictMode && node.flags & NodeFlags.OctalLiteral) { + file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + } + + function checkStrictModePostfixUnaryExpression(node: PostfixUnaryExpression) { + // Grammar checking + // 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. + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + + function checkStrictModePrefixUnaryExpression(node: PrefixUnaryExpression) { + // Grammar checking + if (inStrictMode) { + if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) { + checkStrictModeEvalOrArguments(node, node.operand); + } + } + } + + function checkStrictModeWithStatement(node: WithStatement) { + // Grammar checking for withStatement + if (inStrictMode) { + grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + } + + function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any) { + let span = getSpanOfTokenAtPosition(file, node.pos); + file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); + } + function getDestructuringParameterName(node: Declaration) { return "__" + indexOf((node.parent).parameters, node); } @@ -584,6 +750,11 @@ namespace ts { function bind(node: Node) { node.parent = parent; + var savedInStrictMode = inStrictMode; + if (!savedInStrictMode) { + updateStrictMode(node); + } + // First we bind declaration nodes to a symbol if possible. We'll both create a symbol // and then potentially add the symbol to an appropriate symbol table. Possible // destination symbol tables are: @@ -601,12 +772,70 @@ namespace ts { // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. bindChildren(node); + + inStrictMode = savedInStrictMode; + } + + function updateStrictMode(node: Node) { + switch (node.kind) { + case SyntaxKind.SourceFile: + case SyntaxKind.ModuleBlock: + updateStrictModeStatementList((node).statements); + return; + case SyntaxKind.Block: + if (isFunctionLike(node.parent)) { + updateStrictModeStatementList((node).statements); + } + return; + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + // All classes are automatically in strict mode in ES6. + inStrictMode = true; + return; + } + } + + function updateStrictModeStatementList(statements: NodeArray) { + for (let statement of statements) { + if (!isPrologueDirective(statement)) { + return; + } + + if (isUseStrictPrologueDirective(statement)) { + inStrictMode = true; + return; + } + } } + /// Should be called only on prologue directives (isPrologueDirective(node) should be true) + function isUseStrictPrologueDirective(node: ExpressionStatement): boolean { + let nodeText = getTextOfNodeFromSourceText(file.text, node.expression); + + // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the + // string to contain unicode escapes (as per ES5). + return nodeText === '"use strict"' || nodeText === "'use strict'"; + } + function bindWorker(node: Node) { switch (node.kind) { case SyntaxKind.Identifier: return checkStrictModeIdentifier(node); + case SyntaxKind.BinaryExpression: + return checkStrictModeBinaryExpression(node); + case SyntaxKind.CatchClause: + return checkStrictModeCatchClause(node); + case SyntaxKind.DeleteExpression: + return checkStrictModeDeleteExpression(node); + case SyntaxKind.NumericLiteral: + return checkStrictModeNumericLiteral(node); + case SyntaxKind.PostfixUnaryExpression: + return checkStrictModePostfixUnaryExpression(node); + case SyntaxKind.PrefixUnaryExpression: + return checkStrictModePrefixUnaryExpression(node); + case SyntaxKind.WithStatement: + return checkStrictModeWithStatement(node); + case SyntaxKind.TypeParameter: return declareSymbolAndAddToSymbolTable(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); case SyntaxKind.Parameter: @@ -635,6 +864,7 @@ namespace ts { return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Method | ((node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes); case SyntaxKind.FunctionDeclaration: + checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes); case SyntaxKind.Constructor: return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Constructor, /*symbolExcludes:*/ SymbolFlags.None); @@ -648,9 +878,10 @@ namespace ts { case SyntaxKind.TypeLiteral: return bindAnonymousDeclaration(node, SymbolFlags.TypeLiteral, "__type"); case SyntaxKind.ObjectLiteralExpression: - return bindAnonymousDeclaration(node, SymbolFlags.ObjectLiteral, "__object"); + return bindObjectLiteralExpression(node); case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: + checkStrictModeFunctionName(node); return bindAnonymousDeclaration(node, SymbolFlags.Function, "__function"); case SyntaxKind.ClassExpression: case SyntaxKind.ClassDeclaration: @@ -756,6 +987,10 @@ namespace ts { } function bindVariableDeclarationOrBindingElement(node: VariableDeclaration | BindingElement) { + if (inStrictMode) { + checkStrictModeEvalOrArguments(node, node.name) + } + if (!isBindingPattern(node.name)) { if (isBlockOrCatchScoped(node)) { bindBlockScopedVariableDeclaration(node); @@ -779,6 +1014,12 @@ namespace ts { } function bindParameter(node: ParameterDeclaration) { + if (inStrictMode) { + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a + // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) + checkStrictModeEvalOrArguments(node, node.name); + } + if (isBindingPattern(node.name)) { bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node)); } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4ffa0a81d95..242793c8b6b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2600,56 +2600,126 @@ namespace ts { return concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } + function isConstructorType(type: Type): boolean { + return type.flags & TypeFlags.ObjectType && getSignaturesOfType(type, SignatureKind.Construct).length > 0; + } + + function getBaseTypeNodeOfClass(type: InterfaceType): ExpressionWithTypeArguments { + return getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + } + + function getConstructorsForTypeArguments(type: ObjectType, typeArgumentNodes: TypeNode[]): Signature[] { + let typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + return filter(getSignaturesOfType(type, SignatureKind.Construct), + sig => (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount); + } + + function getInstantiatedConstructorsForTypeArguments(type: ObjectType, typeArgumentNodes: TypeNode[]): Signature[] { + let signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + if (typeArgumentNodes) { + let typeArguments = map(typeArgumentNodes, getTypeFromTypeNode); + signatures = map(signatures, sig => getSignatureInstantiation(sig, typeArguments)); + } + return signatures; + } + + // The base constructor of a class can resolve to + // undefinedType if the class has no extends clause, + // unknownType if an error occurred during resolution of the extends expression, + // nullType if the extends expression is the null value, or + // an object type with at least one construct signature. + function getBaseConstructorTypeOfClass(type: InterfaceType): ObjectType { + if (!type.resolvedBaseConstructorType) { + let baseTypeNode = getBaseTypeNodeOfClass(type); + if (!baseTypeNode) { + return type.resolvedBaseConstructorType = undefinedType; + } + if (!pushTypeResolution(type)) { + return unknownType; + } + let baseConstructorType = checkExpression(baseTypeNode.expression); + if (baseConstructorType.flags & TypeFlags.ObjectType) { + // Force resolution of members such that we catch circularities + resolveObjectOrUnionTypeMembers(baseConstructorType); + } + if (!popTypeResolution()) { + error(type.symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); + return type.resolvedBaseConstructorType = unknownType; + } + if (baseConstructorType !== unknownType && baseConstructorType !== nullType && !isConstructorType(baseConstructorType)) { + error(baseTypeNode.expression, Diagnostics.Base_expression_is_not_of_a_constructor_function_type); + return type.resolvedBaseConstructorType = unknownType; + } + type.resolvedBaseConstructorType = baseConstructorType; + } + return type.resolvedBaseConstructorType; + } + function getBaseTypes(type: InterfaceType): ObjectType[] { - let typeWithBaseTypes = type; - if (!typeWithBaseTypes.baseTypes) { + if (!type.resolvedBaseTypes) { if (type.symbol.flags & SymbolFlags.Class) { - resolveBaseTypesOfClass(typeWithBaseTypes); + resolveBaseTypesOfClass(type); } else if (type.symbol.flags & SymbolFlags.Interface) { - resolveBaseTypesOfInterface(typeWithBaseTypes); + resolveBaseTypesOfInterface(type); } else { Debug.fail("type must be class or interface"); } } - - return typeWithBaseTypes.baseTypes; + return type.resolvedBaseTypes; } - function resolveBaseTypesOfClass(type: InterfaceTypeWithBaseTypes): void { - type.baseTypes = []; - let declaration = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); - let baseTypeNode = getClassExtendsHeritageClauseElement(declaration); - if (baseTypeNode) { - let baseType = getTypeFromTypeNode(baseTypeNode); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & TypeFlags.Class) { - if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); - } - else { - error(declaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType)); - } - } - else { - error(baseTypeNode, Diagnostics.A_class_may_only_extend_another_class); - } - } + function resolveBaseTypesOfClass(type: InterfaceType): void { + type.resolvedBaseTypes = emptyArray; + let baseContructorType = getBaseConstructorTypeOfClass(type); + if (!(baseContructorType.flags & TypeFlags.ObjectType)) { + return; } + let baseTypeNode = getBaseTypeNodeOfClass(type); + let baseType: Type; + if (baseContructorType.symbol && baseContructorType.symbol.flags & SymbolFlags.Class) { + // When base constructor type is a class we know that the constructors all have the same type parameters as the + // class and all return the instance type of the class. There is no need for further checks and we can apply the + // type arguments in the same manner as a type reference to get the same error reporting experience. + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseContructorType.symbol); + } + else { + // The class derives from a "class-like" constructor function, check that we have at least one construct signature + // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere + // we check that all instantiated signatures return the same type. + let constructors = getInstantiatedConstructorsForTypeArguments(baseContructorType, baseTypeNode.typeArguments); + if (!constructors.length) { + error(baseTypeNode.expression, Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); + return; + } + baseType = getReturnTypeOfSignature(constructors[0]); + } + if (baseType === unknownType) { + return; + } + if (!(getTargetType(baseType).flags & (TypeFlags.Class | TypeFlags.Interface))) { + error(baseTypeNode.expression, Diagnostics.Base_constructor_does_not_return_a_class_or_interface_type); + return; + } + if (type === baseType || hasBaseType(baseType, type)) { + error(type.symbol.valueDeclaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, + typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType)); + return; + } + type.resolvedBaseTypes = [baseType]; } - function resolveBaseTypesOfInterface(type: InterfaceTypeWithBaseTypes): void { - type.baseTypes = []; + function resolveBaseTypesOfInterface(type: InterfaceType): void { + type.resolvedBaseTypes = []; for (let declaration of type.symbol.declarations) { if (declaration.kind === SyntaxKind.InterfaceDeclaration && getInterfaceBaseTypeNodes(declaration)) { for (let node of getInterfaceBaseTypeNodes(declaration)) { let baseType = getTypeFromTypeNode(node); - if (baseType !== unknownType) { if (getTargetType(baseType).flags & (TypeFlags.Class | TypeFlags.Interface)) { if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); + type.resolvedBaseTypes.push(baseType); } else { error(declaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType)); @@ -2868,19 +2938,25 @@ namespace ts { } function getDefaultConstructSignatures(classType: InterfaceType): Signature[] { - let baseTypes = getBaseTypes(classType); - if (baseTypes.length) { - let baseType = baseTypes[0]; - let baseSignatures = getSignaturesOfType(getTypeOfSymbol(baseType.symbol), SignatureKind.Construct); - return map(baseSignatures, baseSignature => { - let signature = baseType.flags & TypeFlags.Reference ? - getSignatureInstantiation(baseSignature, (baseType).typeArguments) : cloneSignature(baseSignature); - signature.typeParameters = classType.localTypeParameters; - signature.resolvedReturnType = classType; - return signature; - }); + if (!getBaseTypes(classType).length) { + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; } - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; + let baseConstructorType = getBaseConstructorTypeOfClass(classType); + let baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct); + let baseTypeNode = getBaseTypeNodeOfClass(classType); + let typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode); + let typeArgCount = typeArguments ? typeArguments.length : 0; + let result: Signature[] = []; + for (let baseSig of baseSignatures) { + let typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; + if (typeParamCount === typeArgCount) { + let sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + sig.typeParameters = classType.localTypeParameters; + sig.resolvedReturnType = classType; + result.push(sig); + } + } + return result; } function createTupleTypeMemberSymbols(memberTypes: Type[]): SymbolTable { @@ -2992,10 +3068,10 @@ namespace ts { if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } - let baseTypes = getBaseTypes(classType); - if (baseTypes.length) { + let baseConstructorType = getBaseConstructorTypeOfClass(classType); + if (baseConstructorType.flags & TypeFlags.ObjectType) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(baseTypes[0].symbol))); + addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } stringIndexType = undefined; @@ -4127,14 +4203,14 @@ namespace ts { return !node.typeParameters && node.parameters.length && !forEach(node.parameters, p => p.type); } - function getTypeWithoutConstructors(type: Type): Type { + function getTypeWithoutSignatures(type: Type): Type { if (type.flags & TypeFlags.ObjectType) { let resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.constructSignatures.length) { let result = createObjectType(TypeFlags.Anonymous, type.symbol); result.members = resolved.members; result.properties = resolved.properties; - result.callSignatures = resolved.callSignatures; + result.callSignatures = emptyArray; result.constructSignatures = emptyArray; type = result; } @@ -5881,15 +5957,11 @@ namespace ts { function checkSuperExpression(node: Node): Type { let isCallExpression = node.parent.kind === SyntaxKind.CallExpression && (node.parent).expression === node; - let enclosingClass = getAncestor(node, SyntaxKind.ClassDeclaration); - let baseClass: Type; - if (enclosingClass && getClassExtendsHeritageClauseElement(enclosingClass)) { - let classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); - let baseTypes = getBaseTypes(classType); - baseClass = baseTypes.length && baseTypes[0]; - } + let classDeclaration = getAncestor(node, SyntaxKind.ClassDeclaration); + let classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); + let baseClassType = classType && getBaseTypes(classType)[0]; - if (!baseClass) { + if (!baseClassType) { error(node, Diagnostics.super_can_only_be_referenced_in_a_derived_class); return unknownType; } @@ -5944,11 +6016,11 @@ namespace ts { if ((container.flags & NodeFlags.Static) || isCallExpression) { getNodeLinks(node).flags |= NodeCheckFlags.SuperStatic; - returnType = getTypeOfSymbol(baseClass.symbol); + returnType = getBaseConstructorTypeOfClass(classType); } else { getNodeLinks(node).flags |= NodeCheckFlags.SuperInstance; - returnType = baseClass; + returnType = baseClassType; } if (container.kind === SyntaxKind.Constructor && isInConstructorArgumentInitializer(node, container)) { @@ -7135,35 +7207,13 @@ namespace ts { return args; } - /** - * In a 'super' call, type arguments are not provided within the CallExpression node itself. - * Instead, they must be fetched from the class declaration's base type node. - * - * If 'node' is a 'super' call (e.g. super(...), new super(...)), then we attempt to fetch - * the type arguments off the containing class's first heritage clause (if one exists). Note that if - * type arguments are supplied on the 'super' call, they are ignored (though this is syntactically incorrect). - * - * In all other cases, the call's explicit type arguments are returned. - */ - function getEffectiveTypeArguments(callExpression: CallExpression): TypeNode[] { - if (callExpression.expression.kind === SyntaxKind.SuperKeyword) { - let containingClass = getAncestor(callExpression, SyntaxKind.ClassDeclaration); - let baseClassTypeNode = containingClass && getClassExtendsHeritageClauseElement(containingClass); - return baseClassTypeNode && baseClassTypeNode.typeArguments; - } - else { - // Ordinary case - simple function invocation. - return callExpression.typeArguments; - } - } - function resolveCall(node: CallLikeExpression, signatures: Signature[], candidatesOutArray: Signature[]): Signature { let isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression; let typeArguments: TypeNode[]; if (!isTaggedTemplate) { - typeArguments = getEffectiveTypeArguments(node); + typeArguments = (node).typeArguments; // We already perform checking on the type arguments on the class declaration itself. if ((node).expression.kind !== SyntaxKind.SuperKeyword) { @@ -7371,7 +7421,11 @@ namespace ts { if (node.expression.kind === SyntaxKind.SuperKeyword) { let superType = checkSuperExpression(node.expression); if (superType !== unknownType) { - return resolveCall(node, getSignaturesOfType(superType, SignatureKind.Construct), candidatesOutArray); + // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated + // with the type arguments specified in the extends clause. + let baseTypeNode = getClassExtendsHeritageClauseElement(getAncestor(node, SyntaxKind.ClassDeclaration)); + let baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); } return resolveUntypedCall(node); } @@ -7746,7 +7800,7 @@ namespace ts { // Grammar checking let hasGrammarError = checkGrammarFunctionLikeDeclaration(node); if (!hasGrammarError && node.kind === SyntaxKind.FunctionExpression) { - checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); + checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -7903,14 +7957,7 @@ namespace ts { } function checkDeleteExpression(node: DeleteExpression): Type { - // Grammar checking - 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 - grammarErrorOnNode(node.expression, Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } - - let operandType = checkExpression(node.expression); + checkExpression(node.expression); return booleanType; } @@ -7925,14 +7972,6 @@ namespace ts { } function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { - // Grammar checking - // 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 - if ((node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); - } - let operandType = checkExpression(node.operand); switch (node.operator) { case SyntaxKind.PlusToken: @@ -7959,12 +7998,6 @@ namespace ts { } function checkPostfixUnaryExpression(node: PostfixUnaryExpression): Type { - // Grammar checking - // 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. - checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); - let operandType = checkExpression(node.operand); let ok = checkArithmeticOperandType(node.operand, operandType, Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { @@ -8144,13 +8177,6 @@ namespace ts { } function checkBinaryExpression(node: BinaryExpression, contextualMapper?: TypeMapper) { - // Grammar checking - if (isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operatorToken.kind)) { - // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) - checkGrammarEvalOrArgumentsInStrictMode(node, node.left); - } - let operator = node.operatorToken.kind; if (operator === SyntaxKind.EqualsToken && (node.left.kind === SyntaxKind.ObjectLiteralExpression || node.left.kind === SyntaxKind.ArrayLiteralExpression)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); @@ -8592,11 +8618,9 @@ namespace ts { // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code // or if its FunctionBody is strict code(11.1.5). - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a - // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); let func = getContainingFunction(node); @@ -8958,32 +8982,25 @@ namespace ts { checkDecorators(node); } - function checkTypeReferenceNode(node: TypeReferenceNode) { - return checkTypeReferenceOrExpressionWithTypeArguments(node); + function checkTypeArgumentsAndConstraints(typeParameters: TypeParameter[], typeArguments: TypeNode[]) { + for (let i = 0; i < typeArguments.length; i++) { + let typeArgument = typeArguments[i]; + checkSourceElement(typeArgument); + let constraint = getConstraintOfTypeParameter(typeParameters[i]); + if (produceDiagnostics && constraint) { + checkTypeAssignableTo(getTypeFromTypeNode(typeArgument), constraint, typeArgument, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } + } } - function checkExpressionWithTypeArguments(node: ExpressionWithTypeArguments) { - return checkTypeReferenceOrExpressionWithTypeArguments(node); - } - - function checkTypeReferenceOrExpressionWithTypeArguments(node: TypeReferenceNode | ExpressionWithTypeArguments) { - // Grammar checking + function checkTypeReferenceNode(node: TypeReferenceNode | ExpressionWithTypeArguments) { checkGrammarTypeArguments(node, node.typeArguments); - let type = getTypeFromTypeReference(node); if (type !== unknownType && node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved let symbol = getNodeLinks(node).resolvedSymbol; let typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (type).target.localTypeParameters; - let len = node.typeArguments.length; - for (let i = 0; i < len; i++) { - checkSourceElement(node.typeArguments[i]); - let constraint = getConstraintOfTypeParameter(typeParameters[i]); - if (produceDiagnostics && constraint) { - let typeArgument = (type).typeArguments[i]; - checkTypeAssignableTo(typeArgument, constraint, node, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } - } + checkTypeArgumentsAndConstraints(typeParameters, node.typeArguments); } } @@ -9499,9 +9516,7 @@ namespace ts { function checkFunctionDeclaration(node: FunctionDeclaration): void { if (produceDiagnostics) { - checkFunctionLikeDeclaration(node) || - checkGrammarFunctionName(node.name) || - checkGrammarForGenerator(node); + checkFunctionLikeDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); @@ -10328,12 +10343,7 @@ namespace ts { } function checkWithStatement(node: WithStatement) { - // Grammar checking for withStatement - if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & ParserContextFlags.StrictMode) { - grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } + checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); error(node.expression, Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); @@ -10437,10 +10447,6 @@ namespace ts { grammarErrorOnNode(localSymbol.valueDeclaration, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); } } - - // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the - // Catch production is eval or arguments - checkGrammarEvalOrArgumentsInStrictMode(node, catchClause.variableDeclaration.name); } } @@ -10596,45 +10602,40 @@ namespace ts { let symbol = getSymbolOfNode(node); let type = getDeclaredTypeOfSymbol(symbol); let staticType = getTypeOfSymbol(symbol); + let baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (!isSupportedExpressionWithTypeArguments(baseTypeNode)) { - error(baseTypeNode.expression, Diagnostics.Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses); - } - emitExtends = emitExtends || !isInAmbientContext(node); - checkExpressionWithTypeArguments(baseTypeNode); - } - let baseTypes = getBaseTypes(type); - if (baseTypes.length) { - if (produceDiagnostics) { + let baseTypes = getBaseTypes(type); + if (baseTypes.length && produceDiagnostics) { let baseType = baseTypes[0]; - checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); - let staticBaseType = getTypeOfSymbol(baseType.symbol); - checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name || node, - Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - - if (baseType.symbol !== resolveEntityName(baseTypeNode.expression, SymbolFlags.Value)) { - error(baseTypeNode, Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); + let staticBaseType = getBaseConstructorTypeOfClass(type); + if (baseTypeNode.typeArguments) { + let constructors = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + checkTypeArgumentsAndConstraints(constructors[0].typeParameters, baseTypeNode.typeArguments); + } + checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, + Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class)) { + // When the static base type is a "class-like" constructor function (but not actually a class), we verify + // that all instantiated base constructor signatures return the same type. + let constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + if (forEach(constructors, sig => getReturnTypeOfSignature(sig) !== baseType)) { + error(baseTypeNode.expression, Diagnostics.Base_constructors_must_all_have_the_same_return_type); + } } - checkKindsOfPropertyMemberOverrides(type, baseType); } } - if (baseTypes.length || (baseTypeNode && compilerOptions.isolatedModules)) { - // Check that base type can be evaluated as expression - checkExpression(baseTypeNode.expression); - } - let implementedTypeNodes = getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { forEach(implementedTypeNodes, typeRefNode => { if (!isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } - - checkExpressionWithTypeArguments(typeRefNode); + checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { let t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { @@ -10834,8 +10835,7 @@ namespace ts { if (!isSupportedExpressionWithTypeArguments(heritageElement)) { error(heritageElement.expression, Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } - - checkExpressionWithTypeArguments(heritageElement); + checkTypeReferenceNode(heritageElement); }); forEach(node.members, checkSourceElement); @@ -12020,6 +12020,12 @@ namespace ts { return getTypeOfExpression(node); } + if (isClassExtendsExpressionWithTypeArguments(node)) { + // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the + // extends clause of a class. We handle that case here. + return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + } + if (isTypeDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration let symbol = getSymbolOfNode(node); @@ -13075,11 +13081,6 @@ namespace ts { } } - function checkGrammarFunctionName(name: Node) { - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)) - return checkGrammarEvalOrArgumentsInStrictMode(name, name); - } - function checkGrammarForInvalidQuestionMark(node: Declaration, questionToken: Node, message: DiagnosticMessage): boolean { if (questionToken) { return grammarErrorOnNode(questionToken, message); @@ -13092,7 +13093,6 @@ namespace ts { let GetAccessor = 2; let SetAccesor = 4; let GetOrSetAccessor = GetAccessor | SetAccesor; - let inStrictMode = (node.parserContextFlags & ParserContextFlags.StrictMode) !== 0; for (let prop of node.properties) { let name = prop.name; @@ -13139,9 +13139,7 @@ namespace ts { else { let existingKind = seen[(name).text]; if (currentKind === Property && existingKind === Property) { - if (inStrictMode) { - grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); - } + continue; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { @@ -13364,9 +13362,6 @@ namespace ts { return grammarErrorAtPos(getSourceFileOfNode(node), node.initializer.pos - 1, 1, Diagnostics.A_rest_element_cannot_have_an_initializer); } } - // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code - // and its Identifier is eval or arguments - return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarVariableDeclaration(node: VariableDeclaration) { @@ -13398,8 +13393,7 @@ namespace ts { // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code // and its Identifier is eval or arguments - return (checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name)) || - checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name: Identifier | BindingPattern): boolean { @@ -13538,26 +13532,6 @@ namespace ts { } } - function checkGrammarEvalOrArgumentsInStrictMode(contextNode: Node, name: Node): boolean { - if (name && name.kind === SyntaxKind.Identifier) { - let identifier = name; - if (contextNode && (contextNode.parserContextFlags & ParserContextFlags.StrictMode) && isEvalOrArgumentsIdentifier(identifier)) { - // We check first if the name is inside class declaration or class expression; if so give explicit message - // otherwise report generic error message. - - let message = getAncestor(identifier, SyntaxKind.ClassDeclaration) || getAncestor(identifier, SyntaxKind.ClassExpression) ? - Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode : - Diagnostics.Invalid_use_of_0_in_strict_mode; - return grammarErrorOnNode(identifier, message, declarationNameToString(identifier)); - } - } - } - - function isEvalOrArgumentsIdentifier(node: Node): boolean { - return node.kind === SyntaxKind.Identifier && - ((node).text === "eval" || (node).text === "arguments"); - } - function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) { if (node.typeParameters) { return grammarErrorAtPos(getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -13667,13 +13641,8 @@ namespace ts { function checkGrammarNumericLiteral(node: Identifier): boolean { // Grammar checking - if (node.flags & NodeFlags.OctalLiteral) { - if (node.parserContextFlags & ParserContextFlags.StrictMode) { - return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); - } - else if (languageVersion >= ScriptTarget.ES5) { - return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } + if (node.flags & NodeFlags.OctalLiteral && languageVersion >= ScriptTarget.ES5) { + return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index a65eba493ad..ba617d9cf3b 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -171,6 +171,8 @@ namespace ts { A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, @@ -386,8 +388,13 @@ namespace ts { Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, - Cannot_create_an_instance_of_the_abstract_class_0: { code: 2506, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'" }, - All_overload_signatures_must_match_with_respect_to_modifier_0: { code: 2507, category: DiagnosticCategory.Error, key: "All overload signatures must match with respect to modifier '{0}'." }, + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, + Base_expression_is_not_of_a_constructor_function_type: { code: 2507, category: DiagnosticCategory.Error, key: "Base expression is not of a constructor function type." }, + No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, + Base_constructor_does_not_return_a_class_or_interface_type: { code: 2509, category: DiagnosticCategory.Error, key: "Base constructor does not return a class or interface type." }, + Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'" }, + All_overload_signatures_must_match_with_respect_to_modifier_0: { code: 2512, category: DiagnosticCategory.Error, key: "All overload signatures must match with respect to modifier '{0}'." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c5291d2900d..91d1eafb998 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -671,6 +671,14 @@ "category": "Error", "code": 1213 }, + "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode.": { + "category": "Error", + "code": 1214 + }, + "Invalid use of '{0}'. Modules are automatically in strict mode.": { + "category": "Error", + "code": 1215 + }, "Export assignment is not supported when '--module' flag is 'system'.": { "category": "Error", "code": 1218 @@ -1531,14 +1539,34 @@ "category": "Error", "code": 2505 }, - "Cannot create an instance of the abstract class '{0}'": { + "'{0}' is referenced directly or indirectly in its own base expression.": { "category": "Error", "code": 2506 }, - "All overload signatures must match with respect to modifier '{0}'.": { + "Base expression is not of a constructor function type.": { "category": "Error", "code": 2507 }, + "No base constructor has the specified number of type arguments.": { + "category": "Error", + "code": 2508 + }, + "Base constructor does not return a class or interface type.": { + "category": "Error", + "code": 2509 + }, + "Base constructors must all have the same return type.": { + "category": "Error", + "code": 2510 + }, + "Cannot create an instance of the abstract class '{0}'": { + "category": "Error", + "code": 2511 + }, + "All overload signatures must match with respect to modifier '{0}'.": { + "category": "Error", + "code": 2512 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 4611b1d1657..79ba59b94b8 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -544,7 +544,7 @@ namespace ts { token = nextToken(); processReferenceComments(sourceFile); - sourceFile.statements = parseList(ParsingContext.SourceElements, /*checkForStrictMode*/ true, parseStatement); + sourceFile.statements = parseList(ParsingContext.SourceElements, parseStatement); Debug.assert(token === SyntaxKind.EndOfFileToken); sourceFile.endOfFileToken = parseTokenNode(); @@ -647,10 +647,6 @@ namespace ts { } } - function setStrictModeContext(val: boolean) { - setContextFlag(val, ParserContextFlags.StrictMode); - } - function setDisallowInContext(val: boolean) { setContextFlag(val, ParserContextFlags.DisallowIn); } @@ -744,10 +740,6 @@ namespace ts { return (contextFlags & ParserContextFlags.Yield) !== 0; } - function inStrictModeContext() { - return (contextFlags & ParserContextFlags.StrictMode) !== 0; - } - function inGeneratorParameterContext() { return (contextFlags & ParserContextFlags.GeneratorParameter) !== 0; } @@ -1328,31 +1320,17 @@ namespace ts { } // Parses a list of elements - function parseList(kind: ParsingContext, checkForStrictMode: boolean, parseElement: () => T): NodeArray { + function parseList(kind: ParsingContext, parseElement: () => T): NodeArray { let saveParsingContext = parsingContext; parsingContext |= 1 << kind; let result = >[]; result.pos = getNodePos(); - let savedStrictModeContext = inStrictModeContext(); while (!isListTerminator(kind)) { if (isListElement(kind, /* inErrorRecovery */ false)) { let element = parseListElement(kind, parseElement); result.push(element); - // test elements only if we are not already in strict mode - if (checkForStrictMode && !inStrictModeContext()) { - if (isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(element)) { - setStrictModeContext(true); - checkForStrictMode = false; - } - } - else { - checkForStrictMode = false; - } - } - continue; } @@ -1361,22 +1339,11 @@ namespace ts { } } - setStrictModeContext(savedStrictModeContext); result.end = getNodeEnd(); parsingContext = saveParsingContext; return result; } - /// Should be called only on prologue directives (isPrologueDirective(node) should be true) - function isUseStrictPrologueDirective(node: Node): boolean { - Debug.assert(isPrologueDirective(node)); - let nodeText = getTextOfNodeFromSourceText(sourceText, (node).expression); - - // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the - // string to contain unicode escapes (as per ES5). - return nodeText === '"use strict"' || nodeText === "'use strict'"; - } - function parseListElement(parsingContext: ParsingContext, parseElement: () => T): T { let node = currentNode(parsingContext); if (node) { @@ -2281,7 +2248,7 @@ namespace ts { function parseObjectTypeMembers(): NodeArray { let members: NodeArray; if (parseExpected(SyntaxKind.OpenBraceToken)) { - members = parseList(ParsingContext.TypeMembers, /*checkForStrictMode*/ false, parseTypeMember); + members = parseList(ParsingContext.TypeMembers, parseTypeMember); parseExpected(SyntaxKind.CloseBraceToken); } else { @@ -2650,12 +2617,6 @@ namespace ts { return true; } - if (inStrictModeContext()) { - // If we're in strict mode, then 'yield' is a keyword, could only ever start - // a yield expression. - return true; - } - // We're in a context where 'yield expr' is not allowed. However, if we can // definitely tell that the user was trying to parse a 'yield expr' and not // just a normal expr that start with a 'yield' identifier, then parse out @@ -2670,7 +2631,7 @@ namespace ts { // for now we just check if the next token is an identifier. More heuristics // can be added here later as necessary. We just need to make sure that we // don't accidently consume something legal. - return lookAhead(nextTokenIsIdentifierOnSameLine); + return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); } return false; @@ -3513,10 +3474,10 @@ namespace ts { } // STATEMENTS - function parseBlock(ignoreMissingOpenBrace: boolean, checkForStrictMode: boolean, diagnosticMessage?: DiagnosticMessage): Block { + function parseBlock(ignoreMissingOpenBrace: boolean, diagnosticMessage?: DiagnosticMessage): Block { let node = createNode(SyntaxKind.Block); if (parseExpected(SyntaxKind.OpenBraceToken, diagnosticMessage) || ignoreMissingOpenBrace) { - node.statements = parseList(ParsingContext.BlockStatements, checkForStrictMode, parseStatement); + node.statements = parseList(ParsingContext.BlockStatements, parseStatement); parseExpected(SyntaxKind.CloseBraceToken); } else { @@ -3536,7 +3497,7 @@ namespace ts { setDecoratorContext(false); } - let block = parseBlock(ignoreMissingOpenBrace, /*checkForStrictMode*/ true, diagnosticMessage); + let block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(true); @@ -3678,7 +3639,7 @@ namespace ts { parseExpected(SyntaxKind.CaseKeyword); node.expression = allowInAnd(parseExpression); parseExpected(SyntaxKind.ColonToken); - node.statements = parseList(ParsingContext.SwitchClauseStatements, /*checkForStrictMode*/ false, parseStatement); + node.statements = parseList(ParsingContext.SwitchClauseStatements, parseStatement); return finishNode(node); } @@ -3686,7 +3647,7 @@ namespace ts { let node = createNode(SyntaxKind.DefaultClause); parseExpected(SyntaxKind.DefaultKeyword); parseExpected(SyntaxKind.ColonToken); - node.statements = parseList(ParsingContext.SwitchClauseStatements, /*checkForStrictMode*/ false, parseStatement); + node.statements = parseList(ParsingContext.SwitchClauseStatements, parseStatement); return finishNode(node); } @@ -3702,7 +3663,7 @@ namespace ts { parseExpected(SyntaxKind.CloseParenToken); let caseBlock = createNode(SyntaxKind.CaseBlock, scanner.getStartPos()); parseExpected(SyntaxKind.OpenBraceToken); - caseBlock.clauses = parseList(ParsingContext.SwitchClauses, /*checkForStrictMode*/ false, parseCaseOrDefaultClause); + caseBlock.clauses = parseList(ParsingContext.SwitchClauses, parseCaseOrDefaultClause); parseExpected(SyntaxKind.CloseBraceToken); node.caseBlock = finishNode(caseBlock); return finishNode(node); @@ -3729,14 +3690,14 @@ namespace ts { let node = createNode(SyntaxKind.TryStatement); parseExpected(SyntaxKind.TryKeyword); - node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false, /*checkForStrictMode*/ false); + node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token === SyntaxKind.CatchKeyword ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. if (!node.catchClause || token === SyntaxKind.FinallyKeyword) { parseExpected(SyntaxKind.FinallyKeyword); - node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false, /*checkForStrictMode*/ false); + node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); @@ -3750,7 +3711,7 @@ namespace ts { } parseExpected(SyntaxKind.CloseParenToken); - result.block = parseBlock(/*ignoreMissingOpenBrace*/ false, /*checkForStrictMode*/ false); + result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } @@ -3791,6 +3752,11 @@ namespace ts { return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } + function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { + nextToken(); + return (isIdentifierOrKeyword() || token === SyntaxKind.NumericLiteral) && !scanner.hasPrecedingLineBreak(); + } + function isDeclaration(): boolean { while (true) { switch (token) { @@ -3919,16 +3885,15 @@ namespace ts { } } - function nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine() { + function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return !scanner.hasPrecedingLineBreak() && - (isIdentifier() || token === SyntaxKind.OpenBraceToken || token === SyntaxKind.OpenBracketToken); + return isIdentifier() || token === SyntaxKind.OpenBraceToken || token === SyntaxKind.OpenBracketToken; } function isLetDeclaration() { - // It is let declaration if in strict mode or next token is identifier\open bracket\open curly on same line. - // otherwise it needs to be treated like identifier - return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine); + // In ES6 'let' always starts a lexical declaration if followed by an identifier or { + // or [. + return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement(): Statement { @@ -3936,7 +3901,7 @@ namespace ts { case SyntaxKind.SemicolonToken: return parseEmptyStatement(); case SyntaxKind.OpenBraceToken: - return parseBlock(/*ignoreMissingOpenBrace*/ false, /*checkForStrictMode*/ false); + return parseBlock(/*ignoreMissingOpenBrace*/ false); case SyntaxKind.VarKeyword: return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); case SyntaxKind.LetKeyword: @@ -4455,10 +4420,6 @@ namespace ts { } function parseClassDeclarationOrExpression(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, kind: SyntaxKind): ClassLikeDeclaration { - // In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code - let savedStrictModeContext = inStrictModeContext(); - setStrictModeContext(true); - var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); @@ -4481,9 +4442,7 @@ namespace ts { node.members = createMissingList(); } - var finishedNode = finishNode(node); - setStrictModeContext(savedStrictModeContext); - return finishedNode; + return finishNode(node); } function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray { @@ -4501,7 +4460,7 @@ namespace ts { } function parseHeritageClausesWorker() { - return parseList(ParsingContext.HeritageClauses, /*checkForStrictMode*/ false, parseHeritageClause); + return parseList(ParsingContext.HeritageClauses, parseHeritageClause); } function parseHeritageClause() { @@ -4531,7 +4490,7 @@ namespace ts { } function parseClassMembers() { - return parseList(ParsingContext.ClassMembers, /*checkForStrictMode*/ false, parseClassElement); + return parseList(ParsingContext.ClassMembers, parseClassElement); } function parseInterfaceDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): InterfaceDeclaration { @@ -4589,7 +4548,7 @@ namespace ts { function parseModuleBlock(): ModuleBlock { let node = createNode(SyntaxKind.ModuleBlock, scanner.getStartPos()); if (parseExpected(SyntaxKind.OpenBraceToken)) { - node.statements = parseList(ParsingContext.BlockStatements, /*checkForStrictMode*/ false, parseStatement); + node.statements = parseList(ParsingContext.BlockStatements, parseStatement); parseExpected(SyntaxKind.CloseBraceToken); } else { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7d03b19483d..4c58f12b0ea 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -364,10 +364,6 @@ namespace ts { export const enum ParserContextFlags { None = 0, - // Set if this node was parsed in strict mode. Used for grammar error checks, as well as - // checking if the node can be reused in incremental settings. - StrictMode = 1 << 0, - // If this node was parsed in a context where 'in-expressions' are not allowed. DisallowIn = 1 << 1, @@ -390,7 +386,7 @@ namespace ts { JavaScriptFile = 1 << 6, // Context flags set directly by the parser. - ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError, + ParserGeneratedFlags = DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError, // Context flags computed by aggregating child flags upwards. @@ -1675,10 +1671,8 @@ namespace ts { typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic) outerTypeParameters: TypeParameter[]; // Outer type parameters (undefined if none) localTypeParameters: TypeParameter[]; // Local type parameters (undefined if none) - } - - export interface InterfaceTypeWithBaseTypes extends InterfaceType { - baseTypes: ObjectType[]; + resolvedBaseConstructorType?: Type; // Resolved base constructor type of class + resolvedBaseTypes: ObjectType[]; // Resolved base types } export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 09e02d63b54..86000b9f6ea 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -426,7 +426,7 @@ namespace ts { // Specialized signatures can have string literals as their parameters' type names return node.parent.kind === SyntaxKind.Parameter; case SyntaxKind.ExpressionWithTypeArguments: - return true; + return !isClassExtendsExpressionWithTypeArguments(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container @@ -460,7 +460,7 @@ namespace ts { } switch (parent.kind) { case SyntaxKind.ExpressionWithTypeArguments: - return true; + return !isClassExtendsExpressionWithTypeArguments(parent); case SyntaxKind.TypeParameter: return node === (parent).constraint; case SyntaxKind.PropertyDeclaration: @@ -872,7 +872,6 @@ namespace ts { while (node.parent.kind === SyntaxKind.QualifiedName) { node = node.parent; } - return node.parent.kind === SyntaxKind.TypeQuery; case SyntaxKind.Identifier: if (node.parent.kind === SyntaxKind.TypeQuery) { @@ -920,6 +919,8 @@ namespace ts { return node === (parent).expression; case SyntaxKind.Decorator: return true; + case SyntaxKind.ExpressionWithTypeArguments: + return isClassExtendsExpressionWithTypeArguments(parent); default: if (isExpression(parent)) { return true; @@ -1915,6 +1916,12 @@ namespace ts { return token >= SyntaxKind.FirstAssignment && token <= SyntaxKind.LastAssignment; } + export function isClassExtendsExpressionWithTypeArguments(node: Node): boolean { + return node.kind === SyntaxKind.ExpressionWithTypeArguments && + (node.parent).token === SyntaxKind.ExtendsKeyword && + node.parent.parent.kind === SyntaxKind.ClassDeclaration; + } + // Returns false if this heritage clause element's expression contains something unsupported // (i.e. not a name or dotted name). export function isSupportedExpressionWithTypeArguments(node: ExpressionWithTypeArguments): boolean { diff --git a/src/harness/typeWriter.ts b/src/harness/typeWriter.ts index 533f90a2d83..ac695fc23a4 100644 --- a/src/harness/typeWriter.ts +++ b/src/harness/typeWriter.ts @@ -41,7 +41,10 @@ class TypeWriterWalker { var lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos); var sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node); - var type = this.checker.getTypeAtLocation(node); + // Workaround to ensure we output 'C' instead of 'typeof C' for base class expressions + // var type = this.checker.getTypeAtLocation(node); + var type = node.parent && ts.isClassExtendsExpressionWithTypeArguments(node.parent) && this.checker.getTypeAtLocation(node.parent) || this.checker.getTypeAtLocation(node); + ts.Debug.assert(type !== undefined, "type doesn't exist"); var symbol = this.checker.getSymbolAtLocation(node); diff --git a/src/services/services.ts b/src/services/services.ts index 49afeb780bb..a8411ff1554 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -5813,7 +5813,8 @@ namespace ts { node = node.parent; } - return node.parent.kind === SyntaxKind.TypeReference || node.parent.kind === SyntaxKind.ExpressionWithTypeArguments; + return node.parent.kind === SyntaxKind.TypeReference || + (node.parent.kind === SyntaxKind.ExpressionWithTypeArguments && !isClassExtendsExpressionWithTypeArguments(node.parent)); } function isNamespaceReference(node: Node): boolean { diff --git a/tests/baselines/reference/VariableDeclaration11_es6.errors.txt b/tests/baselines/reference/VariableDeclaration11_es6.errors.txt index 8c0ef5f8690..d1e6ab7c154 100644 --- a/tests/baselines/reference/VariableDeclaration11_es6.errors.txt +++ b/tests/baselines/reference/VariableDeclaration11_es6.errors.txt @@ -1,8 +1,11 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts(2,4): error TS1123: Variable declaration list cannot be empty. +tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts(2,1): error TS1212: Identifier expected. 'let' is a reserved word in strict mode +tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts(2,1): error TS2304: Cannot find name 'let'. -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts (2 errors) ==== "use strict"; let - -!!! error TS1123: Variable declaration list cannot be empty. \ No newline at end of file + ~~~ +!!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode + ~~~ +!!! error TS2304: Cannot find name 'let'. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration11_es6.js b/tests/baselines/reference/VariableDeclaration11_es6.js index 83eec6d9a13..cf4c14617bc 100644 --- a/tests/baselines/reference/VariableDeclaration11_es6.js +++ b/tests/baselines/reference/VariableDeclaration11_es6.js @@ -4,4 +4,4 @@ let //// [VariableDeclaration11_es6.js] "use strict"; -let ; +let; diff --git a/tests/baselines/reference/YieldExpression18_es6.errors.txt b/tests/baselines/reference/YieldExpression18_es6.errors.txt index 056fc0e950a..5dd2807716f 100644 --- a/tests/baselines/reference/YieldExpression18_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression18_es6.errors.txt @@ -1,8 +1,14 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: A 'yield' expression is only allowed in a generator body. +tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1212: Identifier expected. 'yield' is a reserved word in strict mode +tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,7): error TS2304: Cannot find name 'foo'. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts (3 errors) ==== "use strict"; yield(foo); ~~~~~ -!!! error TS1163: A 'yield' expression is only allowed in a generator body. \ No newline at end of file +!!! error TS1212: Identifier expected. 'yield' is a reserved word in strict mode + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + ~~~ +!!! error TS2304: Cannot find name 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression18_es6.js b/tests/baselines/reference/YieldExpression18_es6.js index b4ba37d3ac4..36be3faabfe 100644 --- a/tests/baselines/reference/YieldExpression18_es6.js +++ b/tests/baselines/reference/YieldExpression18_es6.js @@ -4,4 +4,4 @@ yield(foo); //// [YieldExpression18_es6.js] "use strict"; -yield (foo); +yield(foo); diff --git a/tests/baselines/reference/aliasUsageInAccessorsOfClass.types b/tests/baselines/reference/aliasUsageInAccessorsOfClass.types index eccdbc8528c..092643002e4 100644 --- a/tests/baselines/reference/aliasUsageInAccessorsOfClass.types +++ b/tests/baselines/reference/aliasUsageInAccessorsOfClass.types @@ -53,9 +53,9 @@ import Backbone = require("aliasUsage1_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInArray.types b/tests/baselines/reference/aliasUsageInArray.types index ee54300e7d9..488cc97d07f 100644 --- a/tests/baselines/reference/aliasUsageInArray.types +++ b/tests/baselines/reference/aliasUsageInArray.types @@ -41,9 +41,9 @@ import Backbone = require("aliasUsageInArray_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInFunctionExpression.types b/tests/baselines/reference/aliasUsageInFunctionExpression.types index 17994dcab52..eec4341fd67 100644 --- a/tests/baselines/reference/aliasUsageInFunctionExpression.types +++ b/tests/baselines/reference/aliasUsageInFunctionExpression.types @@ -42,9 +42,9 @@ import Backbone = require("aliasUsageInFunctionExpression_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInGenericFunction.types b/tests/baselines/reference/aliasUsageInGenericFunction.types index 0821732f5fc..c21e691d773 100644 --- a/tests/baselines/reference/aliasUsageInGenericFunction.types +++ b/tests/baselines/reference/aliasUsageInGenericFunction.types @@ -57,9 +57,9 @@ import Backbone = require("aliasUsageInGenericFunction_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInIndexerOfClass.types b/tests/baselines/reference/aliasUsageInIndexerOfClass.types index fe67655d4f5..b7e4873ba34 100644 --- a/tests/baselines/reference/aliasUsageInIndexerOfClass.types +++ b/tests/baselines/reference/aliasUsageInIndexerOfClass.types @@ -50,9 +50,9 @@ import Backbone = require("aliasUsageInIndexerOfClass_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInObjectLiteral.types b/tests/baselines/reference/aliasUsageInObjectLiteral.types index 32a78d555b1..5ab294b7350 100644 --- a/tests/baselines/reference/aliasUsageInObjectLiteral.types +++ b/tests/baselines/reference/aliasUsageInObjectLiteral.types @@ -55,9 +55,9 @@ import Backbone = require("aliasUsageInObjectLiteral_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInOrExpression.types b/tests/baselines/reference/aliasUsageInOrExpression.types index 8d3163d481b..e7ca8639762 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.types +++ b/tests/baselines/reference/aliasUsageInOrExpression.types @@ -79,9 +79,9 @@ import Backbone = require("aliasUsageInOrExpression_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types index 460b422a2a4..ae20caa9c37 100644 --- a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types +++ b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types @@ -25,7 +25,7 @@ class C { } class D extends C { >D : D ->C : C +>C : C >IHasVisualizationModel : IHasVisualizationModel x = moduleA; @@ -46,9 +46,9 @@ import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/aliasUsageInVarAssignment.types b/tests/baselines/reference/aliasUsageInVarAssignment.types index b5d20a1b372..6a23293ea7c 100644 --- a/tests/baselines/reference/aliasUsageInVarAssignment.types +++ b/tests/baselines/reference/aliasUsageInVarAssignment.types @@ -37,9 +37,9 @@ import Backbone = require("aliasUsageInVarAssignment_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types index 9b2abf25c2d..9cdbe0a0a61 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types @@ -17,7 +17,7 @@ class List { class DerivedList extends List { >DerivedList : DerivedList >U : U ->List : List +>List : List >U : U foo: U; diff --git a/tests/baselines/reference/baseTypeWrappingInstantiationChain.types b/tests/baselines/reference/baseTypeWrappingInstantiationChain.types index 61919bad212..747b672dd0d 100644 --- a/tests/baselines/reference/baseTypeWrappingInstantiationChain.types +++ b/tests/baselines/reference/baseTypeWrappingInstantiationChain.types @@ -2,7 +2,7 @@ class C extends CBase { >C : C >T1 : T1 ->CBase : CBase +>CBase : CBase >T1 : T1 public works() { @@ -35,7 +35,7 @@ class C extends CBase { class CBase extends CBaseBase> { >CBase : CBase >T2 : T2 ->CBaseBase : CBaseBase +>CBaseBase : CBaseBase> >Wrapper : Wrapper >T2 : T2 diff --git a/tests/baselines/reference/checkForObjectTooStrict.errors.txt b/tests/baselines/reference/checkForObjectTooStrict.errors.txt deleted file mode 100644 index 7af7481f6ae..00000000000 --- a/tests/baselines/reference/checkForObjectTooStrict.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -tests/cases/compiler/checkForObjectTooStrict.ts(22,19): error TS2311: A class may only extend another class. -tests/cases/compiler/checkForObjectTooStrict.ts(26,9): error TS2335: 'super' can only be referenced in a derived class. - - -==== tests/cases/compiler/checkForObjectTooStrict.ts (2 errors) ==== - module Foo { - - export class Object { - - } - - } - - - - class Bar extends Foo.Object { // should work - - constructor () { - - super(); - - } - - } - - - class Baz extends Object { - ~~~~~~ -!!! error TS2311: A class may only extend another class. - - constructor () { // ERROR, as expected - - super(); - ~~~~~ -!!! error TS2335: 'super' can only be referenced in a derived class. - - } - - } - \ No newline at end of file diff --git a/tests/baselines/reference/checkForObjectTooStrict.symbols b/tests/baselines/reference/checkForObjectTooStrict.symbols new file mode 100644 index 00000000000..48e04392c3b --- /dev/null +++ b/tests/baselines/reference/checkForObjectTooStrict.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/checkForObjectTooStrict.ts === +module Foo { +>Foo : Symbol(Foo, Decl(checkForObjectTooStrict.ts, 0, 0)) + + export class Object { +>Object : Symbol(Object, Decl(checkForObjectTooStrict.ts, 0, 12)) + + } + +} + + + +class Bar extends Foo.Object { // should work +>Bar : Symbol(Bar, Decl(checkForObjectTooStrict.ts, 6, 1)) +>Foo.Object : Symbol(Foo.Object, Decl(checkForObjectTooStrict.ts, 0, 12)) +>Foo : Symbol(Foo, Decl(checkForObjectTooStrict.ts, 0, 0)) +>Object : Symbol(Foo.Object, Decl(checkForObjectTooStrict.ts, 0, 12)) + + constructor () { + + super(); +>super : Symbol(Foo.Object, Decl(checkForObjectTooStrict.ts, 0, 12)) + + } + +} + + +class Baz extends Object { +>Baz : Symbol(Baz, Decl(checkForObjectTooStrict.ts, 18, 1)) +>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) + + constructor () { // ERROR, as expected + + super(); +>super : Symbol(ObjectConstructor, Decl(lib.d.ts, 124, 1)) + + } + +} + diff --git a/tests/baselines/reference/checkForObjectTooStrict.types b/tests/baselines/reference/checkForObjectTooStrict.types new file mode 100644 index 00000000000..f6b63019cd5 --- /dev/null +++ b/tests/baselines/reference/checkForObjectTooStrict.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/checkForObjectTooStrict.ts === +module Foo { +>Foo : typeof Foo + + export class Object { +>Object : Object + + } + +} + + + +class Bar extends Foo.Object { // should work +>Bar : Bar +>Foo.Object : Foo.Object +>Foo : typeof Foo +>Object : typeof Foo.Object + + constructor () { + + super(); +>super() : void +>super : typeof Foo.Object + + } + +} + + +class Baz extends Object { +>Baz : Baz +>Object : Object + + constructor () { // ERROR, as expected + + super(); +>super() : void +>super : ObjectConstructor + + } + +} + diff --git a/tests/baselines/reference/circularImportAlias.types b/tests/baselines/reference/circularImportAlias.types index 3ab41f6187b..e4b2f27dbbe 100644 --- a/tests/baselines/reference/circularImportAlias.types +++ b/tests/baselines/reference/circularImportAlias.types @@ -10,9 +10,9 @@ module B { export class D extends a.C { >D : D ->a.C : any +>a.C : a.C >a : typeof a ->C : a.C +>C : typeof a.C id: number; >id : number diff --git a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.types b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.types index f1be8e6d268..11fcac506b6 100644 --- a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.types +++ b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.types @@ -19,8 +19,8 @@ module M { export class O extends M.N { >O : O ->M.N : any +>M.N : N >M : typeof M ->N : N +>N : typeof N } } diff --git a/tests/baselines/reference/classExtendingBuiltinType.js b/tests/baselines/reference/classExtendingBuiltinType.js new file mode 100644 index 00000000000..666ada39505 --- /dev/null +++ b/tests/baselines/reference/classExtendingBuiltinType.js @@ -0,0 +1,90 @@ +//// [classExtendingBuiltinType.ts] +class C1 extends Object { } +class C2 extends Function { } +class C3 extends String { } +class C4 extends Boolean { } +class C5 extends Number { } +class C6 extends Date { } +class C7 extends RegExp { } +class C8 extends Error { } +class C9 extends Array { } +class C10 extends Array { } + + +//// [classExtendingBuiltinType.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var C1 = (function (_super) { + __extends(C1, _super); + function C1() { + _super.apply(this, arguments); + } + return C1; +})(Object); +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + _super.apply(this, arguments); + } + return C2; +})(Function); +var C3 = (function (_super) { + __extends(C3, _super); + function C3() { + _super.apply(this, arguments); + } + return C3; +})(String); +var C4 = (function (_super) { + __extends(C4, _super); + function C4() { + _super.apply(this, arguments); + } + return C4; +})(Boolean); +var C5 = (function (_super) { + __extends(C5, _super); + function C5() { + _super.apply(this, arguments); + } + return C5; +})(Number); +var C6 = (function (_super) { + __extends(C6, _super); + function C6() { + _super.apply(this, arguments); + } + return C6; +})(Date); +var C7 = (function (_super) { + __extends(C7, _super); + function C7() { + _super.apply(this, arguments); + } + return C7; +})(RegExp); +var C8 = (function (_super) { + __extends(C8, _super); + function C8() { + _super.apply(this, arguments); + } + return C8; +})(Error); +var C9 = (function (_super) { + __extends(C9, _super); + function C9() { + _super.apply(this, arguments); + } + return C9; +})(Array); +var C10 = (function (_super) { + __extends(C10, _super); + function C10() { + _super.apply(this, arguments); + } + return C10; +})(Array); diff --git a/tests/baselines/reference/classExtendingBuiltinType.symbols b/tests/baselines/reference/classExtendingBuiltinType.symbols new file mode 100644 index 00000000000..08e85be570e --- /dev/null +++ b/tests/baselines/reference/classExtendingBuiltinType.symbols @@ -0,0 +1,41 @@ +=== tests/cases/conformance/classes/classDeclarations/classExtendingBuiltinType.ts === +class C1 extends Object { } +>C1 : Symbol(C1, Decl(classExtendingBuiltinType.ts, 0, 0)) +>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) + +class C2 extends Function { } +>C2 : Symbol(C2, Decl(classExtendingBuiltinType.ts, 0, 27)) +>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11)) + +class C3 extends String { } +>C3 : Symbol(C3, Decl(classExtendingBuiltinType.ts, 1, 29)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11)) + +class C4 extends Boolean { } +>C4 : Symbol(C4, Decl(classExtendingBuiltinType.ts, 2, 27)) +>Boolean : Symbol(Boolean, Decl(lib.d.ts, 443, 38), Decl(lib.d.ts, 456, 11)) + +class C5 extends Number { } +>C5 : Symbol(C5, Decl(classExtendingBuiltinType.ts, 3, 28)) +>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) + +class C6 extends Date { } +>C6 : Symbol(C6, Decl(classExtendingBuiltinType.ts, 4, 27)) +>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) + +class C7 extends RegExp { } +>C7 : Symbol(C7, Decl(classExtendingBuiltinType.ts, 5, 25)) +>RegExp : Symbol(RegExp, Decl(lib.d.ts, 825, 1), Decl(lib.d.ts, 876, 11)) + +class C8 extends Error { } +>C8 : Symbol(C8, Decl(classExtendingBuiltinType.ts, 6, 27)) +>Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11)) + +class C9 extends Array { } +>C9 : Symbol(C9, Decl(classExtendingBuiltinType.ts, 7, 26)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) + +class C10 extends Array { } +>C10 : Symbol(C10, Decl(classExtendingBuiltinType.ts, 8, 26)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) + diff --git a/tests/baselines/reference/classExtendingBuiltinType.types b/tests/baselines/reference/classExtendingBuiltinType.types new file mode 100644 index 00000000000..b50137e58d6 --- /dev/null +++ b/tests/baselines/reference/classExtendingBuiltinType.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/classes/classDeclarations/classExtendingBuiltinType.ts === +class C1 extends Object { } +>C1 : C1 +>Object : Object + +class C2 extends Function { } +>C2 : C2 +>Function : Function + +class C3 extends String { } +>C3 : C3 +>String : String + +class C4 extends Boolean { } +>C4 : C4 +>Boolean : Boolean + +class C5 extends Number { } +>C5 : C5 +>Number : Number + +class C6 extends Date { } +>C6 : C6 +>Date : Date + +class C7 extends RegExp { } +>C7 : C7 +>RegExp : RegExp + +class C8 extends Error { } +>C8 : C8 +>Error : Error + +class C9 extends Array { } +>C9 : C9 +>Array : any[] + +class C10 extends Array { } +>C10 : C10 +>Array : number[] + diff --git a/tests/baselines/reference/classExtendingClassLikeType.errors.txt b/tests/baselines/reference/classExtendingClassLikeType.errors.txt new file mode 100644 index 00000000000..6f9aef927ea --- /dev/null +++ b/tests/baselines/reference/classExtendingClassLikeType.errors.txt @@ -0,0 +1,70 @@ +tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(7,18): error TS2304: Cannot find name 'Base'. +tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(45,18): error TS2508: No base constructor has the specified number of type arguments. +tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(56,18): error TS2510: Base constructors must all have the same return type. + + +==== tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts (3 errors) ==== + interface Base { + x: T; + y: U; + } + + // Error, no Base constructor function + class D0 extends Base { + ~~~~ +!!! error TS2304: Cannot find name 'Base'. + } + + interface BaseConstructor { + new (x: string, y: string): Base; + new (x: T): Base; + new (x: T, y: T): Base; + new (x: T, y: U): Base; + } + + declare function getBase(): BaseConstructor; + + class D1 extends getBase() { + constructor() { + super("abc", "def"); + this.x = "x"; + this.y = "y"; + } + } + + class D2 extends getBase() { + constructor() { + super(10); + super(10, 20); + this.x = 1; + this.y = 2; + } + } + + class D3 extends getBase() { + constructor() { + super("abc", 42); + this.x = "x"; + this.y = 2; + } + } + + // Error, no constructors with three type arguments + class D4 extends getBase() { + ~~~~~~~~~ +!!! error TS2508: No base constructor has the specified number of type arguments. + } + + interface BadBaseConstructor { + new (x: string): Base; + new (x: number): Base; + } + + declare function getBadBase(): BadBaseConstructor; + + // Error, constructor return types differ + class D5 extends getBadBase() { + ~~~~~~~~~~~~ +!!! error TS2510: Base constructors must all have the same return type. + } + \ No newline at end of file diff --git a/tests/baselines/reference/classExtendingClassLikeType.js b/tests/baselines/reference/classExtendingClassLikeType.js new file mode 100644 index 00000000000..88a5dc8dcd3 --- /dev/null +++ b/tests/baselines/reference/classExtendingClassLikeType.js @@ -0,0 +1,119 @@ +//// [classExtendingClassLikeType.ts] +interface Base { + x: T; + y: U; +} + +// Error, no Base constructor function +class D0 extends Base { +} + +interface BaseConstructor { + new (x: string, y: string): Base; + new (x: T): Base; + new (x: T, y: T): Base; + new (x: T, y: U): Base; +} + +declare function getBase(): BaseConstructor; + +class D1 extends getBase() { + constructor() { + super("abc", "def"); + this.x = "x"; + this.y = "y"; + } +} + +class D2 extends getBase() { + constructor() { + super(10); + super(10, 20); + this.x = 1; + this.y = 2; + } +} + +class D3 extends getBase() { + constructor() { + super("abc", 42); + this.x = "x"; + this.y = 2; + } +} + +// Error, no constructors with three type arguments +class D4 extends getBase() { +} + +interface BadBaseConstructor { + new (x: string): Base; + new (x: number): Base; +} + +declare function getBadBase(): BadBaseConstructor; + +// Error, constructor return types differ +class D5 extends getBadBase() { +} + + +//// [classExtendingClassLikeType.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +// Error, no Base constructor function +var D0 = (function (_super) { + __extends(D0, _super); + function D0() { + _super.apply(this, arguments); + } + return D0; +})(Base); +var D1 = (function (_super) { + __extends(D1, _super); + function D1() { + _super.call(this, "abc", "def"); + this.x = "x"; + this.y = "y"; + } + return D1; +})(getBase()); +var D2 = (function (_super) { + __extends(D2, _super); + function D2() { + _super.call(this, 10); + _super.call(this, 10, 20); + this.x = 1; + this.y = 2; + } + return D2; +})(getBase()); +var D3 = (function (_super) { + __extends(D3, _super); + function D3() { + _super.call(this, "abc", 42); + this.x = "x"; + this.y = 2; + } + return D3; +})(getBase()); +// Error, no constructors with three type arguments +var D4 = (function (_super) { + __extends(D4, _super); + function D4() { + _super.apply(this, arguments); + } + return D4; +})(getBase()); +// Error, constructor return types differ +var D5 = (function (_super) { + __extends(D5, _super); + function D5() { + _super.apply(this, arguments); + } + return D5; +})(getBadBase()); diff --git a/tests/baselines/reference/classExtendingNonConstructor.errors.txt b/tests/baselines/reference/classExtendingNonConstructor.errors.txt new file mode 100644 index 00000000000..b1e3994cf1c --- /dev/null +++ b/tests/baselines/reference/classExtendingNonConstructor.errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(7,18): error TS2507: Base expression is not of a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(8,18): error TS2507: Base expression is not of a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(9,18): error TS2507: Base expression is not of a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(10,18): error TS2507: Base expression is not of a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(11,18): error TS2507: Base expression is not of a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(12,18): error TS2507: Base expression is not of a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(13,18): error TS2507: Base expression is not of a constructor function type. + + +==== tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts (7 errors) ==== + var x: {}; + + function foo() { + this.x = 1; + } + + class C1 extends undefined { } + ~~~~~~~~~ +!!! error TS2507: Base expression is not of a constructor function type. + class C2 extends true { } + ~~~~ +!!! error TS2507: Base expression is not of a constructor function type. + class C3 extends false { } + ~~~~~ +!!! error TS2507: Base expression is not of a constructor function type. + class C4 extends 42 { } + ~~ +!!! error TS2507: Base expression is not of a constructor function type. + class C5 extends "hello" { } + ~~~~~~~ +!!! error TS2507: Base expression is not of a constructor function type. + class C6 extends x { } + ~ +!!! error TS2507: Base expression is not of a constructor function type. + class C7 extends foo { } + ~~~ +!!! error TS2507: Base expression is not of a constructor function type. + \ No newline at end of file diff --git a/tests/baselines/reference/classExtendingNonConstructor.js b/tests/baselines/reference/classExtendingNonConstructor.js new file mode 100644 index 00000000000..f796b30ddd6 --- /dev/null +++ b/tests/baselines/reference/classExtendingNonConstructor.js @@ -0,0 +1,76 @@ +//// [classExtendingNonConstructor.ts] +var x: {}; + +function foo() { + this.x = 1; +} + +class C1 extends undefined { } +class C2 extends true { } +class C3 extends false { } +class C4 extends 42 { } +class C5 extends "hello" { } +class C6 extends x { } +class C7 extends foo { } + + +//// [classExtendingNonConstructor.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var x; +function foo() { + this.x = 1; +} +var C1 = (function (_super) { + __extends(C1, _super); + function C1() { + _super.apply(this, arguments); + } + return C1; +})(undefined); +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + _super.apply(this, arguments); + } + return C2; +})(true); +var C3 = (function (_super) { + __extends(C3, _super); + function C3() { + _super.apply(this, arguments); + } + return C3; +})(false); +var C4 = (function (_super) { + __extends(C4, _super); + function C4() { + _super.apply(this, arguments); + } + return C4; +})(42); +var C5 = (function (_super) { + __extends(C5, _super); + function C5() { + _super.apply(this, arguments); + } + return C5; +})("hello"); +var C6 = (function (_super) { + __extends(C6, _super); + function C6() { + _super.apply(this, arguments); + } + return C6; +})(x); +var C7 = (function (_super) { + __extends(C7, _super); + function C7() { + _super.apply(this, arguments); + } + return C7; +})(foo); diff --git a/tests/baselines/reference/classExtendingNull.js b/tests/baselines/reference/classExtendingNull.js new file mode 100644 index 00000000000..f0c3ea69626 --- /dev/null +++ b/tests/baselines/reference/classExtendingNull.js @@ -0,0 +1,26 @@ +//// [classExtendingNull.ts] +class C1 extends null { } +class C2 extends (null) { } + + +//// [classExtendingNull.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var C1 = (function (_super) { + __extends(C1, _super); + function C1() { + _super.apply(this, arguments); + } + return C1; +})(null); +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + _super.apply(this, arguments); + } + return C2; +})((null)); diff --git a/tests/baselines/reference/classExtendingNull.symbols b/tests/baselines/reference/classExtendingNull.symbols new file mode 100644 index 00000000000..37a6162f414 --- /dev/null +++ b/tests/baselines/reference/classExtendingNull.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/classes/classDeclarations/classExtendingNull.ts === +class C1 extends null { } +>C1 : Symbol(C1, Decl(classExtendingNull.ts, 0, 0)) + +class C2 extends (null) { } +>C2 : Symbol(C2, Decl(classExtendingNull.ts, 0, 25)) + diff --git a/tests/baselines/reference/classExtendingNull.types b/tests/baselines/reference/classExtendingNull.types new file mode 100644 index 00000000000..3c572a3406c --- /dev/null +++ b/tests/baselines/reference/classExtendingNull.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/classes/classDeclarations/classExtendingNull.ts === +class C1 extends null { } +>C1 : C1 +>null : null + +class C2 extends (null) { } +>C2 : C2 +>(null) : null +>null : null + diff --git a/tests/baselines/reference/classExtendingPrimitive.errors.txt b/tests/baselines/reference/classExtendingPrimitive.errors.txt index ae039640e99..68525a1eabd 100644 --- a/tests/baselines/reference/classExtendingPrimitive.errors.txt +++ b/tests/baselines/reference/classExtendingPrimitive.errors.txt @@ -4,13 +4,12 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(6,18): error TS2304: Cannot find name 'Void'. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(7,19): error TS1109: Expression expected. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(8,18): error TS2304: Cannot find name 'Null'. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(9,19): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(10,18): error TS2304: Cannot find name 'undefined'. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(10,18): error TS2507: Base expression is not of a constructor function type. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(11,18): error TS2304: Cannot find name 'Undefined'. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(14,18): error TS2311: A class may only extend another class. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(14,18): error TS2507: Base expression is not of a constructor function type. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts (10 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts (9 errors) ==== // classes cannot extend primitives class C extends number { } @@ -32,11 +31,9 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla ~~~~ !!! error TS2304: Cannot find name 'Null'. class C5a extends null { } - ~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. class C6 extends undefined { } ~~~~~~~~~ -!!! error TS2304: Cannot find name 'undefined'. +!!! error TS2507: Base expression is not of a constructor function type. class C7 extends Undefined { } ~~~~~~~~~ !!! error TS2304: Cannot find name 'Undefined'. @@ -44,4 +41,4 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla enum E { A } class C8 extends E { } ~ -!!! error TS2311: A class may only extend another class. \ No newline at end of file +!!! error TS2507: Base expression is not of a constructor function type. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendingPrimitive2.errors.txt b/tests/baselines/reference/classExtendingPrimitive2.errors.txt index 3bba9b9e041..2303ca6323d 100644 --- a/tests/baselines/reference/classExtendingPrimitive2.errors.txt +++ b/tests/baselines/reference/classExtendingPrimitive2.errors.txt @@ -1,13 +1,10 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts(3,19): error TS1109: Expression expected. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts(4,19): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts (2 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts (1 errors) ==== // classes cannot extend primitives class C4a extends void {} ~~~~ !!! error TS1109: Expression expected. - class C5a extends null { } - ~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. \ No newline at end of file + class C5a extends null { } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendingQualifiedName.errors.txt b/tests/baselines/reference/classExtendingQualifiedName.errors.txt index b63b3e23108..f04d07c89e6 100644 --- a/tests/baselines/reference/classExtendingQualifiedName.errors.txt +++ b/tests/baselines/reference/classExtendingQualifiedName.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classExtendingQualifiedName.ts(5,23): error TS2305: Module 'M' has no exported member 'C'. +tests/cases/compiler/classExtendingQualifiedName.ts(5,23): error TS2339: Property 'C' does not exist on type 'typeof M'. ==== tests/cases/compiler/classExtendingQualifiedName.ts (1 errors) ==== @@ -8,6 +8,6 @@ tests/cases/compiler/classExtendingQualifiedName.ts(5,23): error TS2305: Module class D extends M.C { ~ -!!! error TS2305: Module 'M' has no exported member 'C'. +!!! error TS2339: Property 'C' does not exist on type 'typeof M'. } } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendingQualifiedName2.types b/tests/baselines/reference/classExtendingQualifiedName2.types index 9f0c03db17d..bd50fe3d2ce 100644 --- a/tests/baselines/reference/classExtendingQualifiedName2.types +++ b/tests/baselines/reference/classExtendingQualifiedName2.types @@ -8,8 +8,8 @@ module M { class D extends M.C { >D : D ->M.C : any +>M.C : C >M : typeof M ->C : C +>C : typeof C } } diff --git a/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.errors.txt b/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.errors.txt index 50c90389520..b1c5d253b56 100644 --- a/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.errors.txt +++ b/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classExtendsClauseClassMergedWithModuleNotReferingConstructor.ts(10,21): error TS2419: Type name 'A' in extends clause does not reference constructor function for 'A'. +tests/cases/compiler/classExtendsClauseClassMergedWithModuleNotReferingConstructor.ts(10,21): error TS2507: Base expression is not of a constructor function type. ==== tests/cases/compiler/classExtendsClauseClassMergedWithModuleNotReferingConstructor.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/classExtendsClauseClassMergedWithModuleNotReferingConstruct var A = 1; class B extends A { ~ -!!! error TS2419: Type name 'A' in extends clause does not reference constructor function for 'A'. +!!! error TS2507: Base expression is not of a constructor function type. b: string; } } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.errors.txt b/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.errors.txt index 7f8b6fb411b..448167d739d 100644 --- a/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.errors.txt +++ b/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classExtendsClauseClassNotReferringConstructor.ts(4,21): error TS2419: Type name 'A' in extends clause does not reference constructor function for 'A'. +tests/cases/compiler/classExtendsClauseClassNotReferringConstructor.ts(4,21): error TS2507: Base expression is not of a constructor function type. ==== tests/cases/compiler/classExtendsClauseClassNotReferringConstructor.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/classExtendsClauseClassNotReferringConstructor.ts(4,21): er var A = 1; class B extends A { b: string; } ~ -!!! error TS2419: Type name 'A' in extends clause does not reference constructor function for 'A'. +!!! error TS2507: Base expression is not of a constructor function type. } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsEveryObjectType.errors.txt b/tests/baselines/reference/classExtendsEveryObjectType.errors.txt index 75eced53139..e1f1c785bbc 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType.errors.txt +++ b/tests/baselines/reference/classExtendsEveryObjectType.errors.txt @@ -1,40 +1,43 @@ -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(6,18): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(4,17): error TS2304: Cannot find name 'I'. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,18): error TS2507: Base expression is not of a constructor function type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,25): error TS2304: Cannot find name 'string'. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,31): error TS1005: ',' expected. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(8,18): error TS2304: Cannot find name 'x'. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(11,18): error TS2304: Cannot find name 'M'. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(14,18): error TS2304: Cannot find name 'foo'. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(16,18): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(8,18): error TS2507: Base expression is not of a constructor function type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(11,18): error TS2507: Base expression is not of a constructor function type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(14,18): error TS2507: Base expression is not of a constructor function type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(16,18): error TS2507: Base expression is not of a constructor function type. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts (7 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts (8 errors) ==== interface I { foo: string; } class C extends I { } // error ~ -!!! error TS2311: A class may only extend another class. +!!! error TS2304: Cannot find name 'I'. class C2 extends { foo: string; } { } // error ~~~~~~~~~~~~~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +!!! error TS2507: Base expression is not of a constructor function type. + ~~~~~~ +!!! error TS2304: Cannot find name 'string'. ~ !!! error TS1005: ',' expected. var x: { foo: string; } class C3 extends x { } // error ~ -!!! error TS2304: Cannot find name 'x'. +!!! error TS2507: Base expression is not of a constructor function type. module M { export var x = 1; } class C4 extends M { } // error ~ -!!! error TS2304: Cannot find name 'M'. +!!! error TS2507: Base expression is not of a constructor function type. function foo() { } class C5 extends foo { } // error ~~~ -!!! error TS2304: Cannot find name 'foo'. +!!! error TS2507: Base expression is not of a constructor function type. class C6 extends []{ } // error ~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. \ No newline at end of file +!!! error TS2507: Base expression is not of a constructor function type. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt b/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt index 45a63030d00..650c4e4886e 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt +++ b/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt @@ -1,15 +1,18 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(1,18): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(1,18): error TS2507: Base expression is not of a constructor function type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(1,25): error TS2304: Cannot find name 'string'. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(1,31): error TS1005: ',' expected. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(3,18): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(3,18): error TS2507: Base expression is not of a constructor function type. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts (3 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts (4 errors) ==== class C2 extends { foo: string; } { } // error ~~~~~~~~~~~~~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +!!! error TS2507: Base expression is not of a constructor function type. + ~~~~~~ +!!! error TS2304: Cannot find name 'string'. ~ !!! error TS1005: ',' expected. class C6 extends []{ } // error ~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. \ No newline at end of file +!!! error TS2507: Base expression is not of a constructor function type. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsInterface.errors.txt b/tests/baselines/reference/classExtendsInterface.errors.txt index 746f3c4bea0..2ecca6cf2cf 100644 --- a/tests/baselines/reference/classExtendsInterface.errors.txt +++ b/tests/baselines/reference/classExtendsInterface.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/classExtendsInterface.ts(2,17): error TS2311: A class may only extend another class. -tests/cases/compiler/classExtendsInterface.ts(6,21): error TS2311: A class may only extend another class. +tests/cases/compiler/classExtendsInterface.ts(2,17): error TS2304: Cannot find name 'Comparable'. +tests/cases/compiler/classExtendsInterface.ts(6,21): error TS2304: Cannot find name 'Comparable2'. ==== tests/cases/compiler/classExtendsInterface.ts (2 errors) ==== interface Comparable {} class A extends Comparable {} ~~~~~~~~~~ -!!! error TS2311: A class may only extend another class. +!!! error TS2304: Cannot find name 'Comparable'. class B implements Comparable {} interface Comparable2 {} class A2 extends Comparable2 {} - ~~~~~~~~~~~~~~ -!!! error TS2311: A class may only extend another class. + ~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'Comparable2'. class B2 implements Comparable2 {} \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsItself.errors.txt b/tests/baselines/reference/classExtendsItself.errors.txt index bd15ae22c12..9dd3bcc2202 100644 --- a/tests/baselines/reference/classExtendsItself.errors.txt +++ b/tests/baselines/reference/classExtendsItself.errors.txt @@ -1,17 +1,17 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts(1,7): error TS2310: Type 'C' recursively references itself as a base type. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts(3,7): error TS2310: Type 'D' recursively references itself as a base type. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts(5,7): error TS2310: Type 'E' recursively references itself as a base type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts(1,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts(3,7): error TS2506: 'D' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts(5,7): error TS2506: 'E' is referenced directly or indirectly in its own base expression. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItself.ts (3 errors) ==== class C extends C { } // error ~ -!!! error TS2310: Type 'C' recursively references itself as a base type. +!!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. class D extends D { } // error ~ -!!! error TS2310: Type 'D' recursively references itself as a base type. +!!! error TS2506: 'D' is referenced directly or indirectly in its own base expression. class E extends E { } // error ~ -!!! error TS2310: Type 'E' recursively references itself as a base type. \ No newline at end of file +!!! error TS2506: 'E' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt b/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt index b39ef5b905f..c0f35f0388f 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt +++ b/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt @@ -1,20 +1,32 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(1,7): error TS2310: Type 'C' recursively references itself as a base type. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(7,7): error TS2310: Type 'C2' recursively references itself as a base type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(1,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(3,7): error TS2506: 'D' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(5,7): error TS2506: 'E' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(7,7): error TS2506: 'C2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(9,7): error TS2506: 'D2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(11,7): error TS2506: 'E2' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts (2 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts (6 errors) ==== class C extends E { foo: string; } // error ~ -!!! error TS2310: Type 'C' recursively references itself as a base type. +!!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. class D extends C { bar: string; } + ~ +!!! error TS2506: 'D' is referenced directly or indirectly in its own base expression. class E extends D { baz: number; } + ~ +!!! error TS2506: 'E' is referenced directly or indirectly in its own base expression. class C2 extends E2 { foo: T; } // error ~~ -!!! error TS2310: Type 'C2' recursively references itself as a base type. +!!! error TS2506: 'C2' is referenced directly or indirectly in its own base expression. class D2 extends C2 { bar: T; } + ~~ +!!! error TS2506: 'D2' is referenced directly or indirectly in its own base expression. - class E2 extends D2 { baz: T; } \ No newline at end of file + class E2 extends D2 { baz: T; } + ~~ +!!! error TS2506: 'E2' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt b/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt index a61291b5aa9..061770f9b79 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt +++ b/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt @@ -1,31 +1,43 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(1,7): error TS2310: Type 'C' recursively references itself as a base type. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(13,11): error TS2310: Type 'C2' recursively references itself as a base type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(1,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(4,18): error TS2506: 'D' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(9,18): error TS2506: 'E' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(13,11): error TS2506: 'C2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(16,22): error TS2506: 'D2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(20,22): error TS2506: 'E2' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts (2 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts (6 errors) ==== class C extends N.E { foo: string; } // error ~ -!!! error TS2310: Type 'C' recursively references itself as a base type. +!!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. module M { export class D extends C { bar: string; } + ~ +!!! error TS2506: 'D' is referenced directly or indirectly in its own base expression. } module N { export class E extends M.D { baz: number; } + ~ +!!! error TS2506: 'E' is referenced directly or indirectly in its own base expression. } module O { class C2 extends Q.E2 { foo: T; } // error ~~ -!!! error TS2310: Type 'C2' recursively references itself as a base type. +!!! error TS2506: 'C2' is referenced directly or indirectly in its own base expression. module P { export class D2 extends C2 { bar: T; } + ~~ +!!! error TS2506: 'D2' is referenced directly or indirectly in its own base expression. } module Q { export class E2 extends P.D2 { baz: T; } + ~~ +!!! error TS2506: 'E2' is referenced directly or indirectly in its own base expression. } } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsItselfIndirectly3.errors.txt b/tests/baselines/reference/classExtendsItselfIndirectly3.errors.txt index 8430ec887b5..411ea4cb580 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly3.errors.txt +++ b/tests/baselines/reference/classExtendsItselfIndirectly3.errors.txt @@ -1,25 +1,37 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file1.ts(1,7): error TS2310: Type 'C' recursively references itself as a base type. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file4.ts(1,7): error TS2310: Type 'C2' recursively references itself as a base type. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file1.ts(1,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file2.ts(1,7): error TS2506: 'D' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file3.ts(1,7): error TS2506: 'E' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file4.ts(1,7): error TS2506: 'C2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file5.ts(1,7): error TS2506: 'D2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file6.ts(1,7): error TS2506: 'E2' is referenced directly or indirectly in its own base expression. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file1.ts (1 errors) ==== class C extends E { foo: string; } // error ~ -!!! error TS2310: Type 'C' recursively references itself as a base type. +!!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file2.ts (0 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file2.ts (1 errors) ==== class D extends C { bar: string; } + ~ +!!! error TS2506: 'D' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file3.ts (0 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file3.ts (1 errors) ==== class E extends D { baz: number; } + ~ +!!! error TS2506: 'E' is referenced directly or indirectly in its own base expression. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file4.ts (1 errors) ==== class C2 extends E2 { foo: T; } // error ~~ -!!! error TS2310: Type 'C2' recursively references itself as a base type. +!!! error TS2506: 'C2' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file5.ts (0 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file5.ts (1 errors) ==== class D2 extends C2 { bar: T; } + ~~ +!!! error TS2506: 'D2' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file6.ts (0 errors) ==== - class E2 extends D2 { baz: T; } \ No newline at end of file +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly_file6.ts (1 errors) ==== + class E2 extends D2 { baz: T; } + ~~ +!!! error TS2506: 'E2' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsShadowedConstructorFunction.errors.txt b/tests/baselines/reference/classExtendsShadowedConstructorFunction.errors.txt index 782dd2a2dbc..475a980e4e6 100644 --- a/tests/baselines/reference/classExtendsShadowedConstructorFunction.errors.txt +++ b/tests/baselines/reference/classExtendsShadowedConstructorFunction.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsShadowedConstructorFunction.ts(5,21): error TS2419: Type name 'C' in extends clause does not reference constructor function for 'C'. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsShadowedConstructorFunction.ts(5,21): error TS2507: Base expression is not of a constructor function type. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsShadowedConstructorFunction.ts (1 errors) ==== @@ -8,7 +8,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla var C = 1; class D extends C { // error, C must evaluate to constructor function ~ -!!! error TS2419: Type name 'C' in extends clause does not reference constructor function for 'C'. +!!! error TS2507: Base expression is not of a constructor function type. bar: string; } } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsValidConstructorFunction.errors.txt b/tests/baselines/reference/classExtendsValidConstructorFunction.errors.txt index ad2262819ed..6ebd818e547 100644 --- a/tests/baselines/reference/classExtendsValidConstructorFunction.errors.txt +++ b/tests/baselines/reference/classExtendsValidConstructorFunction.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsValidConstructorFunction.ts(5,17): error TS2304: Cannot find name 'foo'. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsValidConstructorFunction.ts(5,17): error TS2507: Base expression is not of a constructor function type. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsValidConstructorFunction.ts (1 errors) ==== @@ -8,4 +8,4 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla class C extends foo { } // error, cannot extend it though ~~~ -!!! error TS2304: Cannot find name 'foo'. \ No newline at end of file +!!! error TS2507: Base expression is not of a constructor function type. \ No newline at end of file diff --git a/tests/baselines/reference/classInheritence.errors.txt b/tests/baselines/reference/classInheritence.errors.txt index 483812c6b5f..cba8c040d6e 100644 --- a/tests/baselines/reference/classInheritence.errors.txt +++ b/tests/baselines/reference/classInheritence.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/classInheritence.ts(2,7): error TS2310: Type 'A' recursively references itself as a base type. +tests/cases/compiler/classInheritence.ts(2,7): error TS2506: 'A' is referenced directly or indirectly in its own base expression. ==== tests/cases/compiler/classInheritence.ts (1 errors) ==== class B extends A { } class A extends A { } ~ -!!! error TS2310: Type 'A' recursively references itself as a base type. \ No newline at end of file +!!! error TS2506: 'A' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/classUpdateTests.errors.txt b/tests/baselines/reference/classUpdateTests.errors.txt index 536c69023ad..59e9bc9ced1 100644 --- a/tests/baselines/reference/classUpdateTests.errors.txt +++ b/tests/baselines/reference/classUpdateTests.errors.txt @@ -1,7 +1,5 @@ tests/cases/compiler/classUpdateTests.ts(34,2): error TS2377: Constructors for derived classes must contain a 'super' call. tests/cases/compiler/classUpdateTests.ts(43,18): error TS2335: 'super' can only be referenced in a derived class. -tests/cases/compiler/classUpdateTests.ts(46,17): error TS2311: A class may only extend another class. -tests/cases/compiler/classUpdateTests.ts(47,18): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/classUpdateTests.ts(57,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties. tests/cases/compiler/classUpdateTests.ts(63,7): error TS2415: Class 'L' incorrectly extends base class 'G'. Property 'p1' is private in type 'L' but not in type 'G'. @@ -20,7 +18,7 @@ tests/cases/compiler/classUpdateTests.ts(111,15): error TS1005: ';' expected. tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/classUpdateTests.ts (18 errors) ==== +==== tests/cases/compiler/classUpdateTests.ts (16 errors) ==== // // test codegen for instance properties // @@ -71,11 +69,7 @@ tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or st } class I extends Object { - ~~~~~~ -!!! error TS2311: A class may only extend another class. constructor() { super(); } // ERROR - no super call allowed - ~~~~~ -!!! error TS2335: 'super' can only be referenced in a derived class. } class J extends G { diff --git a/tests/baselines/reference/commentOnAmbientModule.types b/tests/baselines/reference/commentOnAmbientModule.types index 13d35cddcea..629395a4e80 100644 --- a/tests/baselines/reference/commentOnAmbientModule.types +++ b/tests/baselines/reference/commentOnAmbientModule.types @@ -5,9 +5,9 @@ declare module E { class foobar extends D.bar { >foobar : foobar ->D.bar : any +>D.bar : D.bar >D : typeof D ->bar : D.bar +>bar : typeof D.bar foo(); >foo : () => any diff --git a/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.errors.txt b/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.errors.txt index 204a7d4c21a..a70eb0e5e2c 100644 --- a/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.errors.txt +++ b/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/complicatedGenericRecursiveBaseClassReference.ts(1,7): error TS2310: Type 'S18' recursively references itself as a base type. +tests/cases/compiler/complicatedGenericRecursiveBaseClassReference.ts(1,7): error TS2506: 'S18' is referenced directly or indirectly in its own base expression. tests/cases/compiler/complicatedGenericRecursiveBaseClassReference.ts(4,2): error TS2346: Supplied parameters do not match any signature of call target. ==== tests/cases/compiler/complicatedGenericRecursiveBaseClassReference.ts (2 errors) ==== class S18 extends S18 ~~~ -!!! error TS2310: Type 'S18' recursively references itself as a base type. +!!! error TS2506: 'S18' is referenced directly or indirectly in its own base expression. { } (new S18(123)).S18 = 0; diff --git a/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.types b/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.types index 1d94a5e464c..6fd80b779c5 100644 --- a/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.types +++ b/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.types @@ -16,7 +16,7 @@ class GenericBase { } class Derived extends GenericBase { >Derived : Derived ->GenericBase : GenericBase +>GenericBase : GenericBase >TypeArg : TypeArg } diff --git a/tests/baselines/reference/constraints0.errors.txt b/tests/baselines/reference/constraints0.errors.txt index 217a7408fbd..39cc7654e01 100644 --- a/tests/baselines/reference/constraints0.errors.txt +++ b/tests/baselines/reference/constraints0.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/constraints0.ts(14,9): error TS2344: Type 'B' does not satisfy the constraint 'A'. +tests/cases/compiler/constraints0.ts(14,11): error TS2344: Type 'B' does not satisfy the constraint 'A'. Property 'a' is missing in type 'B'. @@ -17,7 +17,7 @@ tests/cases/compiler/constraints0.ts(14,9): error TS2344: Type 'B' does not sati var v1: C; // should work var v2: C; // should not work - ~~~~ + ~ !!! error TS2344: Type 'B' does not satisfy the constraint 'A'. !!! error TS2344: Property 'a' is missing in type 'B'. diff --git a/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.types b/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.types index 5f759fb423f..ba203e39aab 100644 --- a/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.types +++ b/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.types @@ -6,7 +6,7 @@ class X { } class C extends X<() => number> { >C : C ->X : X +>X : X<() => number> } interface I extends X<() => number> { >I : I diff --git a/tests/baselines/reference/declFileGenericType.types b/tests/baselines/reference/declFileGenericType.types index 7aa20187890..310f812a7bb 100644 --- a/tests/baselines/reference/declFileGenericType.types +++ b/tests/baselines/reference/declFileGenericType.types @@ -153,9 +153,9 @@ export var g = C.F5>(); export class h extends C.A{ } >h : h ->C.A : any +>C.A : C.A >C : typeof C ->A : C.A +>A : typeof C.A >C : any >B : C.B diff --git a/tests/baselines/reference/declFileGenericType2.types b/tests/baselines/reference/declFileGenericType2.types index e1e1aa0bbfb..07bcba3e85a 100644 --- a/tests/baselines/reference/declFileGenericType2.types +++ b/tests/baselines/reference/declFileGenericType2.types @@ -86,11 +86,11 @@ module templa.dom.mvc { >templa : any >mvc : any >IModel : templa.mvc.IModel ->templa.mvc.AbstractController : any +>templa.mvc.AbstractController : templa.mvc.AbstractController >templa.mvc : typeof templa.mvc >templa : typeof templa >mvc : typeof templa.mvc ->AbstractController : templa.mvc.AbstractController +>AbstractController : typeof templa.mvc.AbstractController >ModelType : ModelType >IElementController : IElementController >ModelType : ModelType @@ -116,13 +116,13 @@ module templa.dom.mvc.composite { >mvc : any >composite : any >ICompositeControllerModel : templa.mvc.composite.ICompositeControllerModel ->templa.dom.mvc.AbstractElementController : any +>templa.dom.mvc.AbstractElementController : AbstractElementController >templa.dom.mvc : typeof mvc >templa.dom : typeof dom >templa : typeof templa >dom : typeof dom >mvc : typeof mvc ->AbstractElementController : AbstractElementController +>AbstractElementController : typeof AbstractElementController >ModelType : ModelType public _controllers: templa.mvc.IController[]; diff --git a/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.types b/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.types index 56e1d07d0ec..f032ad29b11 100644 --- a/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.types +++ b/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.types @@ -19,13 +19,13 @@ module X.Y.base { export class W extends A.B.Base.W { >W : W ->A.B.Base.W : any +>A.B.Base.W : A.B.Base.W >A.B.Base : typeof A.B.Base >A.B : typeof A.B >A : typeof A >B : typeof A.B >Base : typeof A.B.Base ->W : A.B.Base.W +>W : typeof A.B.Base.W name: string; >name : string @@ -41,13 +41,13 @@ module X.Y.base.Z { export class W extends X.Y.base.W { >W : W >TValue : TValue ->X.Y.base.W : any +>X.Y.base.W : base.W >X.Y.base : typeof base >X.Y : typeof Y >X : typeof X >Y : typeof Y >base : typeof base ->W : base.W +>W : typeof base.W value: boolean; >value : boolean diff --git a/tests/baselines/reference/declareDottedExtend.types b/tests/baselines/reference/declareDottedExtend.types index 7df6c9ecb7c..1c6c48c85c9 100644 --- a/tests/baselines/reference/declareDottedExtend.types +++ b/tests/baselines/reference/declareDottedExtend.types @@ -14,15 +14,15 @@ import ab = A.B; class D extends ab.C{ } >D : D ->ab.C : any +>ab.C : ab.C >ab : typeof ab ->C : ab.C +>C : typeof ab.C class E extends A.B.C{ } >E : E ->A.B.C : any +>A.B.C : ab.C >A.B : typeof ab >A : typeof A >B : typeof ab ->C : ab.C +>C : typeof ab.C diff --git a/tests/baselines/reference/deleteOperatorInvalidOperations.errors.txt b/tests/baselines/reference/deleteOperatorInvalidOperations.errors.txt index 5f7c6d70450..d50be713d0a 100644 --- a/tests/baselines/reference/deleteOperatorInvalidOperations.errors.txt +++ b/tests/baselines/reference/deleteOperatorInvalidOperations.errors.txt @@ -1,9 +1,10 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,20): error TS1005: ',' expected. tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,27): error TS1109: Expression expected. tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(8,23): error TS1109: Expression expected. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(13,16): error TS1102: 'delete' cannot be called on an identifier in strict mode. -==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts (3 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts (4 errors) ==== // Unary operator delete var ANY; @@ -23,5 +24,7 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator class testADelx { constructor(public s: () => {}) { delete s; //expect error + ~ +!!! error TS1102: 'delete' cannot be called on an identifier in strict mode. } } \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst11.errors.txt b/tests/baselines/reference/downlevelLetConst11.errors.txt index 42449bd3c8a..29932f55c1f 100644 --- a/tests/baselines/reference/downlevelLetConst11.errors.txt +++ b/tests/baselines/reference/downlevelLetConst11.errors.txt @@ -1,8 +1,11 @@ -tests/cases/compiler/downlevelLetConst11.ts(2,4): error TS1123: Variable declaration list cannot be empty. +tests/cases/compiler/downlevelLetConst11.ts(2,1): error TS1212: Identifier expected. 'let' is a reserved word in strict mode +tests/cases/compiler/downlevelLetConst11.ts(2,1): error TS2304: Cannot find name 'let'. -==== tests/cases/compiler/downlevelLetConst11.ts (1 errors) ==== +==== tests/cases/compiler/downlevelLetConst11.ts (2 errors) ==== "use strict"; let - -!!! error TS1123: Variable declaration list cannot be empty. \ No newline at end of file + ~~~ +!!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode + ~~~ +!!! error TS2304: Cannot find name 'let'. \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst11.js b/tests/baselines/reference/downlevelLetConst11.js index 377c7e6a9ed..e9749923d09 100644 --- a/tests/baselines/reference/downlevelLetConst11.js +++ b/tests/baselines/reference/downlevelLetConst11.js @@ -4,4 +4,4 @@ let //// [downlevelLetConst11.js] "use strict"; -var ; +let; diff --git a/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types b/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types index 0f546fa7b86..e469a377985 100644 --- a/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types @@ -9,11 +9,11 @@ class B { } class C extends B { } >C : C ->B : B +>B : B class D extends B { >D : D ->B : B +>B : B constructor(a: any) >a : any diff --git a/tests/baselines/reference/es6ClassTest7.types b/tests/baselines/reference/es6ClassTest7.types index f92ddad6e82..c0399204ffa 100644 --- a/tests/baselines/reference/es6ClassTest7.types +++ b/tests/baselines/reference/es6ClassTest7.types @@ -9,8 +9,8 @@ declare module M { class Bar extends M.Foo { >Bar : Bar ->M.Foo : any +>M.Foo : M.Foo >M : typeof M ->Foo : M.Foo +>Foo : typeof M.Foo } diff --git a/tests/baselines/reference/exportAssignmentOfGenericType1.types b/tests/baselines/reference/exportAssignmentOfGenericType1.types index 1bf3e7454a7..06ff38b2623 100644 --- a/tests/baselines/reference/exportAssignmentOfGenericType1.types +++ b/tests/baselines/reference/exportAssignmentOfGenericType1.types @@ -5,7 +5,7 @@ import q = require("exportAssignmentOfGenericType1_0"); class M extends q { } >M : M ->q : q +>q : q var m: M; >m : M diff --git a/tests/baselines/reference/exportNonInitializedVariablesAMD.errors.txt b/tests/baselines/reference/exportNonInitializedVariablesAMD.errors.txt index ae79675d8dd..28d7253a70c 100644 --- a/tests/baselines/reference/exportNonInitializedVariablesAMD.errors.txt +++ b/tests/baselines/reference/exportNonInitializedVariablesAMD.errors.txt @@ -1,15 +1,18 @@ tests/cases/conformance/externalModules/exportNonInitializedVariablesAMD.ts(2,4): error TS1123: Variable declaration list cannot be empty. +tests/cases/conformance/externalModules/exportNonInitializedVariablesAMD.ts(3,1): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. tests/cases/conformance/externalModules/exportNonInitializedVariablesAMD.ts(3,1): error TS2304: Cannot find name 'let'. tests/cases/conformance/externalModules/exportNonInitializedVariablesAMD.ts(4,6): error TS1123: Variable declaration list cannot be empty. -==== tests/cases/conformance/externalModules/exportNonInitializedVariablesAMD.ts (3 errors) ==== +==== tests/cases/conformance/externalModules/exportNonInitializedVariablesAMD.ts (4 errors) ==== var; !!! error TS1123: Variable declaration list cannot be empty. let; ~~~ +!!! error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. + ~~~ !!! error TS2304: Cannot find name 'let'. const; diff --git a/tests/baselines/reference/exportNonInitializedVariablesCommonJS.errors.txt b/tests/baselines/reference/exportNonInitializedVariablesCommonJS.errors.txt index 65a18649af3..84d4cab9c83 100644 --- a/tests/baselines/reference/exportNonInitializedVariablesCommonJS.errors.txt +++ b/tests/baselines/reference/exportNonInitializedVariablesCommonJS.errors.txt @@ -1,15 +1,18 @@ tests/cases/conformance/externalModules/exportNonInitializedVariablesCommonJS.ts(2,4): error TS1123: Variable declaration list cannot be empty. +tests/cases/conformance/externalModules/exportNonInitializedVariablesCommonJS.ts(3,1): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. tests/cases/conformance/externalModules/exportNonInitializedVariablesCommonJS.ts(3,1): error TS2304: Cannot find name 'let'. tests/cases/conformance/externalModules/exportNonInitializedVariablesCommonJS.ts(4,6): error TS1123: Variable declaration list cannot be empty. -==== tests/cases/conformance/externalModules/exportNonInitializedVariablesCommonJS.ts (3 errors) ==== +==== tests/cases/conformance/externalModules/exportNonInitializedVariablesCommonJS.ts (4 errors) ==== var; !!! error TS1123: Variable declaration list cannot be empty. let; ~~~ +!!! error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. + ~~~ !!! error TS2304: Cannot find name 'let'. const; diff --git a/tests/baselines/reference/exportNonInitializedVariablesES6.errors.txt b/tests/baselines/reference/exportNonInitializedVariablesES6.errors.txt index 905d16b360f..08e1d9588b6 100644 --- a/tests/baselines/reference/exportNonInitializedVariablesES6.errors.txt +++ b/tests/baselines/reference/exportNonInitializedVariablesES6.errors.txt @@ -1,15 +1,18 @@ tests/cases/conformance/externalModules/exportNonInitializedVariablesES6.ts(2,4): error TS1123: Variable declaration list cannot be empty. +tests/cases/conformance/externalModules/exportNonInitializedVariablesES6.ts(3,1): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. tests/cases/conformance/externalModules/exportNonInitializedVariablesES6.ts(3,1): error TS2304: Cannot find name 'let'. tests/cases/conformance/externalModules/exportNonInitializedVariablesES6.ts(4,6): error TS1123: Variable declaration list cannot be empty. -==== tests/cases/conformance/externalModules/exportNonInitializedVariablesES6.ts (3 errors) ==== +==== tests/cases/conformance/externalModules/exportNonInitializedVariablesES6.ts (4 errors) ==== var; !!! error TS1123: Variable declaration list cannot be empty. let; ~~~ +!!! error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. + ~~~ !!! error TS2304: Cannot find name 'let'. const; diff --git a/tests/baselines/reference/exportNonInitializedVariablesSystem.errors.txt b/tests/baselines/reference/exportNonInitializedVariablesSystem.errors.txt index d7aeb5d2ac0..1e461ea7253 100644 --- a/tests/baselines/reference/exportNonInitializedVariablesSystem.errors.txt +++ b/tests/baselines/reference/exportNonInitializedVariablesSystem.errors.txt @@ -1,15 +1,18 @@ tests/cases/conformance/externalModules/exportNonInitializedVariablesSystem.ts(2,4): error TS1123: Variable declaration list cannot be empty. +tests/cases/conformance/externalModules/exportNonInitializedVariablesSystem.ts(3,1): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. tests/cases/conformance/externalModules/exportNonInitializedVariablesSystem.ts(3,1): error TS2304: Cannot find name 'let'. tests/cases/conformance/externalModules/exportNonInitializedVariablesSystem.ts(4,6): error TS1123: Variable declaration list cannot be empty. -==== tests/cases/conformance/externalModules/exportNonInitializedVariablesSystem.ts (3 errors) ==== +==== tests/cases/conformance/externalModules/exportNonInitializedVariablesSystem.ts (4 errors) ==== var; !!! error TS1123: Variable declaration list cannot be empty. let; ~~~ +!!! error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. + ~~~ !!! error TS2304: Cannot find name 'let'. const; diff --git a/tests/baselines/reference/exportNonInitializedVariablesUMD.errors.txt b/tests/baselines/reference/exportNonInitializedVariablesUMD.errors.txt index eaf68e67055..b180c138501 100644 --- a/tests/baselines/reference/exportNonInitializedVariablesUMD.errors.txt +++ b/tests/baselines/reference/exportNonInitializedVariablesUMD.errors.txt @@ -1,15 +1,18 @@ tests/cases/conformance/externalModules/exportNonInitializedVariablesUMD.ts(2,4): error TS1123: Variable declaration list cannot be empty. +tests/cases/conformance/externalModules/exportNonInitializedVariablesUMD.ts(3,1): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. tests/cases/conformance/externalModules/exportNonInitializedVariablesUMD.ts(3,1): error TS2304: Cannot find name 'let'. tests/cases/conformance/externalModules/exportNonInitializedVariablesUMD.ts(4,6): error TS1123: Variable declaration list cannot be empty. -==== tests/cases/conformance/externalModules/exportNonInitializedVariablesUMD.ts (3 errors) ==== +==== tests/cases/conformance/externalModules/exportNonInitializedVariablesUMD.ts (4 errors) ==== var; !!! error TS1123: Variable declaration list cannot be empty. let; ~~~ +!!! error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. + ~~~ !!! error TS2304: Cannot find name 'let'. const; diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.errors.txt b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.errors.txt new file mode 100644 index 00000000000..6d443464d99 --- /dev/null +++ b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/es6/modules/t3.ts(1,17): error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode. + + +==== tests/cases/conformance/es6/modules/t1.ts (0 errors) ==== + + let set = { + set foo(x: number) { + } + } + let get = 10; + + export { set, get }; + +==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== + import * as set from "./t1"; + +==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ==== + import { set as yield } from "./t1"; + ~~~~~ +!!! error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode. + +==== tests/cases/conformance/es6/modules/t4.ts (0 errors) ==== + import { get } from "./t1"; \ No newline at end of file diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.symbols b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.symbols deleted file mode 100644 index f6695a9cf37..00000000000 --- a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.symbols +++ /dev/null @@ -1,30 +0,0 @@ -=== tests/cases/conformance/es6/modules/t1.ts === - -let set = { ->set : Symbol(set, Decl(t1.ts, 1, 3)) - - set foo(x: number) { ->foo : Symbol(foo, Decl(t1.ts, 1, 11)) ->x : Symbol(x, Decl(t1.ts, 2, 12)) - } -} -let get = 10; ->get : Symbol(get, Decl(t1.ts, 5, 3)) - -export { set, get }; ->set : Symbol(set, Decl(t1.ts, 7, 8)) ->get : Symbol(get, Decl(t1.ts, 7, 13)) - -=== tests/cases/conformance/es6/modules/t2.ts === -import * as set from "./t1"; ->set : Symbol(set, Decl(t2.ts, 0, 6)) - -=== tests/cases/conformance/es6/modules/t3.ts === -import { set as yield } from "./t1"; ->set : Symbol(yield, Decl(t3.ts, 0, 8)) ->yield : Symbol(yield, Decl(t3.ts, 0, 8)) - -=== tests/cases/conformance/es6/modules/t4.ts === -import { get } from "./t1"; ->get : Symbol(get, Decl(t4.ts, 0, 8)) - diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.types b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.types deleted file mode 100644 index a687787c462..00000000000 --- a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.types +++ /dev/null @@ -1,32 +0,0 @@ -=== tests/cases/conformance/es6/modules/t1.ts === - -let set = { ->set : { foo: number; } ->{ set foo(x: number) { }} : { foo: number; } - - set foo(x: number) { ->foo : number ->x : number - } -} -let get = 10; ->get : number ->10 : number - -export { set, get }; ->set : { foo: number; } ->get : number - -=== tests/cases/conformance/es6/modules/t2.ts === -import * as set from "./t1"; ->set : typeof set - -=== tests/cases/conformance/es6/modules/t3.ts === -import { set as yield } from "./t1"; ->set : { foo: number; } ->yield : { foo: number; } - -=== tests/cases/conformance/es6/modules/t4.ts === -import { get } from "./t1"; ->get : number - diff --git a/tests/baselines/reference/extBaseClass1.types b/tests/baselines/reference/extBaseClass1.types index b476e1b4206..1ab2ec3ba53 100644 --- a/tests/baselines/reference/extBaseClass1.types +++ b/tests/baselines/reference/extBaseClass1.types @@ -30,9 +30,9 @@ module N { export class C3 extends M.B { >C3 : C3 ->M.B : any +>M.B : M.B >M : typeof M ->B : M.B +>B : typeof M.B } } diff --git a/tests/baselines/reference/extBaseClass2.errors.txt b/tests/baselines/reference/extBaseClass2.errors.txt index 10c406b6ba0..b4d243c7ef2 100644 --- a/tests/baselines/reference/extBaseClass2.errors.txt +++ b/tests/baselines/reference/extBaseClass2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/extBaseClass2.ts(2,31): error TS2305: Module 'M' has no exported member 'B'. +tests/cases/compiler/extBaseClass2.ts(2,31): error TS2339: Property 'B' does not exist on type 'typeof M'. tests/cases/compiler/extBaseClass2.ts(7,29): error TS2304: Cannot find name 'B'. @@ -6,7 +6,7 @@ tests/cases/compiler/extBaseClass2.ts(7,29): error TS2304: Cannot find name 'B'. module N { export class C4 extends M.B { ~ -!!! error TS2305: Module 'M' has no exported member 'B'. +!!! error TS2339: Property 'B' does not exist on type 'typeof M'. } } diff --git a/tests/baselines/reference/extendNonClassSymbol1.errors.txt b/tests/baselines/reference/extendNonClassSymbol1.errors.txt deleted file mode 100644 index 587ac3a5f04..00000000000 --- a/tests/baselines/reference/extendNonClassSymbol1.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/compiler/extendNonClassSymbol1.ts(3,17): error TS2304: Cannot find name 'x'. - - -==== tests/cases/compiler/extendNonClassSymbol1.ts (1 errors) ==== - class A { foo() { } } - var x = A; - class C extends x { } // error, could not find symbol xs - ~ -!!! error TS2304: Cannot find name 'x'. \ No newline at end of file diff --git a/tests/baselines/reference/extendNonClassSymbol1.symbols b/tests/baselines/reference/extendNonClassSymbol1.symbols new file mode 100644 index 00000000000..02291ebb181 --- /dev/null +++ b/tests/baselines/reference/extendNonClassSymbol1.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/extendNonClassSymbol1.ts === +class A { foo() { } } +>A : Symbol(A, Decl(extendNonClassSymbol1.ts, 0, 0)) +>foo : Symbol(foo, Decl(extendNonClassSymbol1.ts, 0, 9)) + +var x = A; +>x : Symbol(x, Decl(extendNonClassSymbol1.ts, 1, 3)) +>A : Symbol(A, Decl(extendNonClassSymbol1.ts, 0, 0)) + +class C extends x { } // error, could not find symbol xs +>C : Symbol(C, Decl(extendNonClassSymbol1.ts, 1, 10)) + diff --git a/tests/baselines/reference/extendNonClassSymbol1.types b/tests/baselines/reference/extendNonClassSymbol1.types new file mode 100644 index 00000000000..72ae7b4566c --- /dev/null +++ b/tests/baselines/reference/extendNonClassSymbol1.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/extendNonClassSymbol1.ts === +class A { foo() { } } +>A : A +>foo : () => void + +var x = A; +>x : typeof A +>A : typeof A + +class C extends x { } // error, could not find symbol xs +>C : C +>x : A + diff --git a/tests/baselines/reference/extendNonClassSymbol2.errors.txt b/tests/baselines/reference/extendNonClassSymbol2.errors.txt index 1b54474ac39..882a8b447f8 100644 --- a/tests/baselines/reference/extendNonClassSymbol2.errors.txt +++ b/tests/baselines/reference/extendNonClassSymbol2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/extendNonClassSymbol2.ts(5,17): error TS2304: Cannot find name 'Foo'. +tests/cases/compiler/extendNonClassSymbol2.ts(5,17): error TS2507: Base expression is not of a constructor function type. ==== tests/cases/compiler/extendNonClassSymbol2.ts (1 errors) ==== @@ -8,4 +8,4 @@ tests/cases/compiler/extendNonClassSymbol2.ts(5,17): error TS2304: Cannot find n var x = new Foo(); // legal, considered a constructor function class C extends Foo {} // error, could not find symbol Foo ~~~ -!!! error TS2304: Cannot find name 'Foo'. \ No newline at end of file +!!! error TS2507: Base expression is not of a constructor function type. \ No newline at end of file diff --git a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types index 5b9154516c5..b5323ae5c85 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types @@ -61,9 +61,9 @@ import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // interesting stuff here } @@ -74,9 +74,9 @@ import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); export class VisualizationModel extends Backbone.Model { >VisualizationModel : VisualizationModel ->Backbone.Model : any +>Backbone.Model : Backbone.Model >Backbone : typeof Backbone ->Model : Backbone.Model +>Model : typeof Backbone.Model // different interesting stuff here } diff --git a/tests/baselines/reference/generatorTypeCheck40.errors.txt b/tests/baselines/reference/generatorTypeCheck40.errors.txt index 9d9676e5d28..6341ec9ae0a 100644 --- a/tests/baselines/reference/generatorTypeCheck40.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck40.errors.txt @@ -1,9 +1,12 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts(2,21): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts(2,21): error TS2507: Base expression is not of a constructor function type. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts(2,22): error TS1163: A 'yield' expression is only allowed in a generator body. -==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts (2 errors) ==== function* g() { class C extends (yield 0) { } ~~~~~~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +!!! error TS2507: Base expression is not of a constructor function type. + ~~~~~ +!!! error TS1163: A 'yield' expression is only allowed in a generator body. } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck60.errors.txt b/tests/baselines/reference/generatorTypeCheck60.errors.txt index d8e5d640bb1..4d230a81b5b 100644 --- a/tests/baselines/reference/generatorTypeCheck60.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck60.errors.txt @@ -1,9 +1,12 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck60.ts(2,21): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck60.ts(2,21): error TS2507: Base expression is not of a constructor function type. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck60.ts(2,22): error TS1163: A 'yield' expression is only allowed in a generator body. -==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck60.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck60.ts (2 errors) ==== function* g() { class C extends (yield) {}; ~~~~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +!!! error TS2507: Base expression is not of a constructor function type. + ~~~~~ +!!! error TS1163: A 'yield' expression is only allowed in a generator body. } \ No newline at end of file diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty.types b/tests/baselines/reference/genericBaseClassLiteralProperty.types index 51246348ded..87f1c55c42d 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty.types +++ b/tests/baselines/reference/genericBaseClassLiteralProperty.types @@ -14,7 +14,7 @@ class BaseClass { class SubClass extends BaseClass { >SubClass : SubClass ->BaseClass : BaseClass +>BaseClass : BaseClass public Error(): void { >Error : () => void diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty2.types b/tests/baselines/reference/genericBaseClassLiteralProperty2.types index 4576ffb05de..271aa190037 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty2.types +++ b/tests/baselines/reference/genericBaseClassLiteralProperty2.types @@ -24,7 +24,7 @@ class BaseCollection2 { class DataView2 extends BaseCollection2 { >DataView2 : DataView2 ->BaseCollection2 : BaseCollection2 +>BaseCollection2 : BaseCollection2 >CollectionItem2 : CollectionItem2 fillItems(item: CollectionItem2) { diff --git a/tests/baselines/reference/genericCallbacksAndClassHierarchy.types b/tests/baselines/reference/genericCallbacksAndClassHierarchy.types index 97e584dca3f..cb12737a937 100644 --- a/tests/baselines/reference/genericCallbacksAndClassHierarchy.types +++ b/tests/baselines/reference/genericCallbacksAndClassHierarchy.types @@ -31,7 +31,7 @@ module M { export class B extends C1> { } >B : B >T : T ->C1 : C1 +>C1 : C1> >A : A >T : T diff --git a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.types b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.types index 800b215f123..28daf6d38ee 100644 --- a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.types +++ b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.types @@ -1,7 +1,7 @@ === tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts === class A extends B { } >A : A ->B : B +>B : B class B extends C { } >B : B diff --git a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.types b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.types index 6ba27a66399..88ef74283ae 100644 --- a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.types +++ b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.types @@ -192,13 +192,13 @@ module PortalFx.ViewModels.Controls.Validators { export class Validator extends Portal.Controls.Validators.Validator { >Validator : Validator >TValue : TValue ->Portal.Controls.Validators.Validator : any +>Portal.Controls.Validators.Validator : Portal.Controls.Validators.Validator >Portal.Controls.Validators : typeof Portal.Controls.Validators >Portal.Controls : typeof Portal.Controls >Portal : typeof Portal >Controls : typeof Portal.Controls >Validators : typeof Portal.Controls.Validators ->Validator : Portal.Controls.Validators.Validator +>Validator : typeof Portal.Controls.Validators.Validator >TValue : TValue constructor(message?: string) { diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.types b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.types index f1041cfa80f..9a4b209bc97 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.types +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.types @@ -53,7 +53,7 @@ module EndGate.Tweening { export class NumberTween extends Tween{ >NumberTween : NumberTween ->Tween : Tween +>Tween : Tween constructor(from: number) { >from : number diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.types b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.types index 92ffa7c5c03..ba42e42ae0c 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.types +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.types @@ -52,7 +52,7 @@ module EndGate.Tweening { export class NumberTween extends Tween{ >NumberTween : NumberTween ->Tween : Tween +>Tween : Tween >Number : Number constructor(from: number) { diff --git a/tests/baselines/reference/genericTypeConstraints.errors.txt b/tests/baselines/reference/genericTypeConstraints.errors.txt index 9fd8b5f15be..ae97572b56a 100644 --- a/tests/baselines/reference/genericTypeConstraints.errors.txt +++ b/tests/baselines/reference/genericTypeConstraints.errors.txt @@ -1,9 +1,8 @@ -tests/cases/compiler/genericTypeConstraints.ts(9,27): error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'. - Property 'fooMethod' is missing in type 'FooExtended'. tests/cases/compiler/genericTypeConstraints.ts(9,31): error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'. + Property 'fooMethod' is missing in type 'FooExtended'. -==== tests/cases/compiler/genericTypeConstraints.ts (2 errors) ==== +==== tests/cases/compiler/genericTypeConstraints.ts (1 errors) ==== class Foo { fooMethod() {} } @@ -13,11 +12,9 @@ tests/cases/compiler/genericTypeConstraints.ts(9,31): error TS2344: Type 'FooExt class Bar { } class BarExtended extends Bar { - ~~~~~~~~~~~~~~~~ -!!! error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'. -!!! error TS2344: Property 'fooMethod' is missing in type 'FooExtended'. ~~~~~~~~~~~ !!! error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'. +!!! error TS2344: Property 'fooMethod' is missing in type 'FooExtended'. constructor() { super(); } diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt index 5ae71fa2a89..2f6db48bf2f 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt @@ -8,7 +8,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(14,23): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(14,27): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(16,25): error TS2314: Generic type 'C' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(22,28): error TS2305: Module 'M' has no exported member 'C'. +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(22,28): error TS2339: Property 'C' does not exist on type 'typeof M'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(23,28): error TS2314: Generic type 'E' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(25,30): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(26,30): error TS2314: Generic type 'E' requires 1 type argument(s). @@ -58,7 +58,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc declare class D2 extends M.C { } ~ -!!! error TS2305: Module 'M' has no exported member 'C'. +!!! error TS2339: Property 'C' does not exist on type 'typeof M'. declare class D3 { } ~~~ !!! error TS2314: Generic type 'E' requires 1 type argument(s). diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt index 2949ce52ce0..e590ad42a7d 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt @@ -13,9 +13,9 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(18,23): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(18,27): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(18,38): error TS2314: Generic type 'I' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(20,17): error TS2314: Generic type 'I' requires 1 type argument(s). +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(20,17): error TS2304: Cannot find name 'I'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(23,21): error TS2314: Generic type 'I' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(29,20): error TS2305: Module 'M' has no exported member 'C'. +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(29,18): error TS2304: Cannot find name 'M'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(30,24): error TS2314: Generic type 'E' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(31,24): error TS2305: Module 'M' has no exported member 'C'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(33,22): error TS2314: Generic type 'I' requires 1 type argument(s). @@ -76,7 +76,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc class D extends I { ~ -!!! error TS2314: Generic type 'I' requires 1 type argument(s). +!!! error TS2304: Cannot find name 'I'. } interface U extends I {} @@ -88,8 +88,8 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc } class D2 extends M.C { } - ~ -!!! error TS2305: Module 'M' has no exported member 'C'. + ~ +!!! error TS2304: Cannot find name 'M'. interface D3 { } ~~~ !!! error TS2314: Generic type 'E' requires 1 type argument(s). diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt index c0e41374527..95857c925be 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt @@ -8,7 +8,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(14,23): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(14,27): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(16,25): error TS2314: Generic type 'C' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(22,28): error TS2305: Module 'M' has no exported member 'C'. +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(22,28): error TS2339: Property 'C' does not exist on type 'typeof M'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(23,28): error TS2314: Generic type 'E' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(25,30): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(26,30): error TS2314: Generic type 'E' requires 1 type argument(s). @@ -58,7 +58,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc declare class D2 extends M.C { } ~ -!!! error TS2305: Module 'M' has no exported member 'C'. +!!! error TS2339: Property 'C' does not exist on type 'typeof M'. declare class D3 { } ~~~ !!! error TS2314: Generic type 'E' requires 1 type argument(s). diff --git a/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.types b/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.types index e1cdfa85f13..2005604c83c 100644 --- a/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.types +++ b/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.types @@ -12,7 +12,7 @@ export class Collection { export class List extends Collection{ >List : List ->Collection : Collection +>Collection : Collection >ListItem : ListItem Bar() {} diff --git a/tests/baselines/reference/generics1.errors.txt b/tests/baselines/reference/generics1.errors.txt index 81d250a2ef4..6279c0dcd63 100644 --- a/tests/baselines/reference/generics1.errors.txt +++ b/tests/baselines/reference/generics1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/generics1.ts(10,9): error TS2344: Type 'A' does not satisfy the constraint 'B'. +tests/cases/compiler/generics1.ts(10,14): error TS2344: Type 'A' does not satisfy the constraint 'B'. Property 'b' is missing in type 'A'. tests/cases/compiler/generics1.ts(13,9): error TS2314: Generic type 'G' requires 2 type argument(s). tests/cases/compiler/generics1.ts(14,9): error TS2314: Generic type 'G' requires 2 type argument(s). @@ -15,7 +15,7 @@ tests/cases/compiler/generics1.ts(14,9): error TS2314: Generic type 'G' re var v1: G; // Ok var v2: G<{ a: string }, C>; // Ok, equivalent to G var v3: G; // Error, A not valid argument for U - ~~~~~~~ + ~ !!! error TS2344: Type 'A' does not satisfy the constraint 'B'. !!! error TS2344: Property 'b' is missing in type 'A'. var v4: G, C>; // Ok diff --git a/tests/baselines/reference/generics2.errors.txt b/tests/baselines/reference/generics2.errors.txt index a0380eee753..d44bc7baad8 100644 --- a/tests/baselines/reference/generics2.errors.txt +++ b/tests/baselines/reference/generics2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/generics2.ts(17,9): error TS2344: Type 'A' does not satisfy the constraint 'B'. +tests/cases/compiler/generics2.ts(17,14): error TS2344: Type 'A' does not satisfy the constraint 'B'. Property 'b' is missing in type 'A'. tests/cases/compiler/generics2.ts(20,9): error TS2314: Generic type 'G' requires 2 type argument(s). tests/cases/compiler/generics2.ts(21,9): error TS2314: Generic type 'G' requires 2 type argument(s). @@ -22,7 +22,7 @@ tests/cases/compiler/generics2.ts(21,9): error TS2314: Generic type 'G' re var v2: G<{ a: string }, C>; // Ok, equivalent to G var v3: G; // Error, A not valid argument for U - ~~~~~~~ + ~ !!! error TS2344: Type 'A' does not satisfy the constraint 'B'. !!! error TS2344: Property 'b' is missing in type 'A'. var v4: G, C>; // Ok diff --git a/tests/baselines/reference/generics5.errors.txt b/tests/baselines/reference/generics5.errors.txt index 17aeea63df2..fd21a705436 100644 --- a/tests/baselines/reference/generics5.errors.txt +++ b/tests/baselines/reference/generics5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/generics5.ts(10,9): error TS2344: Type 'A' does not satisfy the constraint 'B'. +tests/cases/compiler/generics5.ts(10,14): error TS2344: Type 'A' does not satisfy the constraint 'B'. Property 'b' is missing in type 'A'. @@ -13,7 +13,7 @@ tests/cases/compiler/generics5.ts(10,9): error TS2344: Type 'A' does not satisfy } var v3: G; // Error, A not valid argument for U - ~~~~~~~ + ~ !!! error TS2344: Type 'A' does not satisfy the constraint 'B'. !!! error TS2344: Property 'b' is missing in type 'A'. diff --git a/tests/baselines/reference/importAsBaseClass.errors.txt b/tests/baselines/reference/importAsBaseClass.errors.txt index f09eb55561b..4b923ea2323 100644 --- a/tests/baselines/reference/importAsBaseClass.errors.txt +++ b/tests/baselines/reference/importAsBaseClass.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/importAsBaseClass_1.ts(2,21): error TS2304: Cannot find name 'Greeter'. +tests/cases/compiler/importAsBaseClass_1.ts(2,21): error TS2507: Base expression is not of a constructor function type. ==== tests/cases/compiler/importAsBaseClass_1.ts (1 errors) ==== import Greeter = require("importAsBaseClass_0"); class Hello extends Greeter { } ~~~~~~~ -!!! error TS2304: Cannot find name 'Greeter'. +!!! error TS2507: Base expression is not of a constructor function type. ==== tests/cases/compiler/importAsBaseClass_0.ts (0 errors) ==== export class Greeter { diff --git a/tests/baselines/reference/importAsBaseClass.js b/tests/baselines/reference/importAsBaseClass.js index 24f7e0477d6..b40fd563733 100644 --- a/tests/baselines/reference/importAsBaseClass.js +++ b/tests/baselines/reference/importAsBaseClass.js @@ -25,6 +25,7 @@ var __extends = (this && this.__extends) || function (d, b) { __.prototype = b.prototype; d.prototype = new __(); }; +var Greeter = require("importAsBaseClass_0"); var Hello = (function (_super) { __extends(Hello, _super); function Hello() { diff --git a/tests/baselines/reference/importUsedInExtendsList1.types b/tests/baselines/reference/importUsedInExtendsList1.types index 74737c4db96..3c1b69f5a83 100644 --- a/tests/baselines/reference/importUsedInExtendsList1.types +++ b/tests/baselines/reference/importUsedInExtendsList1.types @@ -5,9 +5,9 @@ import foo = require('importUsedInExtendsList1_require'); class Sub extends foo.Super { } >Sub : Sub ->foo.Super : any +>foo.Super : foo.Super >foo : typeof foo ->Super : foo.Super +>Super : typeof foo.Super var s: Sub; >s : Sub diff --git a/tests/baselines/reference/indirectSelfReference.errors.txt b/tests/baselines/reference/indirectSelfReference.errors.txt index e7c5a00d421..3f7d3d47f12 100644 --- a/tests/baselines/reference/indirectSelfReference.errors.txt +++ b/tests/baselines/reference/indirectSelfReference.errors.txt @@ -1,8 +1,11 @@ -tests/cases/compiler/indirectSelfReference.ts(1,7): error TS2310: Type 'a' recursively references itself as a base type. +tests/cases/compiler/indirectSelfReference.ts(1,7): error TS2506: 'a' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/indirectSelfReference.ts(2,7): error TS2506: 'b' is referenced directly or indirectly in its own base expression. -==== tests/cases/compiler/indirectSelfReference.ts (1 errors) ==== +==== tests/cases/compiler/indirectSelfReference.ts (2 errors) ==== class a extends b{ } ~ -!!! error TS2310: Type 'a' recursively references itself as a base type. - class b extends a{ } \ No newline at end of file +!!! error TS2506: 'a' is referenced directly or indirectly in its own base expression. + class b extends a{ } + ~ +!!! error TS2506: 'b' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt b/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt index 765112f0e99..5a6aeed5de1 100644 --- a/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt +++ b/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt @@ -1,8 +1,11 @@ -tests/cases/compiler/indirectSelfReferenceGeneric.ts(1,7): error TS2310: Type 'a' recursively references itself as a base type. +tests/cases/compiler/indirectSelfReferenceGeneric.ts(1,7): error TS2506: 'a' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/indirectSelfReferenceGeneric.ts(2,7): error TS2506: 'b' is referenced directly or indirectly in its own base expression. -==== tests/cases/compiler/indirectSelfReferenceGeneric.ts (1 errors) ==== +==== tests/cases/compiler/indirectSelfReferenceGeneric.ts (2 errors) ==== class a extends b { } ~ -!!! error TS2310: Type 'a' recursively references itself as a base type. - class b extends a { } \ No newline at end of file +!!! error TS2506: 'a' is referenced directly or indirectly in its own base expression. + class b extends a { } + ~ +!!! error TS2506: 'b' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt b/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt index a9b3cb4b686..c043e37575c 100644 --- a/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt +++ b/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2311: A class may only extend another class. +tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2304: Cannot find name 'T'. tests/cases/compiler/inheritFromGenericTypeParameter.ts(2,24): error TS2312: An interface may only extend a class or another interface. ==== tests/cases/compiler/inheritFromGenericTypeParameter.ts (2 errors) ==== class C extends T { } ~ -!!! error TS2311: A class may only extend another class. +!!! error TS2304: Cannot find name 'T'. interface I extends T { } ~ !!! error TS2312: An interface may only extend a class or another interface. \ No newline at end of file diff --git a/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.types b/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.types index 119b6a19046..c976e905db7 100644 --- a/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.types +++ b/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.types @@ -14,16 +14,16 @@ module N { export class D1 extends M.C1 { } >D1 : D1 ->M.C1 : any +>M.C1 : M.C1 >M : typeof M ->C1 : M.C1 +>C1 : typeof M.C1 export class D2 extends M.C2 { } >D2 : D2 >T : T ->M.C2 : any +>M.C2 : M.C2 >M : typeof M ->C2 : M.C2 +>C2 : typeof M.C2 >T : T } diff --git a/tests/baselines/reference/letAsIdentifier.errors.txt b/tests/baselines/reference/letAsIdentifier.errors.txt new file mode 100644 index 00000000000..b4e4db22853 --- /dev/null +++ b/tests/baselines/reference/letAsIdentifier.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/letAsIdentifier.ts(3,5): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/letAsIdentifier.ts(6,1): error TS2300: Duplicate identifier 'a'. + + +==== tests/cases/compiler/letAsIdentifier.ts (2 errors) ==== + + var let = 10; + var a = 10; + ~ +!!! error TS2300: Duplicate identifier 'a'. + let = 30; + let + a; + ~ +!!! error TS2300: Duplicate identifier 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/letAsIdentifier.js b/tests/baselines/reference/letAsIdentifier.js index ae45b4b491c..05811ce1088 100644 --- a/tests/baselines/reference/letAsIdentifier.js +++ b/tests/baselines/reference/letAsIdentifier.js @@ -10,10 +10,10 @@ a; var let = 10; var a = 10; let = 30; -let; -a; +var a; //// [letAsIdentifier.d.ts] declare var let: number; declare var a: number; +declare let a: any; diff --git a/tests/baselines/reference/letAsIdentifier.symbols b/tests/baselines/reference/letAsIdentifier.symbols deleted file mode 100644 index be5066f5ac7..00000000000 --- a/tests/baselines/reference/letAsIdentifier.symbols +++ /dev/null @@ -1,17 +0,0 @@ -=== tests/cases/compiler/letAsIdentifier.ts === - -var let = 10; ->let : Symbol(let, Decl(letAsIdentifier.ts, 1, 3)) - -var a = 10; ->a : Symbol(a, Decl(letAsIdentifier.ts, 2, 3)) - -let = 30; ->let : Symbol(let, Decl(letAsIdentifier.ts, 1, 3)) - -let ->let : Symbol(let, Decl(letAsIdentifier.ts, 1, 3)) - -a; ->a : Symbol(a, Decl(letAsIdentifier.ts, 2, 3)) - diff --git a/tests/baselines/reference/letAsIdentifier.types b/tests/baselines/reference/letAsIdentifier.types deleted file mode 100644 index 36c190a92e4..00000000000 --- a/tests/baselines/reference/letAsIdentifier.types +++ /dev/null @@ -1,21 +0,0 @@ -=== tests/cases/compiler/letAsIdentifier.ts === - -var let = 10; ->let : number ->10 : number - -var a = 10; ->a : number ->10 : number - -let = 30; ->let = 30 : number ->let : number ->30 : number - -let ->let : number - -a; ->a : number - diff --git a/tests/baselines/reference/letAsIdentifierInStrictMode.errors.txt b/tests/baselines/reference/letAsIdentifierInStrictMode.errors.txt index b59daca008c..42f71669c66 100644 --- a/tests/baselines/reference/letAsIdentifierInStrictMode.errors.txt +++ b/tests/baselines/reference/letAsIdentifierInStrictMode.errors.txt @@ -1,20 +1,20 @@ +tests/cases/compiler/letAsIdentifierInStrictMode.ts(2,5): error TS1212: Identifier expected. 'let' is a reserved word in strict mode tests/cases/compiler/letAsIdentifierInStrictMode.ts(3,5): error TS2300: Duplicate identifier 'a'. -tests/cases/compiler/letAsIdentifierInStrictMode.ts(4,5): error TS1134: Variable declaration expected. -tests/cases/compiler/letAsIdentifierInStrictMode.ts(4,7): error TS1134: Variable declaration expected. +tests/cases/compiler/letAsIdentifierInStrictMode.ts(4,1): error TS1212: Identifier expected. 'let' is a reserved word in strict mode tests/cases/compiler/letAsIdentifierInStrictMode.ts(6,1): error TS2300: Duplicate identifier 'a'. ==== tests/cases/compiler/letAsIdentifierInStrictMode.ts (4 errors) ==== "use strict"; var let = 10; + ~~~ +!!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode var a = 10; ~ !!! error TS2300: Duplicate identifier 'a'. let = 30; - ~ -!!! error TS1134: Variable declaration expected. - ~~ -!!! error TS1134: Variable declaration expected. + ~~~ +!!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode let a; ~ diff --git a/tests/baselines/reference/letAsIdentifierInStrictMode.js b/tests/baselines/reference/letAsIdentifierInStrictMode.js index eb840e1a641..cce0b13cf64 100644 --- a/tests/baselines/reference/letAsIdentifierInStrictMode.js +++ b/tests/baselines/reference/letAsIdentifierInStrictMode.js @@ -10,6 +10,5 @@ a; "use strict"; var let = 10; var a = 10; -var ; -30; +let = 30; var a; diff --git a/tests/baselines/reference/moduleImportedForTypeArgumentPosition.types b/tests/baselines/reference/moduleImportedForTypeArgumentPosition.types index 0a85e6e0002..d3ef4e4e9ce 100644 --- a/tests/baselines/reference/moduleImportedForTypeArgumentPosition.types +++ b/tests/baselines/reference/moduleImportedForTypeArgumentPosition.types @@ -9,7 +9,7 @@ class C1{ } class Test1 extends C1 { >Test1 : Test1 ->C1 : C1 +>C1 : C1 >M2 : any >M2C : M2.M2C } diff --git a/tests/baselines/reference/moduleWithStatementsOfEveryKind.types b/tests/baselines/reference/moduleWithStatementsOfEveryKind.types index 9475d9cfdcb..c6f4be850be 100644 --- a/tests/baselines/reference/moduleWithStatementsOfEveryKind.types +++ b/tests/baselines/reference/moduleWithStatementsOfEveryKind.types @@ -18,7 +18,7 @@ module A { class B extends AA implements I { id: number } >B : B ->AA : AA +>AA : AA >I : I >id : number @@ -106,7 +106,7 @@ module Y { export class B extends AA implements I { id: number } >B : B ->AA : AA +>AA : AA >I : I >id : number diff --git a/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.types b/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.types index 177becac643..4eb4c61aedf 100644 --- a/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.types +++ b/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.types @@ -10,5 +10,5 @@ class Foo { class Bar extends Foo { } // Valid >Bar : Bar ->Foo : Foo +>Foo : Foo diff --git a/tests/baselines/reference/overloadresolutionWithConstraintCheckingDeferred.errors.txt b/tests/baselines/reference/overloadresolutionWithConstraintCheckingDeferred.errors.txt index 35837d3233f..45c9f99b691 100644 --- a/tests/baselines/reference/overloadresolutionWithConstraintCheckingDeferred.errors.txt +++ b/tests/baselines/reference/overloadresolutionWithConstraintCheckingDeferred.errors.txt @@ -7,7 +7,7 @@ tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(18,27): Types of parameters 'x' and 'x' are incompatible. Type 'D' is not assignable to type 'B'. Property 'x' is missing in type 'D'. -tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,12): error TS2344: Type 'D' does not satisfy the constraint 'A'. +tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,14): error TS2344: Type 'D' does not satisfy the constraint 'A'. ==== tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts (6 errors) ==== @@ -41,7 +41,7 @@ tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,12): ~~~~~~~~~~~~~~~~~~~~~~ var y: G; // error that D does not satisfy constraint, y is of type G, entire call to foo is an error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2344: Type 'D' does not satisfy the constraint 'A'. return y; ~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.errors.txt b/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.errors.txt index 21bf243dfcb..3c67ff44fd3 100644 --- a/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.errors.txt +++ b/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.ts(5,26): error TS2305: Module 'Alpha' has no exported member 'x'. +tests/cases/compiler/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.ts(5,20): error TS2507: Base expression is not of a constructor function type. ==== tests/cases/compiler/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/qualifiedName_entity-name-resolution-does-not-affect-class- } class Beta extends Alpha.x { - ~ -!!! error TS2305: Module 'Alpha' has no exported member 'x'. + ~~~~~~~ +!!! error TS2507: Base expression is not of a constructor function type. } \ No newline at end of file diff --git a/tests/baselines/reference/recursiveBaseCheck.errors.txt b/tests/baselines/reference/recursiveBaseCheck.errors.txt index 06915b6b430..0ada6976a83 100644 --- a/tests/baselines/reference/recursiveBaseCheck.errors.txt +++ b/tests/baselines/reference/recursiveBaseCheck.errors.txt @@ -1,19 +1,31 @@ -tests/cases/compiler/recursiveBaseCheck.ts(2,11): error TS2310: Type 'C' recursively references itself as a base type. +tests/cases/compiler/recursiveBaseCheck.ts(2,11): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck.ts(4,18): error TS2506: 'B' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck.ts(6,18): error TS2506: 'A' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck.ts(8,18): error TS2506: 'AmChart' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck.ts(10,18): error TS2506: 'D' is referenced directly or indirectly in its own base expression. -==== tests/cases/compiler/recursiveBaseCheck.ts (1 errors) ==== +==== tests/cases/compiler/recursiveBaseCheck.ts (5 errors) ==== declare module Module { class C extends D { ~ -!!! error TS2310: Type 'C' recursively references itself as a base type. +!!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. } export class B extends Module.C { + ~ +!!! error TS2506: 'B' is referenced directly or indirectly in its own base expression. } export class A extends Module.B { + ~ +!!! error TS2506: 'A' is referenced directly or indirectly in its own base expression. } export class AmChart extends Module.A { + ~~~~~~~ +!!! error TS2506: 'AmChart' is referenced directly or indirectly in its own base expression. } export class D extends AmChart { + ~ +!!! error TS2506: 'D' is referenced directly or indirectly in its own base expression. } export class E extends Module.D { } diff --git a/tests/baselines/reference/recursiveBaseCheck2.errors.txt b/tests/baselines/reference/recursiveBaseCheck2.errors.txt index 1a39f811912..31eb1104003 100644 --- a/tests/baselines/reference/recursiveBaseCheck2.errors.txt +++ b/tests/baselines/reference/recursiveBaseCheck2.errors.txt @@ -1,13 +1,16 @@ -tests/cases/compiler/recursiveBaseCheck2.ts(2,18): error TS2310: Type 'b2CircleShape' recursively references itself as a base type. +tests/cases/compiler/recursiveBaseCheck2.ts(2,18): error TS2506: 'b2CircleShape' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck2.ts(4,18): error TS2506: 'b2Shape' is referenced directly or indirectly in its own base expression. -==== tests/cases/compiler/recursiveBaseCheck2.ts (1 errors) ==== +==== tests/cases/compiler/recursiveBaseCheck2.ts (2 errors) ==== declare module Box2D.Collision.Shapes { export class b2CircleShape extends b2Shape { ~~~~~~~~~~~~~ -!!! error TS2310: Type 'b2CircleShape' recursively references itself as a base type. +!!! error TS2506: 'b2CircleShape' is referenced directly or indirectly in its own base expression. } export class b2Shape extends Box2D.Collision.Shapes.b2CircleShape { + ~~~~~~~ +!!! error TS2506: 'b2Shape' is referenced directly or indirectly in its own base expression. } } declare module Box2D.Dynamics { diff --git a/tests/baselines/reference/recursiveBaseCheck3.errors.txt b/tests/baselines/reference/recursiveBaseCheck3.errors.txt index fe955b420ee..97f7cadc3d6 100644 --- a/tests/baselines/reference/recursiveBaseCheck3.errors.txt +++ b/tests/baselines/reference/recursiveBaseCheck3.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/recursiveBaseCheck3.ts(1,7): error TS2310: Type 'A' recursively references itself as a base type. +tests/cases/compiler/recursiveBaseCheck3.ts(1,7): error TS2506: 'A' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck3.ts(2,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. tests/cases/compiler/recursiveBaseCheck3.ts(4,9): error TS2339: Property 'blah' does not exist on type 'C<{}>'. -==== tests/cases/compiler/recursiveBaseCheck3.ts (2 errors) ==== +==== tests/cases/compiler/recursiveBaseCheck3.ts (3 errors) ==== class A extends C { } ~ -!!! error TS2310: Type 'A' recursively references itself as a base type. +!!! error TS2506: 'A' is referenced directly or indirectly in its own base expression. class C extends A { } + ~ +!!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. (new C).blah; ~~~~ diff --git a/tests/baselines/reference/recursiveBaseCheck4.errors.txt b/tests/baselines/reference/recursiveBaseCheck4.errors.txt index 4417b998871..5616523d14e 100644 --- a/tests/baselines/reference/recursiveBaseCheck4.errors.txt +++ b/tests/baselines/reference/recursiveBaseCheck4.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/recursiveBaseCheck4.ts(1,7): error TS2310: Type 'M' recursively references itself as a base type. +tests/cases/compiler/recursiveBaseCheck4.ts(1,7): error TS2506: 'M' is referenced directly or indirectly in its own base expression. tests/cases/compiler/recursiveBaseCheck4.ts(2,9): error TS2339: Property 'blah' does not exist on type 'M<{}>'. ==== tests/cases/compiler/recursiveBaseCheck4.ts (2 errors) ==== class M extends M { } ~ -!!! error TS2310: Type 'M' recursively references itself as a base type. +!!! error TS2506: 'M' is referenced directly or indirectly in its own base expression. (new M).blah; ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'M<{}>'. \ No newline at end of file diff --git a/tests/baselines/reference/recursiveBaseCheck6.errors.txt b/tests/baselines/reference/recursiveBaseCheck6.errors.txt index 280f50b7a77..6d453da425f 100644 --- a/tests/baselines/reference/recursiveBaseCheck6.errors.txt +++ b/tests/baselines/reference/recursiveBaseCheck6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/recursiveBaseCheck6.ts(1,7): error TS2310: Type 'S18' recursively references itself as a base type. +tests/cases/compiler/recursiveBaseCheck6.ts(1,7): error TS2506: 'S18' is referenced directly or indirectly in its own base expression. tests/cases/compiler/recursiveBaseCheck6.ts(2,13): error TS2339: Property 'blah' does not exist on type 'S18<{}>'. ==== tests/cases/compiler/recursiveBaseCheck6.ts (2 errors) ==== class S18 extends S18<{ S19: A; }>{ } ~~~ -!!! error TS2310: Type 'S18' recursively references itself as a base type. +!!! error TS2506: 'S18' is referenced directly or indirectly in its own base expression. (new S18()).blah; ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'S18<{}>'. \ No newline at end of file diff --git a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.types b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.types index bccd226ceba..af9e13d4002 100644 --- a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.types +++ b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.types @@ -29,7 +29,7 @@ module MsPortal.Controls.Base.ItemList { export class ViewModel extends ItemValue { >ViewModel : ViewModel >TValue : TValue ->ItemValue : ItemValue +>ItemValue : ItemValue >TValue : TValue } } diff --git a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.types b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.types index 43db869265b..c9025b56502 100644 --- a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.types +++ b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.types @@ -4,9 +4,9 @@ module rionegrensis { export class caniventer extends Lanthanum.nitidus { >caniventer : caniventer ->Lanthanum.nitidus : any +>Lanthanum.nitidus : Lanthanum.nitidus >Lanthanum : typeof Lanthanum ->nitidus : Lanthanum.nitidus +>nitidus : typeof Lanthanum.nitidus >petrophilus : any >minutilla : petrophilus.minutilla >julianae : any @@ -90,9 +90,9 @@ module rionegrensis { >veraecrucis : veraecrucis >T0 : T0 >T1 : T1 ->trivirgatus.mixtus : any +>trivirgatus.mixtus : trivirgatus.mixtus >trivirgatus : typeof trivirgatus ->mixtus : trivirgatus.mixtus +>mixtus : typeof trivirgatus.mixtus >gabriellae : any >amicus : gabriellae.amicus >lutreolus : any @@ -516,9 +516,9 @@ module julianae { >oralis : oralis >T0 : T0 >T1 : T1 ->caurinus.psilurus : any +>caurinus.psilurus : caurinus.psilurus >caurinus : typeof caurinus ->psilurus : caurinus.psilurus +>psilurus : typeof caurinus.psilurus cepapi() : caurinus.psilurus { var x : caurinus.psilurus; () => { var y = this; }; return x; } >cepapi : () => caurinus.psilurus @@ -754,9 +754,9 @@ module julianae { } export class sumatrana extends Lanthanum.jugularis { >sumatrana : sumatrana ->Lanthanum.jugularis : any +>Lanthanum.jugularis : Lanthanum.jugularis >Lanthanum : typeof Lanthanum ->jugularis : Lanthanum.jugularis +>jugularis : typeof Lanthanum.jugularis wolffsohni() : Lanthanum.suillus { var x : Lanthanum.suillus; () => { var y = this; }; return x; } >wolffsohni : () => Lanthanum.suillus @@ -1280,9 +1280,9 @@ module julianae { } export class durangae extends dogramacii.aurata { >durangae : durangae ->dogramacii.aurata : any +>dogramacii.aurata : dogramacii.aurata >dogramacii : typeof dogramacii ->aurata : dogramacii.aurata +>aurata : typeof dogramacii.aurata Californium() : panamensis.setulosus { var x : panamensis.setulosus; () => { var y = this; }; return x; } >Californium : () => panamensis.setulosus @@ -1434,9 +1434,9 @@ module Lanthanum { >nitidus : nitidus >T0 : T0 >T1 : T1 ->argurus.gilbertii : any +>argurus.gilbertii : argurus.gilbertii >argurus : typeof argurus ->gilbertii : argurus.gilbertii +>gilbertii : typeof argurus.gilbertii >lavali : any >thaeleri : lavali.thaeleri >lutreolus : any @@ -1604,9 +1604,9 @@ module Lanthanum { } export class megalonyx extends caurinus.johorensis { >megalonyx : megalonyx ->caurinus.johorensis : any +>caurinus.johorensis : caurinus.johorensis >caurinus : typeof caurinus ->johorensis : caurinus.johorensis +>johorensis : typeof caurinus.johorensis >caurinus : any >megaphyllus : caurinus.megaphyllus >julianae : any @@ -1991,9 +1991,9 @@ module rendalli { export class zuluensis extends julianae.steerii { >zuluensis : zuluensis ->julianae.steerii : any +>julianae.steerii : julianae.steerii >julianae : typeof julianae ->steerii : julianae.steerii +>steerii : typeof julianae.steerii telfairi() : argurus.wetmorei { var x : argurus.wetmorei; () => { var y = this; }; return x; } >telfairi : () => argurus.wetmorei @@ -2426,9 +2426,9 @@ module rendalli { >crenulata : crenulata >T0 : T0 >T1 : T1 ->trivirgatus.falconeri : any +>trivirgatus.falconeri : trivirgatus.falconeri >trivirgatus : typeof trivirgatus ->falconeri : trivirgatus.falconeri +>falconeri : typeof trivirgatus.falconeri salvanius() : howi.coludo { var x : howi.coludo; () => { var y = this; }; return x; } >salvanius : () => howi.coludo @@ -2621,9 +2621,9 @@ module trivirgatus { >mixtus : mixtus >T0 : T0 >T1 : T1 ->argurus.pygmaea : any +>argurus.pygmaea : argurus.pygmaea> >argurus : typeof argurus ->pygmaea : argurus.pygmaea +>pygmaea : typeof argurus.pygmaea >argurus : any >oreas : argurus.oreas >panglima : any @@ -3359,9 +3359,9 @@ module ruatanica { export class americanus extends imperfecta.ciliolabrum { >americanus : americanus ->imperfecta.ciliolabrum : any +>imperfecta.ciliolabrum : imperfecta.ciliolabrum >imperfecta : typeof imperfecta ->ciliolabrum : imperfecta.ciliolabrum +>ciliolabrum : typeof imperfecta.ciliolabrum >argurus : any >germaini : argurus.germaini >lutreolus : any @@ -3429,9 +3429,9 @@ module lavali { export class wilsoni extends Lanthanum.nitidus { >wilsoni : wilsoni ->Lanthanum.nitidus : any +>Lanthanum.nitidus : Lanthanum.nitidus >Lanthanum : typeof Lanthanum ->nitidus : Lanthanum.nitidus +>nitidus : typeof Lanthanum.nitidus >rionegrensis : any >caniventer : rionegrensis.caniventer >Lanthanum : any @@ -3650,9 +3650,9 @@ module lavali { } export class otion extends howi.coludo { >otion : otion ->howi.coludo : any +>howi.coludo : howi.coludo >howi : typeof howi ->coludo : howi.coludo +>coludo : typeof howi.coludo >argurus : any >oreas : argurus.oreas >howi : any @@ -4125,9 +4125,9 @@ module lavali { } export class thaeleri extends argurus.oreas { >thaeleri : thaeleri ->argurus.oreas : any +>argurus.oreas : argurus.oreas >argurus : typeof argurus ->oreas : argurus.oreas +>oreas : typeof argurus.oreas coromandra() : julianae.galapagoensis { var x : julianae.galapagoensis; () => { var y = this; }; return x; } >coromandra : () => julianae.galapagoensis @@ -4289,9 +4289,9 @@ module lavali { } export class lepturus extends Lanthanum.suillus { >lepturus : lepturus ->Lanthanum.suillus : any +>Lanthanum.suillus : Lanthanum.suillus >Lanthanum : typeof Lanthanum ->suillus : Lanthanum.suillus +>suillus : typeof Lanthanum.suillus >dammermani : any >melanops : dammermani.melanops >quasiater : any @@ -4365,9 +4365,9 @@ module dogramacii { export class robustulus extends lavali.wilsoni { >robustulus : robustulus ->lavali.wilsoni : any +>lavali.wilsoni : lavali.wilsoni >lavali : typeof lavali ->wilsoni : lavali.wilsoni +>wilsoni : typeof lavali.wilsoni fossor() : minutus.inez { var x : minutus.inez; () => { var y = this; }; return x; } >fossor : () => minutus.inez @@ -4940,9 +4940,9 @@ module lutreolus { export class schlegeli extends lavali.beisa { >schlegeli : schlegeli ->lavali.beisa : any +>lavali.beisa : lavali.beisa >lavali : typeof lavali ->beisa : lavali.beisa +>beisa : typeof lavali.beisa mittendorfi() : rionegrensis.caniventer { var x : rionegrensis.caniventer; () => { var y = this; }; return x; } >mittendorfi : () => rionegrensis.caniventer @@ -5678,9 +5678,9 @@ module panglima { >amphibius : amphibius >T0 : T0 >T1 : T1 ->caurinus.johorensis : any +>caurinus.johorensis : caurinus.johorensis, Lanthanum.jugularis> >caurinus : typeof caurinus ->johorensis : caurinus.johorensis +>johorensis : typeof caurinus.johorensis >Lanthanum : any >nitidus : Lanthanum.nitidus >petrophilus : any @@ -5812,9 +5812,9 @@ module panglima { >fundatus : fundatus >T0 : T0 >T1 : T1 ->lutreolus.schlegeli : any +>lutreolus.schlegeli : lutreolus.schlegeli >lutreolus : typeof lutreolus ->schlegeli : lutreolus.schlegeli +>schlegeli : typeof lutreolus.schlegeli crassulus(): nigra.gracilis { var x: nigra.gracilis; () => { var y = this; }; return x; } >crassulus : () => nigra.gracilis @@ -5918,9 +5918,9 @@ module panglima { >abidi : abidi >T0 : T0 >T1 : T1 ->argurus.dauricus : any +>argurus.dauricus : argurus.dauricus >argurus : typeof argurus ->dauricus : argurus.dauricus +>dauricus : typeof argurus.dauricus >argurus : any >germaini : argurus.germaini >julianae : any @@ -6133,9 +6133,9 @@ module minutus { >himalayana : himalayana >T0 : T0 >T1 : T1 ->lutreolus.punicus : any +>lutreolus.punicus : lutreolus.punicus >lutreolus : typeof lutreolus ->punicus : lutreolus.punicus +>punicus : typeof lutreolus.punicus simoni(): argurus.netscheri> { var x: argurus.netscheri>; () => { var y = this; }; return x; } >simoni : () => argurus.netscheri> @@ -6377,9 +6377,9 @@ module caurinus { >mahaganus : mahaganus >T0 : T0 >T1 : T1 ->panglima.fundatus : any +>panglima.fundatus : panglima.fundatus >panglima : typeof panglima ->fundatus : panglima.fundatus +>fundatus : typeof panglima.fundatus >quasiater : any >carolinensis : quasiater.carolinensis >macrorhinos : any @@ -6606,9 +6606,9 @@ module howi { >angulatus : angulatus >T0 : T0 >T1 : T1 ->sagitta.stolzmanni : any +>sagitta.stolzmanni : sagitta.stolzmanni >sagitta : typeof sagitta ->stolzmanni : sagitta.stolzmanni +>stolzmanni : typeof sagitta.stolzmanni pennatus(): howi.marcanoi { var x: howi.marcanoi; () => { var y = this; }; return x; } >pennatus : () => marcanoi @@ -6814,9 +6814,9 @@ module sagitta { export class walkeri extends minutus.portoricensis { >walkeri : walkeri ->minutus.portoricensis : any +>minutus.portoricensis : minutus.portoricensis >minutus : typeof minutus ->portoricensis : minutus.portoricensis +>portoricensis : typeof minutus.portoricensis maracajuensis(): samarensis.cahirinus { var x: samarensis.cahirinus; () => { var y = this; }; return x; } >maracajuensis : () => samarensis.cahirinus @@ -6846,9 +6846,9 @@ module minutus { >inez : inez >T0 : T0 >T1 : T1 ->samarensis.pelurus : any +>samarensis.pelurus : samarensis.pelurus >samarensis : typeof samarensis ->pelurus : samarensis.pelurus +>pelurus : typeof samarensis.pelurus >argurus : any >germaini : argurus.germaini >julianae : any @@ -6880,9 +6880,9 @@ module macrorhinos { export class konganensis extends imperfecta.lasiurus { >konganensis : konganensis ->imperfecta.lasiurus : any +>imperfecta.lasiurus : imperfecta.lasiurus >imperfecta : typeof imperfecta ->lasiurus : imperfecta.lasiurus +>lasiurus : typeof imperfecta.lasiurus >caurinus : any >psilurus : caurinus.psilurus >caurinus : any @@ -6896,9 +6896,9 @@ module panamensis { >linulus : linulus >T0 : T0 >T1 : T1 ->ruatanica.hector : any +>ruatanica.hector : ruatanica.hector> >ruatanica : typeof ruatanica ->hector : ruatanica.hector +>hector : typeof ruatanica.hector >julianae : any >sumatrana : julianae.sumatrana >samarensis : any @@ -7357,9 +7357,9 @@ module samarensis { >pelurus : pelurus >T0 : T0 >T1 : T1 ->sagitta.stolzmanni : any +>sagitta.stolzmanni : sagitta.stolzmanni >sagitta : typeof sagitta ->stolzmanni : sagitta.stolzmanni +>stolzmanni : typeof sagitta.stolzmanni Palladium(): panamensis.linulus { var x: panamensis.linulus; () => { var y = this; }; return x; } >Palladium : () => panamensis.linulus @@ -7615,9 +7615,9 @@ module samarensis { >fuscus : fuscus >T0 : T0 >T1 : T1 ->macrorhinos.daphaenodon : any +>macrorhinos.daphaenodon : macrorhinos.daphaenodon >macrorhinos : typeof macrorhinos ->daphaenodon : macrorhinos.daphaenodon +>daphaenodon : typeof macrorhinos.daphaenodon planifrons(): nigra.gracilis { var x: nigra.gracilis; () => { var y = this; }; return x; } >planifrons : () => nigra.gracilis @@ -8093,9 +8093,9 @@ module sagitta { >leptoceros : leptoceros >T0 : T0 >T1 : T1 ->caurinus.johorensis : any +>caurinus.johorensis : caurinus.johorensis> >caurinus : typeof caurinus ->johorensis : caurinus.johorensis +>johorensis : typeof caurinus.johorensis >argurus : any >peninsulae : argurus.peninsulae >daubentonii : any @@ -8205,9 +8205,9 @@ module daubentonii { >nigricans : nigricans >T0 : T0 >T1 : T1 ->sagitta.stolzmanni : any +>sagitta.stolzmanni : sagitta.stolzmanni >sagitta : typeof sagitta ->stolzmanni : sagitta.stolzmanni +>stolzmanni : typeof sagitta.stolzmanni woosnami(): dogramacii.robustulus { var x: dogramacii.robustulus; () => { var y = this; }; return x; } >woosnami : () => dogramacii.robustulus @@ -8238,9 +8238,9 @@ module argurus { >pygmaea : pygmaea >T0 : T0 >T1 : T1 ->rendalli.moojeni : any +>rendalli.moojeni : rendalli.moojeni >rendalli : typeof rendalli ->moojeni : rendalli.moojeni +>moojeni : typeof rendalli.moojeni >macrorhinos : any >konganensis : macrorhinos.konganensis >gabriellae : any @@ -8290,9 +8290,9 @@ module chrysaeolus { >sarasinorum : sarasinorum >T0 : T0 >T1 : T1 ->caurinus.psilurus : any +>caurinus.psilurus : caurinus.psilurus >caurinus : typeof caurinus ->psilurus : caurinus.psilurus +>psilurus : typeof caurinus.psilurus belzebul(): samarensis.pallidus { var x: samarensis.pallidus; () => { var y = this; }; return x; } >belzebul : () => samarensis.pallidus @@ -8533,9 +8533,9 @@ module argurus { export class oreas extends lavali.wilsoni { >oreas : oreas ->lavali.wilsoni : any +>lavali.wilsoni : lavali.wilsoni >lavali : typeof lavali ->wilsoni : lavali.wilsoni +>wilsoni : typeof lavali.wilsoni salamonis(): lavali.xanthognathus { var x: lavali.xanthognathus; () => { var y = this; }; return x; } >salamonis : () => lavali.xanthognathus @@ -9163,9 +9163,9 @@ module provocax { export class melanoleuca extends lavali.wilsoni { >melanoleuca : melanoleuca ->lavali.wilsoni : any +>lavali.wilsoni : lavali.wilsoni >lavali : typeof lavali ->wilsoni : lavali.wilsoni +>wilsoni : typeof lavali.wilsoni Neodymium(): macrorhinos.marmosurus, lutreolus.foina> { var x: macrorhinos.marmosurus, lutreolus.foina>; () => { var y = this; }; return x; } >Neodymium : () => macrorhinos.marmosurus, lutreolus.foina> @@ -9310,9 +9310,9 @@ module howi { export class marcanoi extends Lanthanum.megalonyx { >marcanoi : marcanoi ->Lanthanum.megalonyx : any +>Lanthanum.megalonyx : Lanthanum.megalonyx >Lanthanum : typeof Lanthanum ->megalonyx : Lanthanum.megalonyx +>megalonyx : typeof Lanthanum.megalonyx formosae(): Lanthanum.megalonyx { var x: Lanthanum.megalonyx; () => { var y = this; }; return x; } >formosae : () => Lanthanum.megalonyx @@ -10398,9 +10398,9 @@ module gabriellae { >klossii : klossii >T0 : T0 >T1 : T1 ->imperfecta.lasiurus : any +>imperfecta.lasiurus : imperfecta.lasiurus >imperfecta : typeof imperfecta ->lasiurus : imperfecta.lasiurus +>lasiurus : typeof imperfecta.lasiurus >dogramacii : any >robustulus : dogramacii.robustulus >caurinus : any @@ -10908,9 +10908,9 @@ module imperfecta { >ciliolabrum : ciliolabrum >T0 : T0 >T1 : T1 ->dogramacii.robustulus : any +>dogramacii.robustulus : dogramacii.robustulus >dogramacii : typeof dogramacii ->robustulus : dogramacii.robustulus +>robustulus : typeof dogramacii.robustulus leschenaultii(): argurus.dauricus> { var x: argurus.dauricus>; () => { var y = this; }; return x; } >leschenaultii : () => argurus.dauricus> @@ -11072,9 +11072,9 @@ module petrophilus { >sodyi : sodyi >T0 : T0 >T1 : T1 ->quasiater.bobrinskoi : any +>quasiater.bobrinskoi : quasiater.bobrinskoi >quasiater : typeof quasiater ->bobrinskoi : quasiater.bobrinskoi +>bobrinskoi : typeof quasiater.bobrinskoi saundersiae(): samarensis.pallidus { var x: samarensis.pallidus; () => { var y = this; }; return x; } >saundersiae : () => samarensis.pallidus @@ -11206,9 +11206,9 @@ module caurinus { export class megaphyllus extends imperfecta.lasiurus> { >megaphyllus : megaphyllus ->imperfecta.lasiurus : any +>imperfecta.lasiurus : imperfecta.lasiurus> >imperfecta : typeof imperfecta ->lasiurus : imperfecta.lasiurus +>lasiurus : typeof imperfecta.lasiurus >julianae : any >acariensis : julianae.acariensis >howi : any @@ -11640,9 +11640,9 @@ module lutreolus { >cor : cor >T0 : T0 >T1 : T1 ->panglima.fundatus : any +>panglima.fundatus : panglima.fundatus, lavali.beisa>, dammermani.melanops> >panglima : typeof panglima ->fundatus : panglima.fundatus +>fundatus : typeof panglima.fundatus >panamensis : any >linulus : panamensis.linulus >trivirgatus : any @@ -11887,9 +11887,9 @@ module argurus { export class germaini extends gabriellae.amicus { >germaini : germaini ->gabriellae.amicus : any +>gabriellae.amicus : gabriellae.amicus >gabriellae : typeof gabriellae ->amicus : gabriellae.amicus +>amicus : typeof gabriellae.amicus sharpei(): lavali.wilsoni { var x: lavali.wilsoni; () => { var y = this; }; return x; } >sharpei : () => lavali.wilsoni @@ -12100,9 +12100,9 @@ module dammermani { export class melanops extends minutus.inez { >melanops : melanops ->minutus.inez : any +>minutus.inez : minutus.inez >minutus : typeof minutus ->inez : minutus.inez +>inez : typeof minutus.inez >sagitta : any >stolzmanni : sagitta.stolzmanni >dammermani : any @@ -12350,9 +12350,9 @@ module argurus { export class peninsulae extends patas.uralensis { >peninsulae : peninsulae ->patas.uralensis : any +>patas.uralensis : patas.uralensis >patas : typeof patas ->uralensis : patas.uralensis +>uralensis : typeof patas.uralensis aitkeni(): trivirgatus.mixtus, panglima.amphibius> { var x: trivirgatus.mixtus, panglima.amphibius>; () => { var y = this; }; return x; } >aitkeni : () => trivirgatus.mixtus, panglima.amphibius> @@ -12815,9 +12815,9 @@ module ruatanica { >Praseodymium : Praseodymium >T0 : T0 >T1 : T1 ->ruatanica.hector : any +>ruatanica.hector : hector >ruatanica : typeof ruatanica ->hector : hector +>hector : typeof hector >lutreolus : any >punicus : lutreolus.punicus >gabriellae : any @@ -13163,9 +13163,9 @@ module caurinus { >johorensis : johorensis >T0 : T0 >T1 : T1 ->lutreolus.punicus : any +>lutreolus.punicus : lutreolus.punicus >lutreolus : typeof lutreolus ->punicus : lutreolus.punicus +>punicus : typeof lutreolus.punicus maini(): ruatanica.Praseodymium { var x: ruatanica.Praseodymium; () => { var y = this; }; return x; } >maini : () => ruatanica.Praseodymium @@ -13610,9 +13610,9 @@ module caurinus { export class psilurus extends lutreolus.punicus { >psilurus : psilurus ->lutreolus.punicus : any +>lutreolus.punicus : lutreolus.punicus >lutreolus : typeof lutreolus ->punicus : lutreolus.punicus +>punicus : typeof lutreolus.punicus socialis(): panglima.amphibius { var x: panglima.amphibius; () => { var y = this; }; return x; } >socialis : () => panglima.amphibius diff --git a/tests/baselines/reference/specializedInheritedConstructors1.types b/tests/baselines/reference/specializedInheritedConstructors1.types index a073efa24d7..7a7c4782406 100644 --- a/tests/baselines/reference/specializedInheritedConstructors1.types +++ b/tests/baselines/reference/specializedInheritedConstructors1.types @@ -27,7 +27,7 @@ class Model { } class MyView extends View { } >MyView : MyView ->View : View +>View : View >Model : Model var m: ViewOptions = { model: new Model() }; diff --git a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt index 138d09e9b55..0b868960bed 100644 --- a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt +++ b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt @@ -22,7 +22,7 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error T tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS2304: Cannot find name 'package'. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. -tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS2503: Cannot find namespace 'package'. +tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS2304: Cannot find name 'package'. ==== tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts (25 errors) ==== @@ -103,4 +103,4 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error T ~~~~~~~ !!! error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~~ -!!! error TS2503: Cannot find namespace 'package'. \ No newline at end of file +!!! error TS2304: Cannot find name 'package'. \ No newline at end of file diff --git a/tests/baselines/reference/strictModeReservedWordInImportEqualDeclaration.errors.txt b/tests/baselines/reference/strictModeReservedWordInImportEqualDeclaration.errors.txt index 7511e88f53a..3405db573a9 100644 --- a/tests/baselines/reference/strictModeReservedWordInImportEqualDeclaration.errors.txt +++ b/tests/baselines/reference/strictModeReservedWordInImportEqualDeclaration.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/strictModeReservedWordInImportEqualDeclaration.ts(3,8): error TS1212: Identifier expected. 'public' is a reserved word in strict mode +tests/cases/compiler/strictModeReservedWordInImportEqualDeclaration.ts(3,8): error TS1214: Identifier expected. 'public' is a reserved word in strict mode. Modules are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInImportEqualDeclaration.ts(3,25): error TS2307: Cannot find module '1'. @@ -7,6 +7,6 @@ tests/cases/compiler/strictModeReservedWordInImportEqualDeclaration.ts(3,25): er "use strict" import public = require("1"); ~~~~~~ -!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode +!!! error TS1214: Identifier expected. 'public' is a reserved word in strict mode. Modules are automatically in strict mode. ~~~ !!! error TS2307: Cannot find module '1'. \ No newline at end of file diff --git a/tests/baselines/reference/strictModeWordInImportDeclaration.errors.txt b/tests/baselines/reference/strictModeWordInImportDeclaration.errors.txt index aed48e1d3fd..b6e20cfc188 100644 --- a/tests/baselines/reference/strictModeWordInImportDeclaration.errors.txt +++ b/tests/baselines/reference/strictModeWordInImportDeclaration.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/strictModeWordInImportDeclaration.ts(2,13): error TS1212: Identifier expected. 'package' is a reserved word in strict mode +tests/cases/compiler/strictModeWordInImportDeclaration.ts(2,13): error TS1214: Identifier expected. 'package' is a reserved word in strict mode. Modules are automatically in strict mode. tests/cases/compiler/strictModeWordInImportDeclaration.ts(2,26): error TS2307: Cannot find module './1'. -tests/cases/compiler/strictModeWordInImportDeclaration.ts(3,16): error TS1212: Identifier expected. 'private' is a reserved word in strict mode +tests/cases/compiler/strictModeWordInImportDeclaration.ts(3,16): error TS1214: Identifier expected. 'private' is a reserved word in strict mode. Modules are automatically in strict mode. tests/cases/compiler/strictModeWordInImportDeclaration.ts(3,30): error TS2307: Cannot find module './1'. -tests/cases/compiler/strictModeWordInImportDeclaration.ts(4,8): error TS1212: Identifier expected. 'public' is a reserved word in strict mode +tests/cases/compiler/strictModeWordInImportDeclaration.ts(4,8): error TS1214: Identifier expected. 'public' is a reserved word in strict mode. Modules are automatically in strict mode. tests/cases/compiler/strictModeWordInImportDeclaration.ts(4,20): error TS2307: Cannot find module './1'. @@ -10,16 +10,16 @@ tests/cases/compiler/strictModeWordInImportDeclaration.ts(4,20): error TS2307: C "use strict" import * as package from "./1" ~~~~~~~ -!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode +!!! error TS1214: Identifier expected. 'package' is a reserved word in strict mode. Modules are automatically in strict mode. ~~~~~ !!! error TS2307: Cannot find module './1'. import {foo as private} from "./1" ~~~~~~~ -!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode +!!! error TS1214: Identifier expected. 'private' is a reserved word in strict mode. Modules are automatically in strict mode. ~~~~~ !!! error TS2307: Cannot find module './1'. import public from "./1" ~~~~~~ -!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode +!!! error TS1214: Identifier expected. 'public' is a reserved word in strict mode. Modules are automatically in strict mode. ~~~~~ !!! error TS2307: Cannot find module './1'. \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt index 01b581b7306..318b64d9331 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Index signatures are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts(24,25): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts(24,27): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer2.ts(32,15): error TS2430: Interface 'B3' incorrectly extends interface 'A'. Index signatures are incompatible. Type 'Base' is not assignable to type 'T'. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } interface B extends A { - ~~~~~~~ + ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. [x: number]: Derived; // error } diff --git a/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt index 4da8bc0290a..6f2684ae93b 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Index signatures are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts(24,21): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts(24,23): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer3.ts(32,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'Base' is not assignable to type 'T'. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } class B extends A { - ~~~~~~~ + ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. [x: number]: Derived; // error } diff --git a/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt index f3c9cc25a10..5dd39e0ad63 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer4.errors.txt @@ -6,7 +6,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Index signatures are incompatible. Type 'string' is not assignable to type 'Base'. Property 'foo' is missing in type 'String'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(20,21): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(20,23): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithNumericIndexer4.ts(24,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. Index signatures are incompatible. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'Base'. !!! error TS2415: Property 'foo' is missing in type 'String'. - ~~~~~~~ + ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. !!! error TS2344: Property 'bar' is missing in type 'Base'. [x: number]: string; // error diff --git a/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt index cfe8f2b8e1d..82f6229b20c 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Index signatures are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts(24,25): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts(24,27): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer2.ts(32,15): error TS2430: Interface 'B3' incorrectly extends interface 'A'. Index signatures are incompatible. Type 'Base' is not assignable to type 'T'. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } interface B extends A { - ~~~~~~~ + ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. [x: string]: Derived; // error } diff --git a/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt index 91c9f7fd47e..205ecf780cb 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Index signatures are incompatible. Type 'Base' is not assignable to type 'Derived'. Property 'bar' is missing in type 'Base'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts(24,21): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts(24,23): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer3.ts(32,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. Index signatures are incompatible. Type 'Base' is not assignable to type 'T'. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW } class B extends A { - ~~~~~~~ + ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. [x: string]: Derived; // error } diff --git a/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt index 6df716791c2..4aa889444e5 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer4.errors.txt @@ -6,7 +6,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Index signatures are incompatible. Type 'string' is not assignable to type 'Base'. Property 'foo' is missing in type 'String'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(20,21): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(20,23): error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. Property 'bar' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithStringIndexer4.ts(24,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. Index signatures are incompatible. @@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2415: Index signatures are incompatible. !!! error TS2415: Type 'string' is not assignable to type 'Base'. !!! error TS2415: Property 'foo' is missing in type 'String'. - ~~~~~~~ + ~~~~ !!! error TS2344: Type 'Base' does not satisfy the constraint 'Derived'. !!! error TS2344: Property 'bar' is missing in type 'Base'. [x: string]: string; // error diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.types b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.types index 7630d67606a..02d85f763b5 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.types +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.types @@ -16,7 +16,7 @@ declare class B { class D extends B { >D : D ->B : B +>B : B constructor() { super(); diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.types b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.types index cd26719d22e..68959b8b4b6 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.types +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.types @@ -12,7 +12,7 @@ declare class B { class D extends B { >D : D ->B : B +>B : B constructor() { super(); diff --git a/tests/baselines/reference/superCallParameterContextualTyping1.types b/tests/baselines/reference/superCallParameterContextualTyping1.types index 23aa3147997..4dc68fee3f7 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping1.types +++ b/tests/baselines/reference/superCallParameterContextualTyping1.types @@ -16,7 +16,7 @@ class A { class B extends A { >B : B ->A : A +>A : A // Ensure 'value' is of type 'number (and not '{}') by using its 'toExponential()' method. constructor() { super(value => String(value.toExponential())); } diff --git a/tests/baselines/reference/superCallParameterContextualTyping3.types b/tests/baselines/reference/superCallParameterContextualTyping3.types index 4a8515d110c..262b624e78f 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping3.types +++ b/tests/baselines/reference/superCallParameterContextualTyping3.types @@ -29,7 +29,7 @@ class CBase { class C extends CBase { >C : C ->CBase : CBase +>CBase : CBase constructor() { // Should be okay. diff --git a/tests/baselines/reference/superWithGenericSpecialization.types b/tests/baselines/reference/superWithGenericSpecialization.types index 258615b309f..075362e8a29 100644 --- a/tests/baselines/reference/superWithGenericSpecialization.types +++ b/tests/baselines/reference/superWithGenericSpecialization.types @@ -11,7 +11,7 @@ class C { class D extends C { >D : D >T : T ->C : C +>C : C y: T; >y : T diff --git a/tests/baselines/reference/superWithGenerics.types b/tests/baselines/reference/superWithGenerics.types index 3a034b67f04..ddf2741e35c 100644 --- a/tests/baselines/reference/superWithGenerics.types +++ b/tests/baselines/reference/superWithGenerics.types @@ -16,7 +16,7 @@ declare class B { class D extends B { >D : D ->B : B +>B : B constructor() { super(); diff --git a/tests/baselines/reference/thisInInvalidContexts.errors.txt b/tests/baselines/reference/thisInInvalidContexts.errors.txt index 055e0770dea..9cb554ab5df 100644 --- a/tests/baselines/reference/thisInInvalidContexts.errors.txt +++ b/tests/baselines/reference/thisInInvalidContexts.errors.txt @@ -1,7 +1,7 @@ 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. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body. -tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(38,25): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(38,25): error TS2507: Base expression is not of a constructor function type. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(44,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): error TS2332: 'this' cannot be referenced in current location. @@ -52,7 +52,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): class ErrClass3 extends this { ~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +!!! error TS2507: Base expression is not of a constructor function type. } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt index 03c494cad45..96fab807f5e 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(3,16): error TS2334: 'this' cannot be referenced in a static property initializer. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(22,15): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body. -tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS2507: Base expression is not of a constructor function type. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(44,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(45,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(48,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. @@ -53,7 +53,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod class ErrClass3 extends this { ~~~~ -!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses. +!!! error TS2507: Base expression is not of a constructor function type. } diff --git a/tests/baselines/reference/typeParameterAsBaseClass.errors.txt b/tests/baselines/reference/typeParameterAsBaseClass.errors.txt index 5602bf69f57..dec7f7f2a4a 100644 --- a/tests/baselines/reference/typeParameterAsBaseClass.errors.txt +++ b/tests/baselines/reference/typeParameterAsBaseClass.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2311: A class may only extend another class. +tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2304: Cannot find name 'T'. tests/cases/compiler/typeParameterAsBaseClass.ts(2,24): error TS2422: A class may only implement another class or interface. ==== tests/cases/compiler/typeParameterAsBaseClass.ts (2 errors) ==== class C extends T {} ~ -!!! error TS2311: A class may only extend another class. +!!! error TS2304: Cannot find name 'T'. class C2 implements T {} ~ !!! error TS2422: A class may only implement another class or interface. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAsBaseType.errors.txt b/tests/baselines/reference/typeParameterAsBaseType.errors.txt index b945dcdd987..835b2369948 100644 --- a/tests/baselines/reference/typeParameterAsBaseType.errors.txt +++ b/tests/baselines/reference/typeParameterAsBaseType.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2311: A class may only extend another class. -tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2311: A class may only extend another class. +tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2304: Cannot find name 'T'. +tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2304: Cannot find name 'U'. tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(7,24): error TS2312: An interface may only extend a class or another interface. tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): error TS2312: An interface may only extend a class or another interface. @@ -10,10 +10,10 @@ tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): e class C extends T { } ~ -!!! error TS2311: A class may only extend another class. +!!! error TS2304: Cannot find name 'T'. class C2 extends U { } ~ -!!! error TS2311: A class may only extend another class. +!!! error TS2304: Cannot find name 'U'. interface I extends T { } ~ diff --git a/tests/baselines/reference/undeclaredBase.errors.txt b/tests/baselines/reference/undeclaredBase.errors.txt index 5a6d838284c..25d550572d4 100644 --- a/tests/baselines/reference/undeclaredBase.errors.txt +++ b/tests/baselines/reference/undeclaredBase.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/undeclaredBase.ts(1,37): error TS2305: Module 'M' has no exported member 'I'. +tests/cases/compiler/undeclaredBase.ts(1,37): error TS2339: Property 'I' does not exist on type 'typeof M'. ==== tests/cases/compiler/undeclaredBase.ts (1 errors) ==== module M { export class C extends M.I { } } ~ -!!! error TS2305: Module 'M' has no exported member 'I'. +!!! error TS2339: Property 'I' does not exist on type 'typeof M'. \ No newline at end of file diff --git a/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.errors.txt b/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.errors.txt index 624d53f95d3..c6cd96578b4 100644 --- a/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.errors.txt +++ b/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.errors.txt @@ -4,14 +4,13 @@ tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(8,10): error TS2 tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(10,7): error TS2420: Class 'C' incorrectly implements interface 'Function'. Property 'apply' is missing in type 'C'. tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(18,10): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(20,18): error TS2311: A class may only extend another class. -tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(22,10): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(22,10): error TS2347: Untyped function calls may not accept type arguments. tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(28,10): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(35,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(41,1): error TS2346: Supplied parameters do not match any signature of call target. -==== tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts (10 errors) ==== +==== tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts (9 errors) ==== // none of these function calls should be allowed var x = function () { return; }; var r1 = x(); @@ -43,12 +42,10 @@ tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(41,1): error TS2 !!! error TS2349: Cannot invoke an expression whose type lacks a call signature. class C2 extends Function { } // error - ~~~~~~~~ -!!! error TS2311: A class may only extend another class. var c3: C2; var r5 = c3(); // error ~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2347: Untyped function calls may not accept type arguments. interface I { (number): number; diff --git a/tests/cases/conformance/classes/classDeclarations/classExtendingBuiltinType.ts b/tests/cases/conformance/classes/classDeclarations/classExtendingBuiltinType.ts new file mode 100644 index 00000000000..f36da74ea71 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classExtendingBuiltinType.ts @@ -0,0 +1,10 @@ +class C1 extends Object { } +class C2 extends Function { } +class C3 extends String { } +class C4 extends Boolean { } +class C5 extends Number { } +class C6 extends Date { } +class C7 extends RegExp { } +class C8 extends Error { } +class C9 extends Array { } +class C10 extends Array { } diff --git a/tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts b/tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts new file mode 100644 index 00000000000..a9f2a3049ed --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts @@ -0,0 +1,57 @@ +interface Base { + x: T; + y: U; +} + +// Error, no Base constructor function +class D0 extends Base { +} + +interface BaseConstructor { + new (x: string, y: string): Base; + new (x: T): Base; + new (x: T, y: T): Base; + new (x: T, y: U): Base; +} + +declare function getBase(): BaseConstructor; + +class D1 extends getBase() { + constructor() { + super("abc", "def"); + this.x = "x"; + this.y = "y"; + } +} + +class D2 extends getBase() { + constructor() { + super(10); + super(10, 20); + this.x = 1; + this.y = 2; + } +} + +class D3 extends getBase() { + constructor() { + super("abc", 42); + this.x = "x"; + this.y = 2; + } +} + +// Error, no constructors with three type arguments +class D4 extends getBase() { +} + +interface BadBaseConstructor { + new (x: string): Base; + new (x: number): Base; +} + +declare function getBadBase(): BadBaseConstructor; + +// Error, constructor return types differ +class D5 extends getBadBase() { +} diff --git a/tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts b/tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts new file mode 100644 index 00000000000..4b7e5c7a76e --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts @@ -0,0 +1,13 @@ +var x: {}; + +function foo() { + this.x = 1; +} + +class C1 extends undefined { } +class C2 extends true { } +class C3 extends false { } +class C4 extends 42 { } +class C5 extends "hello" { } +class C6 extends x { } +class C7 extends foo { } diff --git a/tests/cases/conformance/classes/classDeclarations/classExtendingNull.ts b/tests/cases/conformance/classes/classDeclarations/classExtendingNull.ts new file mode 100644 index 00000000000..655cf44ed57 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classExtendingNull.ts @@ -0,0 +1,2 @@ +class C1 extends null { } +class C2 extends (null) { } diff --git a/tests/cases/unittests/incrementalParser.ts b/tests/cases/unittests/incrementalParser.ts index 93d99615c93..a0b361a87f4 100644 --- a/tests/cases/unittests/incrementalParser.ts +++ b/tests/cases/unittests/incrementalParser.ts @@ -252,11 +252,6 @@ module ts { }); it('Strict mode 1',() => { - // In non-strict mode 'package' means nothing and can be reused. In strict mode though - // we'll have to reparse the nodes (and generate an error for 'package();' - // - // Note: in this test we don't actually add 'use strict'. This is so we can compare - // reuse with/without a strict mode change. var source = "foo1();\r\nfoo1();\r\nfoo1();\r\package();"; var oldText = ScriptSnapshot.fromString(source); @@ -266,23 +261,15 @@ module ts { }); it('Strict mode 2',() => { - // In non-strict mode 'package' means nothing and can be reused. In strict mode though - // we'll have to reparse the nodes (and generate an error for 'package();' var source = "foo1();\r\nfoo1();\r\nfoo1();\r\package();"; var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withInsert(oldText, 0, "'use strict';\r\n"); - // Note the decreased reuse of nodes compared to 'Strict mode 1' - compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 9); }); it('Strict mode 3',() => { - // In non-strict mode 'package' means nothing and can be reused. In strict mode though - // we'll have to reparse the nodes (and generate an error for 'package();' - // - // Note: in this test we don't actually remove 'use strict'. This is so we can compare - // reuse with/without a strict mode change. var source = "'strict';\r\nfoo1();\r\nfoo1();\r\nfoo1();\r\npackage();"; var index = source.indexOf('f'); @@ -293,16 +280,13 @@ module ts { }); it('Strict mode 4',() => { - // In non-strict mode 'package' means nothing and can be reused. In strict mode though - // we'll have to reparse the nodes (and generate an error for 'package();' var source = "'use strict';\r\nfoo1();\r\nfoo1();\r\nfoo1();\r\npackage();"; var index = source.indexOf('f'); var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withDelete(oldText, 0, index); - // Note the decreased reuse of nodes compared to testStrictMode3 - compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 9); }); it('Strict mode 5',() => { @@ -312,7 +296,7 @@ module ts { var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, index, 6, "strict"); - compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 27); }); it('Strict mode 6',() => { @@ -322,7 +306,7 @@ module ts { var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, index, 6, "blahhh"); - compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 27); }); it('Strict mode 7',() => { @@ -492,7 +476,6 @@ module ts { var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, index, ": Foo { @@ -555,7 +538,7 @@ module ts { var index = source.length; var newTextAndChange = withInsert(oldText, index, "var x;"); - compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 2); }); it('Delete parameter after comment',() => { @@ -595,7 +578,7 @@ constructor(name) { }\ var index = source.indexOf("100"); var newTextAndChange = withInsert(oldText, index, "'1', "); - compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 5); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 7); }); it('Insert declare modifier before module',() => { @@ -718,7 +701,7 @@ module m3 { }\ var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, 0, "var v =".length, "class C"); - compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code. + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4); }); it('Moving methods from object literal to class in strict mode', () => { @@ -736,7 +719,7 @@ module m3 { }\ var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, 0, "class".length, "interface"); - compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code. + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 18); }); it('Moving index signatures from class to interface in strict mode', () => { @@ -754,7 +737,7 @@ module m3 { }\ var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, 0, "interface".length, "class"); - compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code. + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 18); }); @@ -782,7 +765,7 @@ module m3 { }\ var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, 0, "var v =".length, "class C"); - compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code. + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4); });