From 35f2ada95b2873a9353063e760b3d97090fdc3cd Mon Sep 17 00:00:00 2001 From: Duncan Mak Date: Sun, 24 Aug 2014 00:36:55 -0400 Subject: [PATCH 01/12] Remove trailing whitespace. --- src/compiler/checker.ts | 134 ++++++++++++++++++++-------------------- src/compiler/emitter.ts | 32 +++++----- 2 files changed, 83 insertions(+), 83 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9f88df3aa8dad..77841e3124f8f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25,7 +25,7 @@ module ts { var emptyArray: any[] = []; var emptySymbols: SymbolTable = {}; - + var checker: TypeChecker = { getProgram: () => program, getDiagnostics: getDiagnostics, @@ -282,10 +282,10 @@ module ts { break; case SyntaxKind.Property: // TypeScript 1.0 spec (April 2014): 8.4.1 - // Initializer expressions for instance member variables are evaluated in the scope - // of the class constructor body but are not permitted to reference parameters or - // local variables of the constructor.This effectively means that entities from outer scopes - // by the same name as a constructor parameter or local variable are inaccessible + // Initializer expressions for instance member variables are evaluated in the scope + // of the class constructor body but are not permitted to reference parameters or + // local variables of the constructor.This effectively means that entities from outer scopes + // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. if (location.parent.kind === SyntaxKind.ClassDeclaration && !(location.flags & NodeFlags.Static)) { var ctor = findConstructorDeclaration(location.parent); @@ -302,7 +302,7 @@ module ts { if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & SymbolFlags.Type)) { if (lastLocation && lastLocation.flags & NodeFlags.Static) { // TypeScript 1.0 spec (April 2014): 3.4.1 - // The scope of a type parameter extends over the entire declaration + // The scope of a type parameter extends over the entire declaration // with which the type parameter list is associated, with the exception of static member declarations in classes. error(errorLocation, Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; @@ -495,7 +495,7 @@ module ts { var node = exportInformation.exportAssignments[0]; if (exportInformation.hasExportedMember) { // TypeScript 1.0 spec (April 2014): 11.2.3 - // If an external module contains an export assignment it is an error + // If an external module contains an export assignment it is an error // for the external module to also contain export declarations. // The two types of exports are mutually exclusive. error(node, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); @@ -559,7 +559,7 @@ module ts { return (resolveImport(symbol).flags & SymbolFlags.Value) !== 0; } - // If it is an instantiated symbol, then it is a value if hte symbol it is an + // If it is an instantiated symbol, then it is a value if hte symbol it is an // instantiation of is a value. if (symbol.flags & SymbolFlags.Instantiated) { return (getSymbolLinks(symbol).target.flags & SymbolFlags.Value) !== 0; @@ -708,7 +708,7 @@ module ts { function isAccessible(symbolFromSymbolTable: Symbol, resolvedAliasSymbol?: Symbol) { if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) - // and if symbolfrom symbolTable or alias resolution matches the symbol, + // and if symbolfrom symbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible return !forEach(symbolFromSymbolTable.declarations, declaration => hasExternalModuleSymbol(declaration)) && canQualifySymbol(symbolFromSymbolTable, meaning); @@ -791,7 +791,7 @@ module ts { return { accessibility: SymbolAccessibility.Accessible, aliasesToMakeVisible: hasAccessibleDeclarations.aliasesToMakeVisible }; } - // If we havent got the accessible symbol doesnt mean the symbol is actually inaccessible. + // If we havent got the accessible symbol doesnt mean the symbol is actually inaccessible. // It could be qualified symbol and hence verify the path // eg: // module m { @@ -800,14 +800,14 @@ module ts { // } // var x: typeof m.c // In the above example when we start with checking if typeof m.c symbol is accessible, - // we are going to see if c can be accessed in scope directly. + // we are going to see if c can be accessed in scope directly. // But it cant, hence the accessible is going to be undefined, but that doesnt mean m.c is accessible // It is accessible if the parent m is accessible because then m.c can be accessed through qualification meaningToLook = getQualifiedLeftMeaning(meaning); symbol = getParentOfSymbol(symbol); } - // This could be a symbol that is not exported in the external module + // This could be a symbol that is not exported in the external module // or it could be a symbol from different external module that is not aliased and hence cannot be named var symbolExternalModule = forEach(initialSymbol.declarations, declaration => getExternalModuleContainer(declaration)); if (symbolExternalModule) { @@ -854,7 +854,7 @@ module ts { function getIsDeclarationVisible(declaration: Declaration) { if (!isDeclarationVisible(declaration)) { - // Mark the unexported alias as visible if its parent is visible + // Mark the unexported alias as visible if its parent is visible // because these kind of aliases can be used to name types in declaration file if (declaration.kind === SyntaxKind.ImportDeclaration && !(declaration.flags & NodeFlags.Export) && @@ -903,7 +903,7 @@ module ts { return symbol.name; } - // Get qualified name + // Get qualified name if (enclosingDeclaration && // Properties/methods/Signatures/Constructors/TypeParameters do not need qualification !(symbol.flags & SymbolFlags.PropertyOrAccessor & SymbolFlags.Signature & SymbolFlags.Constructor & SymbolFlags.Method & SymbolFlags.TypeParameter)) { @@ -988,7 +988,7 @@ module ts { function writeTypeReference(type: TypeReference) { if (type.target === globalArrayType && !(flags & TypeFormatFlags.WriteArrayAsGenericType)) { - // If we are writing array element type the arrow style signatures are not allowed as + // If we are writing array element type the arrow style signatures are not allowed as // we need to surround it by curlies, eg. { (): T; }[]; as () => T[] would mean something different writeType(type.typeArguments[0], /*allowFunctionOrConstructorTypeLiteral*/ false); writer.write("[]"); @@ -1300,7 +1300,7 @@ module ts { function getTypeOfPrototypeProperty(prototype: Symbol): Type { // TypeScript 1.0 spec (April 2014): 8.4 - // Every class automatically contains a static property member named 'prototype', + // Every class automatically contains a static property member named 'prototype', // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. // It is an error to explicitly declare a static property member with the name 'prototype'. var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -2144,11 +2144,11 @@ module ts { var symbol = resolveName(typeParameter, ((n).typeName).text, SymbolFlags.Type, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (symbol && (symbol.flags & SymbolFlags.TypeParameter)) { // TypeScript 1.0 spec (April 2014): 3.4.1 - // Type parameters declared in a particular type parameter list + // Type parameters declared in a particular type parameter list // may not be referenced in constraints in that type parameter list - + // symbol.declaration.parent === typeParameter.parent - // -> typeParameter and symbol.declaration originate from the same type parameter list + // -> typeParameter and symbol.declaration originate from the same type parameter list // -> illegal for all declarations in symbol // forEach === exists links.isIllegalTypeReferenceInConstraint = forEach(symbol.declarations, d => d.parent == typeParameter.parent); @@ -2175,7 +2175,7 @@ module ts { var type: Type; if ((symbol.flags & SymbolFlags.TypeParameter) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { // TypeScript 1.0 spec (April 2014): 3.4.1 - // Type parameters declared in a particular type parameter list + // Type parameters declared in a particular type parameter list // may not be referenced in constraints in that type parameter list // Implementation: such type references are resolved to 'unknown' type that usually denotes error type = unknownType; @@ -2211,7 +2211,7 @@ module ts { // TypeScript 1.0 spec (April 2014): 3.6.3 // The expression is processed as an identifier expression (section 4.3) // or property access expression(section 4.10), - // the widened type(section 3.9) of which becomes the result. + // the widened type(section 3.9) of which becomes the result. links.resolvedType = getWidenedType(checkExpression(node.exprName)); } return links.resolvedType; @@ -2442,7 +2442,7 @@ module ts { mapper = combineTypeMappers(links.mapper, mapper); } - // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and + // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. var result = createSymbol(SymbolFlags.Instantiated | SymbolFlags.Transient, symbol.name); result.declarations = symbol.declarations; @@ -2876,7 +2876,7 @@ module ts { // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. // M is a property and S' contains a property N where - // if M is a required property, N is also a required property + // if M is a required property, N is also a required property // (M - property in T) // (N - property in S) if (reportErrors) { @@ -3065,7 +3065,7 @@ module ts { } return true; } - } + } function numberIndexTypesRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): boolean { if (relation === identityRelation) { @@ -3595,7 +3595,7 @@ module ts { container.kind === SyntaxKind.Property || container.kind === SyntaxKind.Constructor; } - } + } } if (canUseSuperExpression) { @@ -3733,7 +3733,7 @@ module ts { function getContextualTypeForConditionalOperand(node: Expression): Type { var conditional = node.parent; - return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; + return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualType(node: Expression): Type { @@ -3824,9 +3824,9 @@ module ts { } else { // TypeScript 1.0 spec (April 2014) - // A get accessor declaration is processed in the same manner as + // A get accessor declaration is processed in the same manner as // an ordinary function declaration(section 6.1) with no parameters. - // A set accessor declaration is processed in the same manner + // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. var getAccessor = getDeclarationOfKind(member, SyntaxKind.GetAccessor); if (getAccessor) { @@ -3892,11 +3892,11 @@ module ts { if (prop.parent && prop.parent.flags & SymbolFlags.Class) { // TS 1.0 spec (April 2014): 4.8.2 - // - In a constructor, instance member function, instance member accessor, or - // instance member variable initializer where this references a derived class instance, + // - In a constructor, instance member function, instance member accessor, or + // instance member variable initializer where this references a derived class instance, // a super property access is permitted and must specify a public instance member function of the base class. - // - In a static member function or static member accessor - // where this references the constructor function object of a derived class, + // - In a static member function or static member accessor + // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. if (node.left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.Method) { error(node.right, Diagnostics.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -3919,11 +3919,11 @@ module ts { if (objectType === unknownType) return unknownType; // TypeScript 1.0 spec (April 2014): 4.10 Property Access - // - If IndexExpr is a string literal or a numeric literal and ObjExpr's apparent type has a property with the name + // - If IndexExpr is a string literal or a numeric literal and ObjExpr's apparent type has a property with the name // given by that literal(converted to its string representation in the case of a numeric literal), the property access is of the type of that property. - // - Otherwise, if ObjExpr's apparent type has a numeric index signature and IndexExpr is of type Any, the Number primitive type, or an enum type, + // - Otherwise, if ObjExpr's apparent type has a numeric index signature and IndexExpr is of type Any, the Number primitive type, or an enum type, // the property access is of the type of that index signature. - // - Otherwise, if ObjExpr's apparent type has a string index signature and IndexExpr is of type Any, the String or Number primitive type, or an enum type, + // - Otherwise, if ObjExpr's apparent type has a string index signature and IndexExpr is of type Any, the String or Number primitive type, or an enum type, // the property access is of the type of that index signature. // - Otherwise, if IndexExpr is of type Any, the String or Number primitive type, or an enum type, the property access is of type Any. @@ -3942,7 +3942,7 @@ module ts { } // Check for compatible indexer types. - if (indexType.flags & (TypeFlags.Any | TypeFlags.StringLike | TypeFlags.NumberLike)) { + if (indexType.flags & (TypeFlags.Any | TypeFlags.StringLike | TypeFlags.NumberLike)) { // Try to use a number indexer. if (indexType.flags & (TypeFlags.Any | TypeFlags.NumberLike)) { @@ -4009,7 +4009,7 @@ module ts { if (isCandidateSignature(node, signature)) { var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; - if (!lastSymbol || symbol === lastSymbol) { + if (!lastSymbol || symbol === lastSymbol) { if (lastParent && parent === lastParent) { pos++; } @@ -4190,7 +4190,7 @@ module ts { // Another error has already been reported return resolveErrorCall(node); } - + var apparentType = getApparentType(funcType); if (apparentType === unknownType) { // handler cases when funcType is type parameter with invalid constraint @@ -4365,7 +4365,7 @@ module ts { var commonType = getBestCommonType(types, /*contextualType:*/ undefined, /*candidatesOnly:*/ true); if (!commonType) { error(func, Diagnostics.No_best_common_type_exists_among_return_expressions); - + return unknownType; } @@ -4552,16 +4552,16 @@ module ts { function isReferenceOrErrorExpression(n: Node): boolean { // TypeScript 1.0 spec (April 2014): - // Expressions are classified as values or references. + // Expressions are classified as values or references. // References are the subset of expressions that are permitted as the target of an assignment. - // Specifically, references are combinations of identifiers(section 4.3), parentheses(section 4.7), + // Specifically, references are combinations of identifiers(section 4.3), parentheses(section 4.7), // and property accesses(section 4.10). // All other expression constructs described in this chapter are classified as values. switch (n.kind) { case SyntaxKind.Identifier: var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 - // An identifier expression that references a variable or parameter is classified as a reference. + // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & SymbolFlags.Variable) !== 0; case SyntaxKind.PropertyAccess: @@ -4630,7 +4630,7 @@ module ts { function checkInstanceOfExpression(node: BinaryExpression, leftType: Type, rightType: Type): Type { // TypeScript 1.0 spec (April 2014): 4.15.4 // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, - // and the right operand to be of type Any or a subtype of the 'Function' interface type. + // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. if (!isTypeAnyTypeObjectTypeOrTypeParameter(leftType)) { error(node.left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); @@ -4682,7 +4682,7 @@ module ts { case SyntaxKind.AmpersandEqualsToken: // TypeScript 1.0 spec (April 2014): 4.15.1 // These operators require their operands to be of type Any, the Number primitive type, - // or an enum type. Operands of an enum type are treated + // or an enum type. Operands of an enum type are treated // as having the primitive type Number. If one operand is the null or undefined value, // it is treated as having the type of the other operand. // The result is always of the Number primitive type. @@ -4764,7 +4764,7 @@ module ts { // An assignment of the form // VarExpr = ValueExpr // requires VarExpr to be classified as a reference - // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) + // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non - compound operation to be assignable to the type of VarExpr. var ok = checkReferenceExpression(node.left, Diagnostics.Invalid_left_hand_side_of_assignment_expression); // Use default messages @@ -4905,7 +4905,7 @@ module ts { function checkReferencesInInitializer(n: Node): void { if (n.kind === SyntaxKind.Identifier) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; - // check FunctionDeclaration.locals (stores parameters\function local variable) + // check FunctionDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(parameterDeclaration.parent.locals, referencedSymbol.name, SymbolFlags.Value) === referencedSymbol) { if (referencedSymbol.valueDeclaration.kind === SyntaxKind.Parameter) { @@ -5068,14 +5068,14 @@ module ts { } // TS 1.0 spec (April 2014): 8.3.2 - // Constructors of classes with no extends clause may not contain super calls, whereas + // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. if ((node.parent).baseType) { - + if (containsSuperCall(node.body)) { // The first statement in the body of a constructor must be a super call if both of the following are true: // - The containing class is a derived class. - // - The constructor declares parameter properties + // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. var superCallShouldBeFirst = forEach((node.parent).members, isInstancePropertyWithInitializer) || @@ -5375,8 +5375,8 @@ module ts { // checkSpecializedSignatureDeclaration if (!bodySignature.hasStringLiterals) { // TypeScript 1.0 spec (April 2014): 6.1 - // If a function declaration includes overloads, the overloads determine the call - // signatures of the type given to the function object + // If a function declaration includes overloads, the overloads determine the call + // signatures of the type given to the function object // and the function implementation signature must be assignable to that type // // TypeScript 1.0 spec (April 2014): 3.8.4 @@ -5426,7 +5426,7 @@ module ts { return; } - // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace + // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace // to denote disjoint declarationSpaces (without making new enum type). var exportedDeclarationSpaces: SymbolFlags = 0; var nonExportedDeclarationSpaces: SymbolFlags = 0; @@ -5546,7 +5546,7 @@ module ts { // - function has rest parameters // - context is not ambient (otherwise no codegen impact) if ((node.parent).body && hasRestParameters(node.parent) && !isInAmbientContext(node)) { - error(node, Diagnostics.Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter); + error(node, Diagnostics.Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter); } return; } @@ -5564,10 +5564,10 @@ module ts { // var x = { get baz() { return _i; } } // } // } - // + // // at runtime '_i' referenced in getter will be resolved to the generated index variable '_i' used to initialize rest parameters. // legitimate case: when '_i' is defined inside the function declaration with rest parameters. - // + // // function foo(...a) { // var _i = "!"; // function bar() { @@ -5649,7 +5649,7 @@ module ts { // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node: Node): void { var current = node; - while (current) { + while (current) { if (getNodeCheckFlags(current) & NodeCheckFlags.CaptureThis) { var isDeclaration = node.kind !== SyntaxKind.Identifier; if (isDeclaration) { @@ -5763,7 +5763,7 @@ module ts { // In a 'for-in' statement of the form // for (var VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, - // and Expr must be an expression of type Any, an object type, or a type parameter type. + // and Expr must be an expression of type Any, an object type, or a type parameter type. if (node.declaration) { checkVariableDeclaration(node.declaration); if (node.declaration.type) { @@ -5782,7 +5782,7 @@ module ts { } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(node.variable, Diagnostics.Invalid_left_hand_side_in_for_in_statement); + checkReferenceExpression(node.variable, Diagnostics.Invalid_left_hand_side_in_for_in_statement); } } @@ -5879,7 +5879,7 @@ module ts { if (node.finallyBlock) checkBlock(node.finallyBlock); } - function checkIndexConstraints(type: Type) { + function checkIndexConstraints(type: Type) { function checkIndexConstraintForProperty(prop: Symbol, propertyType: Type, indexDeclaration: Declaration, indexType: Type, indexKind: IndexKind): void { if (!indexType) { @@ -5942,7 +5942,7 @@ module ts { } } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { + if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { error(errorNode, Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); } @@ -6004,7 +6004,7 @@ module ts { checkKindsOfPropertyMemberOverrides(type, baseType); } - + // Check that base type can be evaluated as expression checkExpression(node.baseType.typeName); } @@ -6046,13 +6046,13 @@ module ts { // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. // Both public and private property members are inherited, but only public property members can be overridden. // A property member in a derived class is said to override a property member in a base class - // when the derived class property member has the same name and kind(instance or static) + // when the derived class property member has the same name and kind(instance or static) // as the base class property member. // The type of an overriding property member must be assignable(section 3.8.4) // to the type of the overridden property member, or otherwise a compile - time error occurs. // Base class instance member functions can be overridden by derived class instance member functions, // but not by other kinds of members. - // Base class instance member variables and accessors can be overridden by + // Base class instance member variables and accessors can be overridden by // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration @@ -6209,7 +6209,7 @@ module ts { autoValue = getConstantValue(initializer); if (autoValue === undefined && !ambient) { // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. + // If it is a constant value (not undefined), it is syntactically constrained to be a number. // Also, we do not need to check this for ambients because there is already // a syntax error if it is not a constant. checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*chainedMessage*/ undefined, /*terminalMessage*/ undefined); @@ -6307,7 +6307,7 @@ module ts { checkCollisionWithCapturedThisVariable(node, node.name); var symbol = getSymbolOfNode(node); var target: Symbol; - + if (node.entityName) { target = resolveImport(symbol); // Import declaration for an internal module @@ -6335,7 +6335,7 @@ module ts { } else if (node.parent.kind === SyntaxKind.ModuleBlock && (node.parent.parent).name.kind === SyntaxKind.StringLiteral) { // TypeScript 1.0 spec (April 2013): 12.1.6 - // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference + // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference // other external modules only through top - level external module names. // Relative external module names are not permitted. if (isExternalModuleNameRelative(node.externalModuleName.text)) { @@ -6855,7 +6855,7 @@ module ts { case SyntaxKind.SuperKeyword: var type = checkExpression(node); return type.symbol; - + case SyntaxKind.ConstructorKeyword: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 198adc4c37ee9..f38594bcd3562 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -243,11 +243,11 @@ module ts { // } // module m { // /* this is line 1 -- Assume current writer indent 8 - // * line --3 = 8 - 4 + 5 + // * line --3 = 8 - 4 + 5 // More right indented comment */ --4 = 8 - 4 + 11 // class c { } // } - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); if (spacesToEmit > 0) { var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); @@ -348,7 +348,7 @@ module ts { var emitEnd = function (node: Node) { }; /** Emit the text for the given token that comes after startPos - * This by default writes the text provided with the given tokenKind + * This by default writes the text provided with the given tokenKind * but if optional emitFn callback is provided the text is emitted using the callback instead of default text * @param tokenKind the kind of the token to search and emit * @param startPos the position in the source to start searching for the token @@ -417,13 +417,13 @@ module ts { // 1. Relative Column 0 based sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - // 2. Relative sourceIndex + // 2. Relative sourceIndex sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); // 3. Relative sourceLine 0 based sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - // 4. Relative sourceColumn 0 based + // 4. Relative sourceColumn 0 based sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); // 5. Relative namePosition 0 based @@ -523,7 +523,7 @@ module ts { function recordNewSourceFileStart(node: SourceFile) { // Add the the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path + // If sourceroot option: Use the relative path corresponding to the common directory path // otherwise source locations relative to map file location var sourcesDirectoryPath = compilerOptions.sourceRoot ? program.getCommonSourceDirectory() : sourceMapDir; @@ -625,7 +625,7 @@ module ts { sourceMapDecodedMappings: [] }; - // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the + // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the // relative paths of the sources list in the sourcemap sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== CharacterCodes.slash) { @@ -929,7 +929,7 @@ module ts { var operand = (node.expression).operand; // Make sure we consider all nested cast expressions, e.g.: - // (-A).x; + // (-A).x; while (operand.kind == SyntaxKind.TypeAssertion) { operand = (operand).operand; } @@ -937,7 +937,7 @@ module ts { // We have an expression of the form: (SubExpr) // Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is. // Omitting the parentheses, however, could cause change in the semantics of the generated - // code if the casted expression has a lower precedence than the rest of the expression, e.g.: + // code if the casted expression has a lower precedence than the rest of the expression, e.g.: // (new A).foo should be emitted as (new A).foo and not new A.foo // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() @@ -2156,7 +2156,7 @@ module ts { if (commentLine >= lastCommentLine + 2) { // There was a blank line between the last comment and this comment. This - // comment is not part of the copyright comments. Return what we have so + // comment is not part of the copyright comments. Return what we have so // far. return detachedComments; } @@ -2335,7 +2335,7 @@ module ts { } // If the node is parented in the current source file we need to emit export declare or just export else if (node.parent === currentSourceFile) { - // If the node is exported + // If the node is exported if (node.flags & NodeFlags.Export) { write("export "); } @@ -2361,7 +2361,7 @@ module ts { } function writeImportDeclaration(node: ImportDeclaration) { - // note usage of writer. methods instead of aliases created, just to make sure we are using + // note usage of writer. methods instead of aliases created, just to make sure we are using // correct writer especially to handle asynchronous alias writing emitJsDocComments(node); if (node.flags & NodeFlags.Export) { @@ -2845,7 +2845,7 @@ module ts { switch (node.kind) { case SyntaxKind.ConstructSignature: // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; @@ -3036,8 +3036,8 @@ module ts { return program.getSourceFile(referenceFileName); } - // Contains the reference paths that needs to go in the declaration file. - // Collecting this separately because reference paths need to be first thing in the declaration file + // Contains the reference paths that needs to go in the declaration file. + // Collecting this separately because reference paths need to be first thing in the declaration file // and we could be collecting these paths from multiple files into single one with --out option var referencePathsOutput = ""; function writeReferencePath(referencedFile: SourceFile) { @@ -3099,7 +3099,7 @@ module ts { }); } - // TODO(shkamat): Should we not write any declaration file if any of them can produce error, + // TODO(shkamat): Should we not write any declaration file if any of them can produce error, // or should we just not write this file like we are doing now if (!reportedDeclarationError) { var declarationOutput = referencePathsOutput; From 613f80939b4fa94d40cd22f7dfedb95805a4cd5f Mon Sep 17 00:00:00 2001 From: Duncan Mak Date: Sun, 24 Aug 2014 00:39:45 -0400 Subject: [PATCH 02/12] Add new method isParameterReferencedInBody. This is only a sketch. --- src/compiler/checker.ts | 15 +++++++++++++++ src/compiler/types.ts | 1 + 2 files changed, 16 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 77841e3124f8f..160e7a84988f8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7098,6 +7098,20 @@ module ts { return false; } + function isParameterReferencedInBody (node: FunctionDeclaration, param: ParameterDeclaration) { + var result = true; + + var statements = ( node.body).statements; + forEach(statements, s => { + if (s.kind == SyntaxKind.ReturnStatement) { + var expr = ( s).expression; + if (expr === undefined) + result = false; + } + }); + return result; + } + function getNodeCheckFlags(node: Node): NodeCheckFlags { return getNodeLinks(node).flags; } @@ -7133,6 +7147,7 @@ module ts { shouldEmitDeclarations: shouldEmitDeclarations, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, + isParameterReferencedInBody: isParameterReferencedInBody, writeTypeAtLocation: writeTypeAtLocation, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, writeSymbol: writeSymbolToTextWriter, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 35793de5d5c31..7a30f6b897001 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -662,6 +662,7 @@ module ts { shouldEmitDeclarations(): boolean; isDeclarationVisible(node: Declaration): boolean; isImplementationOfOverload(node: FunctionDeclaration): boolean; + isParameterReferencedInBody(node: FunctionDeclaration, param: ParameterDeclaration): boolean; writeTypeAtLocation(location: Node, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter): void; writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter): void; writeSymbol(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, writer: TextWriter): void; From 48ef2ebeab5e4fec0ad94f5c4b588966597b3f82 Mon Sep 17 00:00:00 2001 From: Duncan Mak Date: Sun, 24 Aug 2014 00:44:01 -0400 Subject: [PATCH 03/12] Use isParameterReferencedInBody in EmitRestParameter. --- src/compiler/emitter.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index f38594bcd3562..11f6f260c235c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1275,6 +1275,11 @@ module ts { if (hasRestParameters(node)) { var restIndex = node.parameters.length - 1; var restParam = node.parameters[restIndex]; + + if (!resolver.isParameterReferencedInBody(node, restParam)) { + return; + } + writeLine(); emitLeadingComments(restParam); emitStart(restParam); From 0f3dcb19a837cfe523d86ebaa4e886e6d197a557 Mon Sep 17 00:00:00 2001 From: Duncan Mak Date: Sun, 24 Aug 2014 12:12:05 -0400 Subject: [PATCH 04/12] Use forEachChild in the implementation of isParameterReferencedInBody. Still need to figure out the correct way to match the parameter against the child Node. --- src/compiler/checker.ts | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 160e7a84988f8..579804ecefc59 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7098,18 +7098,35 @@ module ts { return false; } - function isParameterReferencedInBody (node: FunctionDeclaration, param: ParameterDeclaration) { - var result = true; + function isParameterReferencedInBody(node: FunctionDeclaration, param: ParameterDeclaration) { - var statements = ( node.body).statements; - forEach(statements, s => { - if (s.kind == SyntaxKind.ReturnStatement) { - var expr = ( s).expression; - if (expr === undefined) - result = false; + function isReferenced(node: Node): boolean { + + if (node === undefined) + return false; + + switch (node.kind) { + + // Terminals + case SyntaxKind.NumericLiteral: + case SyntaxKind.StringLiteral: + case SyntaxKind.RegularExpressionLiteral: + return false; + + case SyntaxKind.Identifier: + var identifier = node; + // DEBUG + console.log({ name: identifier.text, id: identifier.id }, 'vs', { name: param.symbol.name, id: param.symbol.id }); + return identifier.id === param.symbol.id + + default: + // Recursively check children until we hit a terminal + return forEachChild(node, isReferenced) || false; } - }); - return result; + } + + forEachChild(node, isReferenced); + return false; } function getNodeCheckFlags(node: Node): NodeCheckFlags { From 1197d2509134e93cfddc8f81b9115bfe710067e0 Mon Sep 17 00:00:00 2001 From: Duncan Mak Date: Sun, 24 Aug 2014 12:30:12 -0400 Subject: [PATCH 05/12] Fix up the return value. --- src/compiler/checker.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 579804ecefc59..4df39e93ba647 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7121,12 +7121,11 @@ module ts { default: // Recursively check children until we hit a terminal - return forEachChild(node, isReferenced) || false; + return forEachChild(node, isReferenced); } } - forEachChild(node, isReferenced); - return false; + return forEachChild(node, isReferenced); } function getNodeCheckFlags(node: Node): NodeCheckFlags { From 41fb398d993575160d048866bd426932cd6ab4b7 Mon Sep 17 00:00:00 2001 From: Duncan Mak Date: Sun, 24 Aug 2014 19:02:01 -0400 Subject: [PATCH 06/12] A 2nd attempt at implementing isReferenced. --- src/compiler/checker.ts | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4df39e93ba647..e3cb3bccb99b4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7098,34 +7098,29 @@ module ts { return false; } - function isParameterReferencedInBody(node: FunctionDeclaration, param: ParameterDeclaration) { + function isParameterReferencedInBody(body: FunctionDeclaration, param: ParameterDeclaration) { - function isReferenced(node: Node): boolean { - - if (node === undefined) - return false; + function equals(a: Symbol, b: Symbol) { + var x = a.valueDeclaration; + var y = b.valueDeclaration; + return (x.pos === y.pos) && (x.end === y.end); + } + function isReferenced(node: Node): boolean { switch (node.kind) { - - // Terminals - case SyntaxKind.NumericLiteral: - case SyntaxKind.StringLiteral: - case SyntaxKind.RegularExpressionLiteral: + case SyntaxKind.Parameter: return false; case SyntaxKind.Identifier: - var identifier = node; - // DEBUG - console.log({ name: identifier.text, id: identifier.id }, 'vs', { name: param.symbol.name, id: param.symbol.id }); - return identifier.id === param.symbol.id + var symbol = getSymbolOfEntityName(node); + return symbol && symbol.valueDeclaration && equals(symbol, param.symbol); default: - // Recursively check children until we hit a terminal return forEachChild(node, isReferenced); } } - return forEachChild(node, isReferenced); + return forEachChild(body, isReferenced); } function getNodeCheckFlags(node: Node): NodeCheckFlags { From 0ae925d37f597e79cefd0bb2ad3bfd9e0cca042c Mon Sep 17 00:00:00 2001 From: Duncan Mak Date: Sun, 24 Aug 2014 19:43:24 -0400 Subject: [PATCH 07/12] Use === to compare valueDeclaration instead of custom equals function. --- src/compiler/checker.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e3cb3bccb99b4..2562573603ae2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7100,12 +7100,6 @@ module ts { function isParameterReferencedInBody(body: FunctionDeclaration, param: ParameterDeclaration) { - function equals(a: Symbol, b: Symbol) { - var x = a.valueDeclaration; - var y = b.valueDeclaration; - return (x.pos === y.pos) && (x.end === y.end); - } - function isReferenced(node: Node): boolean { switch (node.kind) { case SyntaxKind.Parameter: @@ -7113,7 +7107,7 @@ module ts { case SyntaxKind.Identifier: var symbol = getSymbolOfEntityName(node); - return symbol && symbol.valueDeclaration && equals(symbol, param.symbol); + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration === param.symbol.valueDeclaration); default: return forEachChild(node, isReferenced); From 5eea15f69ad86b833ae380b258c0bcedf2e87337 Mon Sep 17 00:00:00 2001 From: Duncan Mak Date: Sun, 24 Aug 2014 20:15:06 -0400 Subject: [PATCH 08/12] Handle ParameterDeclarations that come with an initializer Expression. --- src/compiler/checker.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2562573603ae2..59c40614c995c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7102,15 +7102,15 @@ module ts { function isReferenced(node: Node): boolean { switch (node.kind) { - case SyntaxKind.Parameter: - return false; - - case SyntaxKind.Identifier: - var symbol = getSymbolOfEntityName(node); - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration === param.symbol.valueDeclaration); + case SyntaxKind.Parameter: + var p = node; + return (p.initializer) ? isReferenced(p.initializer) : false; + case SyntaxKind.Identifier: + var symbol = getSymbolOfEntityName(node); + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration === param.symbol.valueDeclaration); - default: - return forEachChild(node, isReferenced); + default: + return forEachChild(node, isReferenced); } } From c0fc950b0ab2f05594b4b320acf55f28d20c3ff4 Mon Sep 17 00:00:00 2001 From: Duncan Mak Date: Tue, 26 Aug 2014 00:11:45 -0400 Subject: [PATCH 09/12] Address issues brought up in code review. Renamed isParameterReferencedInBody to isParameterUsedInFunction. --- src/compiler/checker.ts | 12 +++++++----- src/compiler/emitter.ts | 2 +- src/compiler/types.ts | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 59c40614c995c..31fc12ab4f0cf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7098,23 +7098,25 @@ module ts { return false; } - function isParameterReferencedInBody(body: FunctionDeclaration, param: ParameterDeclaration) { + function isParameterUsedInFunction(func: FunctionDeclaration, param: ParameterDeclaration) { function isReferenced(node: Node): boolean { switch (node.kind) { + // Necessary to check parameters with default initializer case SyntaxKind.Parameter: var p = node; - return (p.initializer) ? isReferenced(p.initializer) : false; + return p.initializer && isReferenced(p.initializer); + case SyntaxKind.Identifier: var symbol = getSymbolOfEntityName(node); - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration === param.symbol.valueDeclaration); + return symbol === param.symbol; default: return forEachChild(node, isReferenced); } } - return forEachChild(body, isReferenced); + return forEach(func.parameters, isReferenced) || forEachChild(func.body, isReferenced); } function getNodeCheckFlags(node: Node): NodeCheckFlags { @@ -7152,7 +7154,7 @@ module ts { shouldEmitDeclarations: shouldEmitDeclarations, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, - isParameterReferencedInBody: isParameterReferencedInBody, + isParameterUsedInFunction: isParameterUsedInFunction, writeTypeAtLocation: writeTypeAtLocation, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, writeSymbol: writeSymbolToTextWriter, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 11f6f260c235c..02257f68ecec9 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1276,7 +1276,7 @@ module ts { var restIndex = node.parameters.length - 1; var restParam = node.parameters[restIndex]; - if (!resolver.isParameterReferencedInBody(node, restParam)) { + if (!resolver.isParameterUsedInFunction(node, restParam)) { return; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7a30f6b897001..15cd2a3216407 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -662,7 +662,7 @@ module ts { shouldEmitDeclarations(): boolean; isDeclarationVisible(node: Declaration): boolean; isImplementationOfOverload(node: FunctionDeclaration): boolean; - isParameterReferencedInBody(node: FunctionDeclaration, param: ParameterDeclaration): boolean; + isParameterUsedInFunction(func: FunctionDeclaration, param: ParameterDeclaration): boolean; writeTypeAtLocation(location: Node, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter): void; writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter): void; writeSymbol(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, writer: TextWriter): void; From a2d491d7c6575a52a586170445925a3cf6106ab6 Mon Sep 17 00:00:00 2001 From: Duncan Mak Date: Tue, 26 Aug 2014 00:18:02 -0400 Subject: [PATCH 10/12] Add test case. --- tests/cases/compiler/restParameterEmit.ts | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/cases/compiler/restParameterEmit.ts diff --git a/tests/cases/compiler/restParameterEmit.ts b/tests/cases/compiler/restParameterEmit.ts new file mode 100644 index 0000000000000..f728ffca44ff0 --- /dev/null +++ b/tests/cases/compiler/restParameterEmit.ts @@ -0,0 +1,47 @@ +function shouldEmit(x, y, z, ...rest) { + return rest; +} + +function shouldEmit2(x, y, z, ...rest) { + var a = rest.concat([x, y, z]); +} + +function shouldEmit3(a: string, b: number, ...rest: any[]) { + console.log(g()); + return; + + function g(): any { + return rest[0]; + } +} + +function shouldEmit4(a: number, ...rest: number[]) { + function g(x: number = rest[0]): number { + return a || x; + } + + return g(); +} + +function shouldNotEmit(x, y, z, ...rest) { + return; +} + +var shouldNotEmit2 = (a, b, ...c) => a.concat([1,2,3]); + +function shouldNotEmit3(a: string, b: number, ...rest: any[]) { + console.log(g()); + return; + + function g(): any { + return a; + } +} + +function shouldNotEmit4(a: number, b: number[], ...rest: number[]) { + function g(x: number = b[0]): number { + return a || x; + } + + return g(); +} From 88cae963f41e2b3ae1fdfa1e2af4fffb8f059125 Mon Sep 17 00:00:00 2001 From: Duncan Mak Date: Thu, 28 Aug 2014 18:37:19 -0400 Subject: [PATCH 11/12] Update baseline --- .../arrayLiteralInNonVarArgParameter.js | 4 - ...patWithCallSignaturesWithRestParameters.js | 56 +----- .../reference/baseTypeAfterDerivedType.js | 4 - .../collisionArgumentsArrowFunctions.js | 8 - .../collisionArgumentsClassConstructor.js | 16 -- .../collisionArgumentsClassMethod.js | 12 -- .../reference/collisionArgumentsFunction.js | 12 -- .../collisionArgumentsFunctionExpressions.js | 12 -- .../collisionRestParameterArrowFunctions.js | 8 - .../collisionRestParameterClassConstructor.js | 16 -- .../collisionRestParameterClassMethod.js | 12 -- .../collisionRestParameterFunction.js | 12 -- ...llisionRestParameterFunctionExpressions.js | 12 -- .../collisionRestParameterUnderscoreIUsage.js | 4 - ...RestParametersOfFunctionAndFunctionType.js | 4 - ...detachedCommentAtStartOfLambdaFunction1.js | 11 +- ...detachedCommentAtStartOfLambdaFunction2.js | 7 +- tests/baselines/reference/functionCall10.js | 4 - tests/baselines/reference/functionCall13.js | 4 - tests/baselines/reference/functionCall14.js | 4 - tests/baselines/reference/functionCall15.js | 4 - tests/baselines/reference/functionCall16.js | 4 - tests/baselines/reference/functionCall17.js | 4 - ...tionOverloadsRecursiveGenericReturnType.js | 4 - ...icitAnyDeclareFunctionWithoutFormalType.js | 4 - ...eArgumentsInSignatureWithRestParameters.js | 12 -- .../inheritedConstructorWithRestParams.js | 4 - .../noImplicitAnyParametersInBareFunctions.js | 24 +-- .../noImplicitAnyParametersInClass.js | 48 +---- .../noImplicitAnyParametersInModule.js | 24 +-- .../overloadGenericFunctionWithRestArgs.js | 4 - .../restParameterAssignmentCompatibility.js | 4 - .../reference/restParameterEmit.errors.txt | 53 +++++ .../baselines/reference/restParameterEmit.js | 105 ++++++++++ tests/baselines/reference/restParameters.js | 16 -- .../reference/restParamsWithNonRestParams.js | 12 -- .../reference/sourceMapValidationClass.js | 4 - .../reference/sourceMapValidationClass.js.map | 2 +- .../sourceMapValidationClass.sourcemap.txt | 187 +++++++----------- .../reference/sourceMapValidationFunctions.js | 8 - .../sourceMapValidationFunctions.js.map | 2 +- ...sourceMapValidationFunctions.sourcemap.txt | 138 +++---------- tests/baselines/reference/strictMode5.js | 4 - .../stringLiteralTypeIsSubtypeOfString.js | 4 - .../reference/subtypingWithCallSignatures2.js | 8 +- .../reference/subtypingWithCallSignatures3.js | 16 +- .../reference/undeclaredModuleError.js | 4 - tests/baselines/reference/underscoreTest1.js | 4 - .../reference/varArgParamTypeCheck.js | 4 - tests/baselines/reference/vararg.js | 4 - tests/cases/compiler/restParameterEmit.ts | 4 +- 51 files changed, 288 insertions(+), 653 deletions(-) create mode 100644 tests/baselines/reference/restParameterEmit.errors.txt create mode 100644 tests/baselines/reference/restParameterEmit.js diff --git a/tests/baselines/reference/arrayLiteralInNonVarArgParameter.js b/tests/baselines/reference/arrayLiteralInNonVarArgParameter.js index 57cba07d6bf16..a07e0a05bfced 100644 --- a/tests/baselines/reference/arrayLiteralInNonVarArgParameter.js +++ b/tests/baselines/reference/arrayLiteralInNonVarArgParameter.js @@ -6,9 +6,5 @@ panic([], 'one', 'two'); //// [arrayLiteralInNonVarArgParameter.js] function panic(val) { - var opt = []; - for (var _i = 1; _i < arguments.length; _i++) { - opt[_i - 1] = arguments[_i]; - } } panic([], 'one', 'two'); diff --git a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.js b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.js index f4cf5cc79e29b..9c878e2c4c090 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.js @@ -49,49 +49,19 @@ var a4: (x?: number, y?: string, ...z: number[]) => number; // call signatures in derived types must have the same or fewer optional parameters as the target for assignment var a; // ok, same number of required params a = function () { return 1; }; // ok, same number of required params -a = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } - return 1; -}; // ok, same number of required params -a = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } - return 1; -}; // error, type mismatch +a = function () { return 1; }; // ok, same number of required params +a = function () { return 1; }; // error, type mismatch a = function (x) { return 1; }; // ok, same number of required params a = function (x, y, z) { return 1; }; // ok, same number of required params a = function (x) { return 1; }; // ok, rest param corresponds to infinite number of params a = function (x) { return 1; }; // error, incompatible type var a2; a2 = function () { return 1; }; // ok, fewer required params -a2 = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } - return 1; -}; // ok, fewer required params +a2 = function () { return 1; }; // ok, fewer required params a2 = function (x) { return 1; }; // ok, fewer required params a2 = function (x) { return 1; }; // ok, same number of required params -a2 = function (x) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - return 1; -}; // ok, same number of required params -a2 = function (x) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - return 1; -}; // should be type mismatch error +a2 = function (x) { return 1; }; // ok, same number of required params +a2 = function (x) { return 1; }; // should be type mismatch error a2 = function (x, y) { return 1; }; // ok, rest param corresponds to infinite number of params a2 = function (x, y) { return 1; }; // ok, same number of required params var a3; @@ -100,13 +70,7 @@ a3 = function (x) { return 1; }; // ok, fewer required params a3 = function (x) { return 1; }; // ok, same number of required params a3 = function (x, y) { return 1; }; // ok, all present params match a3 = function (x, y, z) { return 1; }; // error -a3 = function (x) { - var z = []; - for (var _i = 1; _i < arguments.length; _i++) { - z[_i - 1] = arguments[_i]; - } - return 1; -}; // error +a3 = function (x) { return 1; }; // error a3 = function (x, y, z) { return 1; }; // error var a4; a4 = function () { return 1; }; // ok, fewer required params @@ -114,10 +78,4 @@ a4 = function (x, y) { return 1; }; // error, type mismatch a4 = function (x) { return 1; }; // ok, all present params match a4 = function (x, y) { return 1; }; // error, second param has type mismatch a4 = function (x, y) { return 1; }; // ok, same number of required params with matching types -a4 = function (x) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - return 1; -}; // error, rest params have type mismatch +a4 = function (x) { return 1; }; // error, rest params have type mismatch diff --git a/tests/baselines/reference/baseTypeAfterDerivedType.js b/tests/baselines/reference/baseTypeAfterDerivedType.js index c64239ac0c86f..6191c0123f344 100644 --- a/tests/baselines/reference/baseTypeAfterDerivedType.js +++ b/tests/baselines/reference/baseTypeAfterDerivedType.js @@ -21,10 +21,6 @@ var Derived2 = (function () { function Derived2() { } Derived2.prototype.method = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } }; return Derived2; })(); diff --git a/tests/baselines/reference/collisionArgumentsArrowFunctions.js b/tests/baselines/reference/collisionArgumentsArrowFunctions.js index 0aa939e1a2d7f..8f410ca5d23d2 100644 --- a/tests/baselines/reference/collisionArgumentsArrowFunctions.js +++ b/tests/baselines/reference/collisionArgumentsArrowFunctions.js @@ -25,20 +25,12 @@ var f1 = function (i) { var arguments; // no error }; var f12 = function (arguments) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } var arguments = 10; // no error }; var f1NoError = function (arguments) { var arguments = 10; // no error }; var f2 = function () { - var restParameters = []; - for (var _i = 0; _i < arguments.length; _i++) { - restParameters[_i - 0] = arguments[_i]; - } var arguments = 10; // No Error }; var f2NoError = function () { diff --git a/tests/baselines/reference/collisionArgumentsClassConstructor.js b/tests/baselines/reference/collisionArgumentsClassConstructor.js index ca743777b39d8..6faf10565eb62 100644 --- a/tests/baselines/reference/collisionArgumentsClassConstructor.js +++ b/tests/baselines/reference/collisionArgumentsClassConstructor.js @@ -100,10 +100,6 @@ var c1 = (function () { })(); var c12 = (function () { function c12(arguments) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } var arguments = 10; // no error } return c12; @@ -116,10 +112,6 @@ var c1NoError = (function () { })(); var c2 = (function () { function c2() { - var restParameters = []; - for (var _i = 0; _i < arguments.length; _i++) { - restParameters[_i - 0] = arguments[_i]; - } var arguments = 10; // no error } return c2; @@ -132,10 +124,6 @@ var c2NoError = (function () { })(); var c3 = (function () { function c3(arguments) { - var restParameters = []; - for (var _i = 1; _i < arguments.length; _i++) { - restParameters[_i - 1] = arguments[_i]; - } this.arguments = arguments; var arguments = 10; // no error } @@ -160,10 +148,6 @@ var c5 = (function () { })(); var c52 = (function () { function c52(arguments) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } var arguments; // no error } return c52; diff --git a/tests/baselines/reference/collisionArgumentsClassMethod.js b/tests/baselines/reference/collisionArgumentsClassMethod.js index 10c9b28854408..328bdd8fc7df3 100644 --- a/tests/baselines/reference/collisionArgumentsClassMethod.js +++ b/tests/baselines/reference/collisionArgumentsClassMethod.js @@ -60,10 +60,6 @@ var c1 = (function () { var arguments; // no error }; c1.prototype.foo1 = function (arguments) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } var arguments = 10; // no error }; c1.prototype.fooNoError = function (arguments) { @@ -77,10 +73,6 @@ var c1 = (function () { var arguments; // no error }; c1.prototype.f41 = function (arguments) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } var arguments; // no error }; c1.prototype.f4NoError = function (arguments) { @@ -92,10 +84,6 @@ var c3 = (function () { function c3() { } c3.prototype.foo = function () { - var restParameters = []; - for (var _i = 0; _i < arguments.length; _i++) { - restParameters[_i - 0] = arguments[_i]; - } var arguments = 10; // no error }; c3.prototype.fooNoError = function () { diff --git a/tests/baselines/reference/collisionArgumentsFunction.js b/tests/baselines/reference/collisionArgumentsFunction.js index 9ce4a5ab0e20b..e52f6cd675a4c 100644 --- a/tests/baselines/reference/collisionArgumentsFunction.js +++ b/tests/baselines/reference/collisionArgumentsFunction.js @@ -47,10 +47,6 @@ declare function f6(arguments: string); // no codegen no error //// [collisionArgumentsFunction.js] // Functions function f1(arguments) { - var restParameters = []; - for (var _i = 1; _i < arguments.length; _i++) { - restParameters[_i - 1] = arguments[_i]; - } var arguments = 10; // no error } function f12(i) { @@ -64,20 +60,12 @@ function f1NoError(arguments) { var arguments = 10; // no error } function f3() { - var restParameters = []; - for (var _i = 0; _i < arguments.length; _i++) { - restParameters[_i - 0] = arguments[_i]; - } var arguments = 10; // no error } function f3NoError() { var arguments = 10; // no error } function f4(arguments) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } var arguments; // No error } function f42(i) { diff --git a/tests/baselines/reference/collisionArgumentsFunctionExpressions.js b/tests/baselines/reference/collisionArgumentsFunctionExpressions.js index 405ceb625c3c9..e4290dd84590a 100644 --- a/tests/baselines/reference/collisionArgumentsFunctionExpressions.js +++ b/tests/baselines/reference/collisionArgumentsFunctionExpressions.js @@ -37,10 +37,6 @@ function foo() { //// [collisionArgumentsFunctionExpressions.js] function foo() { function f1(arguments) { - var restParameters = []; - for (var _i = 1; _i < arguments.length; _i++) { - restParameters[_i - 1] = arguments[_i]; - } var arguments = 10; // no error } function f12(i) { @@ -54,20 +50,12 @@ function foo() { var arguments = 10; // no error } function f3() { - var restParameters = []; - for (var _i = 0; _i < arguments.length; _i++) { - restParameters[_i - 0] = arguments[_i]; - } var arguments = 10; // no error } function f3NoError() { var arguments = 10; // no error } function f4(arguments) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } var arguments; // No error } function f42(i) { diff --git a/tests/baselines/reference/collisionRestParameterArrowFunctions.js b/tests/baselines/reference/collisionRestParameterArrowFunctions.js index cc8dc337b87fd..785d8d49bd866 100644 --- a/tests/baselines/reference/collisionRestParameterArrowFunctions.js +++ b/tests/baselines/reference/collisionRestParameterArrowFunctions.js @@ -15,20 +15,12 @@ var f2NoError = () => { //// [collisionRestParameterArrowFunctions.js] var f1 = function (_i) { - var restParameters = []; - for (var _i = 1; _i < arguments.length; _i++) { - restParameters[_i - 1] = arguments[_i]; - } var _i = 10; // no error }; var f1NoError = function (_i) { var _i = 10; // no error }; var f2 = function () { - var restParameters = []; - for (var _i = 0; _i < arguments.length; _i++) { - restParameters[_i - 0] = arguments[_i]; - } var _i = 10; // No Error }; var f2NoError = function () { diff --git a/tests/baselines/reference/collisionRestParameterClassConstructor.js b/tests/baselines/reference/collisionRestParameterClassConstructor.js index 02c7ada9dff89..b37a5c31334df 100644 --- a/tests/baselines/reference/collisionRestParameterClassConstructor.js +++ b/tests/baselines/reference/collisionRestParameterClassConstructor.js @@ -70,10 +70,6 @@ declare class c6NoError { // Constructors var c1 = (function () { function c1(_i) { - var restParameters = []; - for (var _i = 1; _i < arguments.length; _i++) { - restParameters[_i - 1] = arguments[_i]; - } var _i = 10; // no error } return c1; @@ -86,10 +82,6 @@ var c1NoError = (function () { })(); var c2 = (function () { function c2() { - var restParameters = []; - for (var _i = 0; _i < arguments.length; _i++) { - restParameters[_i - 0] = arguments[_i]; - } var _i = 10; // no error } return c2; @@ -102,10 +94,6 @@ var c2NoError = (function () { })(); var c3 = (function () { function c3(_i) { - var restParameters = []; - for (var _i = 1; _i < arguments.length; _i++) { - restParameters[_i - 1] = arguments[_i]; - } this._i = _i; var _i = 10; // no error } @@ -120,10 +108,6 @@ var c3NoError = (function () { })(); var c5 = (function () { function c5(_i) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } var _i; // no error } return c5; diff --git a/tests/baselines/reference/collisionRestParameterClassMethod.js b/tests/baselines/reference/collisionRestParameterClassMethod.js index 326ad0c424d92..22e8d530123f6 100644 --- a/tests/baselines/reference/collisionRestParameterClassMethod.js +++ b/tests/baselines/reference/collisionRestParameterClassMethod.js @@ -43,20 +43,12 @@ var c1 = (function () { function c1() { } c1.prototype.foo = function (_i) { - var restParameters = []; - for (var _i = 1; _i < arguments.length; _i++) { - restParameters[_i - 1] = arguments[_i]; - } var _i = 10; // no error }; c1.prototype.fooNoError = function (_i) { var _i = 10; // no error }; c1.prototype.f4 = function (_i) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } var _i; // no error }; c1.prototype.f4NoError = function (_i) { @@ -68,10 +60,6 @@ var c3 = (function () { function c3() { } c3.prototype.foo = function () { - var restParameters = []; - for (var _i = 0; _i < arguments.length; _i++) { - restParameters[_i - 0] = arguments[_i]; - } var _i = 10; // no error }; c3.prototype.fooNoError = function () { diff --git a/tests/baselines/reference/collisionRestParameterFunction.js b/tests/baselines/reference/collisionRestParameterFunction.js index c81dbb0f8d3dc..a1f47aafdca87 100644 --- a/tests/baselines/reference/collisionRestParameterFunction.js +++ b/tests/baselines/reference/collisionRestParameterFunction.js @@ -36,30 +36,18 @@ declare function f6(_i: string); // no codegen no error //// [collisionRestParameterFunction.js] // Functions function f1(_i) { - var restParameters = []; - for (var _i = 1; _i < arguments.length; _i++) { - restParameters[_i - 1] = arguments[_i]; - } var _i = 10; // no error } function f1NoError(_i) { var _i = 10; // no error } function f3() { - var restParameters = []; - for (var _i = 0; _i < arguments.length; _i++) { - restParameters[_i - 0] = arguments[_i]; - } var _i = 10; // no error } function f3NoError() { var _i = 10; // no error } function f4(_i) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } } function f4NoError(_i) { } diff --git a/tests/baselines/reference/collisionRestParameterFunctionExpressions.js b/tests/baselines/reference/collisionRestParameterFunctionExpressions.js index 4f1dea2b11ea8..dd2f5ff08d3f4 100644 --- a/tests/baselines/reference/collisionRestParameterFunctionExpressions.js +++ b/tests/baselines/reference/collisionRestParameterFunctionExpressions.js @@ -27,30 +27,18 @@ function foo() { //// [collisionRestParameterFunctionExpressions.js] function foo() { function f1(_i) { - var restParameters = []; - for (var _i = 1; _i < arguments.length; _i++) { - restParameters[_i - 1] = arguments[_i]; - } var _i = 10; // no error } function f1NoError(_i) { var _i = 10; // no error } function f3() { - var restParameters = []; - for (var _i = 0; _i < arguments.length; _i++) { - restParameters[_i - 0] = arguments[_i]; - } var _i = 10; // no error } function f3NoError() { var _i = 10; // no error } function f4(_i) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } } function f4NoError(_i) { } diff --git a/tests/baselines/reference/collisionRestParameterUnderscoreIUsage.js b/tests/baselines/reference/collisionRestParameterUnderscoreIUsage.js index b8d3aaec91c4a..adc9fd23f81c1 100644 --- a/tests/baselines/reference/collisionRestParameterUnderscoreIUsage.js +++ b/tests/baselines/reference/collisionRestParameterUnderscoreIUsage.js @@ -12,10 +12,6 @@ new Foo(); var _i = "This is what I'd expect to see"; var Foo = (function () { function Foo() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } console.log(_i); // This should result in error } return Foo; diff --git a/tests/baselines/reference/declFileRestParametersOfFunctionAndFunctionType.js b/tests/baselines/reference/declFileRestParametersOfFunctionAndFunctionType.js index 5ff631c6aadb7..0bf266d5c0436 100644 --- a/tests/baselines/reference/declFileRestParametersOfFunctionAndFunctionType.js +++ b/tests/baselines/reference/declFileRestParametersOfFunctionAndFunctionType.js @@ -12,10 +12,6 @@ var f6 = () => { return [10]; } //// [declFileRestParametersOfFunctionAndFunctionType.js] function f1() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } } function f2(x) { } diff --git a/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction1.js b/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction1.js index 2505e3f60826e..385bdbba77987 100644 --- a/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction1.js +++ b/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction1.js @@ -16,16 +16,7 @@ var TestFile = (function () { } TestFile.prototype.foo = function (message) { var _this = this; - return function () { - var x = []; - for (var _i = 0; _i < arguments.length; _i++) { - x[_i - 0] = arguments[_i]; - } - /// Test summary - /// - /// - return message + _this.name; - }; + return function () { return message + _this.name; }; }; return TestFile; })(); diff --git a/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction2.js b/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction2.js index 53f6d08eaf557..3ca8728d215c0 100644 --- a/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction2.js +++ b/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction2.js @@ -21,12 +21,7 @@ var TestFile = (function () { /// Test summary /// /// - var x = []; - for (var _i = 0; _i < arguments.length; _i++) { - x[_i - 0] = arguments[_i]; - } - return message + _this.name; - }; + return message + _this.name; }; }; return TestFile; })(); diff --git a/tests/baselines/reference/functionCall10.js b/tests/baselines/reference/functionCall10.js index 9d5cb33a56a3b..55c60ac5495bc 100644 --- a/tests/baselines/reference/functionCall10.js +++ b/tests/baselines/reference/functionCall10.js @@ -8,10 +8,6 @@ foo(1, 'bar'); //// [functionCall10.js] function foo() { - var a = []; - for (var _i = 0; _i < arguments.length; _i++) { - a[_i - 0] = arguments[_i]; - } } ; foo(0, 1); diff --git a/tests/baselines/reference/functionCall13.js b/tests/baselines/reference/functionCall13.js index ce57f43215e4d..a7e64df49dea9 100644 --- a/tests/baselines/reference/functionCall13.js +++ b/tests/baselines/reference/functionCall13.js @@ -9,10 +9,6 @@ foo('foo', 1, 3); //// [functionCall13.js] function foo(a) { - var b = []; - for (var _i = 1; _i < arguments.length; _i++) { - b[_i - 1] = arguments[_i]; - } } foo('foo', 1); foo('foo'); diff --git a/tests/baselines/reference/functionCall14.js b/tests/baselines/reference/functionCall14.js index 47447f46db5ca..61a272ecee97e 100644 --- a/tests/baselines/reference/functionCall14.js +++ b/tests/baselines/reference/functionCall14.js @@ -9,10 +9,6 @@ foo('foo', 1, 3); //// [functionCall14.js] function foo(a) { - var b = []; - for (var _i = 1; _i < arguments.length; _i++) { - b[_i - 1] = arguments[_i]; - } } foo('foo', 1); foo('foo'); diff --git a/tests/baselines/reference/functionCall15.js b/tests/baselines/reference/functionCall15.js index 28fa4c917c867..4db2056510935 100644 --- a/tests/baselines/reference/functionCall15.js +++ b/tests/baselines/reference/functionCall15.js @@ -3,8 +3,4 @@ function foo(a?:string, b?:number, ...b:number[]){} //// [functionCall15.js] function foo(a, b) { - var b = []; - for (var _i = 2; _i < arguments.length; _i++) { - b[_i - 2] = arguments[_i]; - } } diff --git a/tests/baselines/reference/functionCall16.js b/tests/baselines/reference/functionCall16.js index 187572a9a7e84..7a2ff1b9e23e6 100644 --- a/tests/baselines/reference/functionCall16.js +++ b/tests/baselines/reference/functionCall16.js @@ -10,10 +10,6 @@ foo('foo', 'bar', 3); //// [functionCall16.js] function foo(a, b) { - var c = []; - for (var _i = 2; _i < arguments.length; _i++) { - c[_i - 2] = arguments[_i]; - } } foo('foo', 1); foo('foo'); diff --git a/tests/baselines/reference/functionCall17.js b/tests/baselines/reference/functionCall17.js index 73f7fd6070b22..a8cda3697133f 100644 --- a/tests/baselines/reference/functionCall17.js +++ b/tests/baselines/reference/functionCall17.js @@ -10,10 +10,6 @@ foo('foo', 'bar', 3, 4); //// [functionCall17.js] function foo(a, b, c) { - var d = []; - for (var _i = 3; _i < arguments.length; _i++) { - d[_i - 3] = arguments[_i]; - } } foo('foo', 1); foo('foo'); diff --git a/tests/baselines/reference/functionOverloadsRecursiveGenericReturnType.js b/tests/baselines/reference/functionOverloadsRecursiveGenericReturnType.js index ab0baf2059296..8a96c12fd9385 100644 --- a/tests/baselines/reference/functionOverloadsRecursiveGenericReturnType.js +++ b/tests/baselines/reference/functionOverloadsRecursiveGenericReturnType.js @@ -26,9 +26,5 @@ var A = (function () { return A; })(); function Choice() { - var v_args = []; - for (var _i = 0; _i < arguments.length; _i++) { - v_args[_i - 0] = arguments[_i]; - } return new A(); } diff --git a/tests/baselines/reference/implicitAnyDeclareFunctionWithoutFormalType.js b/tests/baselines/reference/implicitAnyDeclareFunctionWithoutFormalType.js index 72d68da22872b..566204f6d666d 100644 --- a/tests/baselines/reference/implicitAnyDeclareFunctionWithoutFormalType.js +++ b/tests/baselines/reference/implicitAnyDeclareFunctionWithoutFormalType.js @@ -23,10 +23,6 @@ function func2(a, b, c) { } ; function func3() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } } ; function func4(z, w) { diff --git a/tests/baselines/reference/inferTypeArgumentsInSignatureWithRestParameters.js b/tests/baselines/reference/inferTypeArgumentsInSignatureWithRestParameters.js index 1cc86829a6b0b..b1a9e332b13e4 100644 --- a/tests/baselines/reference/inferTypeArgumentsInSignatureWithRestParameters.js +++ b/tests/baselines/reference/inferTypeArgumentsInSignatureWithRestParameters.js @@ -13,22 +13,10 @@ i(a); // OK //// [inferTypeArgumentsInSignatureWithRestParameters.js] function f(array) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } } function g(array) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } } function h(nonarray) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } } function i(array, opt) { } diff --git a/tests/baselines/reference/inheritedConstructorWithRestParams.js b/tests/baselines/reference/inheritedConstructorWithRestParams.js index b924fe25db9c8..9585d084d9ae0 100644 --- a/tests/baselines/reference/inheritedConstructorWithRestParams.js +++ b/tests/baselines/reference/inheritedConstructorWithRestParams.js @@ -23,10 +23,6 @@ var __extends = this.__extends || function (d, b) { }; var Base = (function () { function Base() { - var a = []; - for (var _i = 0; _i < arguments.length; _i++) { - a[_i - 0] = arguments[_i]; - } } return Base; })(); diff --git a/tests/baselines/reference/noImplicitAnyParametersInBareFunctions.js b/tests/baselines/reference/noImplicitAnyParametersInBareFunctions.js index 06848d7e89af4..ee33f142265e9 100644 --- a/tests/baselines/reference/noImplicitAnyParametersInBareFunctions.js +++ b/tests/baselines/reference/noImplicitAnyParametersInBareFunctions.js @@ -62,17 +62,9 @@ function f5(x, y, z) { } // Implicit-'any[]' error for r. function f6() { - var r = []; - for (var _i = 0; _i < arguments.length; _i++) { - r[_i - 0] = arguments[_i]; - } } // Implicit-'any'/'any[]' errors for x, r. function f7(x) { - var r = []; - for (var _i = 1; _i < arguments.length; _i++) { - r[_i - 1] = arguments[_i]; - } } function f8(x3, y3) { } @@ -85,18 +77,6 @@ var f11 = function (x, y, z) { return ""; }; // Implicit-'any' errors for x and z. var f12 = function (x, y, z) { return ""; }; // Implicit-'any[]' error for r. -var f13 = function () { - var r = []; - for (var _i = 0; _i < arguments.length; _i++) { - r[_i - 0] = arguments[_i]; - } - return ""; -}; +var f13 = function () { return ""; }; // Implicit-'any'/'any[]' errors for x, r. -var f14 = function (x) { - var r = []; - for (var _i = 1; _i < arguments.length; _i++) { - r[_i - 1] = arguments[_i]; - } - return ""; -}; +var f14 = function (x) { return ""; }; diff --git a/tests/baselines/reference/noImplicitAnyParametersInClass.js b/tests/baselines/reference/noImplicitAnyParametersInClass.js index 82164884b801c..97b94d956b309 100644 --- a/tests/baselines/reference/noImplicitAnyParametersInClass.js +++ b/tests/baselines/reference/noImplicitAnyParametersInClass.js @@ -104,21 +104,9 @@ var C = (function () { // Implicit-'any' errors for x and z. this.pub_f12 = function (x, y, z) { return ""; }; // Implicit-'any[]' error for r. - this.pub_f13 = function () { - var r = []; - for (var _i = 0; _i < arguments.length; _i++) { - r[_i - 0] = arguments[_i]; - } - return ""; - }; + this.pub_f13 = function () { return ""; }; // Implicit-'any'/'any[]' errors for x, r. - this.pub_f14 = function (x) { - var r = []; - for (var _i = 1; _i < arguments.length; _i++) { - r[_i - 1] = arguments[_i]; - } - return ""; - }; + this.pub_f14 = function (x) { return ""; }; // No implicit-'any' errors. this.priv_f9 = function () { return ""; }; // Implicit-'any' errors for x. @@ -128,21 +116,9 @@ var C = (function () { // Implicit-'any' errors for x and z. this.priv_f12 = function (x, y, z) { return ""; }; // Implicit-'any[]' error for r. - this.priv_f13 = function () { - var r = []; - for (var _i = 0; _i < arguments.length; _i++) { - r[_i - 0] = arguments[_i]; - } - return ""; - }; + this.priv_f13 = function () { return ""; }; // Implicit-'any'/'any[]' errors for x, r. - this.priv_f14 = function (x) { - var r = []; - for (var _i = 1; _i < arguments.length; _i++) { - r[_i - 1] = arguments[_i]; - } - return ""; - }; + this.priv_f14 = function (x) { return ""; }; } // No implicit-'any' errors. C.prototype.pub_f1 = function () { @@ -161,17 +137,9 @@ var C = (function () { }; // Implicit-'any[]' errors for r. C.prototype.pub_f6 = function () { - var r = []; - for (var _i = 0; _i < arguments.length; _i++) { - r[_i - 0] = arguments[_i]; - } }; // Implicit-'any'/'any[]' errors for x, r. C.prototype.pub_f7 = function (x) { - var r = []; - for (var _i = 1; _i < arguments.length; _i++) { - r[_i - 1] = arguments[_i]; - } }; C.prototype.pub_f8 = function (x3, y3) { }; @@ -193,17 +161,9 @@ var C = (function () { }; // Implicit-'any[]' errors for r. C.prototype.priv_f6 = function () { - var r = []; - for (var _i = 0; _i < arguments.length; _i++) { - r[_i - 0] = arguments[_i]; - } }; // Implicit-'any'/'any[]' errors for x, r. C.prototype.priv_f7 = function (x) { - var r = []; - for (var _i = 1; _i < arguments.length; _i++) { - r[_i - 1] = arguments[_i]; - } }; C.prototype.priv_f8 = function (x3, y3) { }; diff --git a/tests/baselines/reference/noImplicitAnyParametersInModule.js b/tests/baselines/reference/noImplicitAnyParametersInModule.js index fccb16cefa79a..fb10f361d9e70 100644 --- a/tests/baselines/reference/noImplicitAnyParametersInModule.js +++ b/tests/baselines/reference/noImplicitAnyParametersInModule.js @@ -66,17 +66,9 @@ var M; } // Implicit-'any[]' error for r. function m_f6() { - var r = []; - for (var _i = 0; _i < arguments.length; _i++) { - r[_i - 0] = arguments[_i]; - } } // Implicit-'any'/'any[]' errors for x and r. function m_f7(x) { - var r = []; - for (var _i = 1; _i < arguments.length; _i++) { - r[_i - 1] = arguments[_i]; - } } function m_f8(x3, y3) { } @@ -89,19 +81,7 @@ var M; // Implicit-'any' errors for x and z. var m_f12 = function (x, y, z) { return ""; }; // Implicit-'any[]' errors for r. - var m_f13 = function () { - var r = []; - for (var _i = 0; _i < arguments.length; _i++) { - r[_i - 0] = arguments[_i]; - } - return ""; - }; + var m_f13 = function () { return ""; }; // Implicit-'any'/'any[]' errors for x and r. - var m_f14 = function (x) { - var r = []; - for (var _i = 1; _i < arguments.length; _i++) { - r[_i - 1] = arguments[_i]; - } - return ""; - }; + var m_f14 = function (x) { return ""; }; })(M || (M = {})); diff --git a/tests/baselines/reference/overloadGenericFunctionWithRestArgs.js b/tests/baselines/reference/overloadGenericFunctionWithRestArgs.js index c4b133ea44c48..e47e4db0145de 100644 --- a/tests/baselines/reference/overloadGenericFunctionWithRestArgs.js +++ b/tests/baselines/reference/overloadGenericFunctionWithRestArgs.js @@ -22,9 +22,5 @@ var A = (function () { return A; })(); function Choice() { - var v_args = []; - for (var _i = 0; _i < arguments.length; _i++) { - v_args[_i - 0] = arguments[_i]; - } return new A(); } diff --git a/tests/baselines/reference/restParameterAssignmentCompatibility.js b/tests/baselines/reference/restParameterAssignmentCompatibility.js index 62c0204c74991..cdfc257db4141 100644 --- a/tests/baselines/reference/restParameterAssignmentCompatibility.js +++ b/tests/baselines/reference/restParameterAssignmentCompatibility.js @@ -31,10 +31,6 @@ var T = (function () { function T() { } T.prototype.m = function () { - var p3 = []; - for (var _i = 0; _i < arguments.length; _i++) { - p3[_i - 0] = arguments[_i]; - } }; return T; })(); diff --git a/tests/baselines/reference/restParameterEmit.errors.txt b/tests/baselines/reference/restParameterEmit.errors.txt new file mode 100644 index 0000000000000..d099b80e488df --- /dev/null +++ b/tests/baselines/reference/restParameterEmit.errors.txt @@ -0,0 +1,53 @@ +==== tests/cases/compiler/restParameterEmit.ts (2 errors) ==== + function shouldEmit(x, y, z, ...rest) { + return rest; + } + + function shouldEmit2(x, y, z, ...rest) { + var a = rest.concat([x, y, z]); + } + + function shouldEmit3(a: string, b: number, ...rest: any[]) { + console.log(g()); + ~~~~~~~ +!!! Cannot find name 'console'. + return; + + function g(): any { + return rest[0]; + } + } + + function shouldEmit4(a: number, ...rest: number[]) { + function g(x: number = rest[0]): number { + return a || x; + } + + return g(); + } + + function shouldNotEmit(x, y, z, ...rest) { + return; + } + + var shouldNotEmit2 = (a, b, ...c) => a.concat([1,2,3]); + + function shouldNotEmit3(a: string, b: number, ...rest: any[]) { + console.log(g()); + ~~~~~~~ +!!! Cannot find name 'console'. + return; + + function g(): any { + return a; + } + } + + function shouldNotEmit4(a: number, b: number[], ...rest: number[]) { + function g(x: number = b[0]): number { + return a || x; + } + + return g(); + } + \ No newline at end of file diff --git a/tests/baselines/reference/restParameterEmit.js b/tests/baselines/reference/restParameterEmit.js new file mode 100644 index 0000000000000..6e3f49f490d78 --- /dev/null +++ b/tests/baselines/reference/restParameterEmit.js @@ -0,0 +1,105 @@ +//// [restParameterEmit.ts] +function shouldEmit(x, y, z, ...rest) { + return rest; +} + +function shouldEmit2(x, y, z, ...rest) { + var a = rest.concat([x, y, z]); +} + +function shouldEmit3(a: string, b: number, ...rest: any[]) { + console.log(g()); + return; + + function g(): any { + return rest[0]; + } +} + +function shouldEmit4(a: number, ...rest: number[]) { + function g(x: number = rest[0]): number { + return a || x; + } + + return g(); +} + +function shouldNotEmit(x, y, z, ...rest) { + return; +} + +var shouldNotEmit2 = (a, b, ...c) => a.concat([1,2,3]); + +function shouldNotEmit3(a: string, b: number, ...rest: any[]) { + console.log(g()); + return; + + function g(): any { + return a; + } +} + +function shouldNotEmit4(a: number, b: number[], ...rest: number[]) { + function g(x: number = b[0]): number { + return a || x; + } + + return g(); +} + + +//// [restParameterEmit.js] +function shouldEmit(x, y, z) { + var rest = []; + for (var _i = 3; _i < arguments.length; _i++) { + rest[_i - 3] = arguments[_i]; + } + return rest; +} +function shouldEmit2(x, y, z) { + var rest = []; + for (var _i = 3; _i < arguments.length; _i++) { + rest[_i - 3] = arguments[_i]; + } + var a = rest.concat([x, y, z]); +} +function shouldEmit3(a, b) { + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } + console.log(g()); + return; + function g() { + return rest[0]; + } +} +function shouldEmit4(a) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + function g(x) { + if (x === void 0) { x = rest[0]; } + return a || x; + } + return g(); +} +function shouldNotEmit(x, y, z) { + return; +} +var shouldNotEmit2 = function (a, b) { return a.concat([1, 2, 3]); }; +function shouldNotEmit3(a, b) { + console.log(g()); + return; + function g() { + return a; + } +} +function shouldNotEmit4(a, b) { + function g(x) { + if (x === void 0) { x = b[0]; } + return a || x; + } + return g(); +} diff --git a/tests/baselines/reference/restParameters.js b/tests/baselines/reference/restParameters.js index 2e5b7bb4c928a..833c6fd8598d4 100644 --- a/tests/baselines/reference/restParameters.js +++ b/tests/baselines/reference/restParameters.js @@ -9,26 +9,10 @@ function f21(a:string, b?:string, c?:number, ...d:number[]){} //// [restParameters.js] function f18(a) { - var b = []; - for (var _i = 1; _i < arguments.length; _i++) { - b[_i - 1] = arguments[_i]; - } } function f19(a, b) { - var c = []; - for (var _i = 2; _i < arguments.length; _i++) { - c[_i - 2] = arguments[_i]; - } } function f20(a, b) { - var c = []; - for (var _i = 2; _i < arguments.length; _i++) { - c[_i - 2] = arguments[_i]; - } } function f21(a, b, c) { - var d = []; - for (var _i = 3; _i < arguments.length; _i++) { - d[_i - 3] = arguments[_i]; - } } diff --git a/tests/baselines/reference/restParamsWithNonRestParams.js b/tests/baselines/reference/restParamsWithNonRestParams.js index 6b0caa723940a..a71863f8cd503 100644 --- a/tests/baselines/reference/restParamsWithNonRestParams.js +++ b/tests/baselines/reference/restParamsWithNonRestParams.js @@ -8,23 +8,11 @@ foo3(); // error but shouldn't be //// [restParamsWithNonRestParams.js] function foo() { - var b = []; - for (var _i = 0; _i < arguments.length; _i++) { - b[_i - 0] = arguments[_i]; - } } foo(); // ok function foo2(a) { - var b = []; - for (var _i = 1; _i < arguments.length; _i++) { - b[_i - 1] = arguments[_i]; - } } foo2(); // should be an error function foo3(a) { - var b = []; - for (var _i = 1; _i < arguments.length; _i++) { - b[_i - 1] = arguments[_i]; - } } foo3(); // error but shouldn't be diff --git a/tests/baselines/reference/sourceMapValidationClass.js b/tests/baselines/reference/sourceMapValidationClass.js index eef5a723ebf3e..e2ca47b3ffe77 100644 --- a/tests/baselines/reference/sourceMapValidationClass.js +++ b/tests/baselines/reference/sourceMapValidationClass.js @@ -21,10 +21,6 @@ class Greeter { //// [sourceMapValidationClass.js] var Greeter = (function () { function Greeter(greeting) { - var b = []; - for (var _i = 1; _i < arguments.length; _i++) { - b[_i - 1] = arguments[_i]; - } this.greeting = greeting; this.x1 = 10; } diff --git a/tests/baselines/reference/sourceMapValidationClass.js.map b/tests/baselines/reference/sourceMapValidationClass.js.map index 661459022b1d6..29119fe85b60d 100644 --- a/tests/baselines/reference/sourceMapValidationClass.js.map +++ b/tests/baselines/reference/sourceMapValidationClass.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationClass.js.map] -{"version":3,"file":"sourceMapValidationClass.js","sourceRoot":"","sources":["sourceMapValidationClass.ts"],"names":["Greeter","Greeter.constructor","Greeter.greet","Greeter.fn","Greeter.greetings"],"mappings":"AAAA,IAAM,OAAO;IACTA,SADEA,OAAOA,CACUA,QAAgBA;QAAEC,WAAcA;aAAdA,WAAcA,CAAdA,sBAAcA,CAAdA,IAAcA;YAAdA,0BAAcA;;QAAhCA,aAAQA,GAARA,QAAQA,CAAQA;QAM3BA,OAAEA,GAAWA,EAAEA,CAACA;IALxBA,CAACA;IACDD,uBAAKA,GAALA;QACIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;IAC5CA,CAACA;IAGOF,oBAAEA,GAAVA;QACIG,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;IACzBA,CAACA;IACDH,sBAAIA,8BAASA;aAAbA;YACII,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;QACzBA,CAACA;aACDJ,UAAcA,SAAiBA;YAC3BI,IAAIA,CAACA,QAAQA,GAAGA,SAASA,CAACA;QAC9BA,CAACA;;;OAHAJ;IAILA,cAACA;AAADA,CAACA,AAjBD,IAiBC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationClass.js","sourceRoot":"","sources":["sourceMapValidationClass.ts"],"names":["Greeter","Greeter.constructor","Greeter.greet","Greeter.fn","Greeter.greetings"],"mappings":"AAAA,IAAM,OAAO;IACTA,SADEA,OAAOA,CACUA,QAAgBA;QAAhBC,aAAQA,GAARA,QAAQA,CAAQA;QAM3BA,OAAEA,GAAWA,EAAEA,CAACA;IALxBA,CAACA;IACDD,uBAAKA,GAALA;QACIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;IAC5CA,CAACA;IAGOF,oBAAEA,GAAVA;QACIG,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;IACzBA,CAACA;IACDH,sBAAIA,8BAASA;aAAbA;YACII,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;QACzBA,CAACA;aACDJ,UAAcA,SAAiBA;YAC3BI,IAAIA,CAACA,QAAQA,GAAGA,SAASA,CAACA;QAC9BA,CAACA;;;OAHAJ;IAILA,cAACA;AAADA,CAACA,AAjBD,IAiBC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationClass.sourcemap.txt b/tests/baselines/reference/sourceMapValidationClass.sourcemap.txt index 1c80abde32e90..16041fced4b1c 100644 --- a/tests/baselines/reference/sourceMapValidationClass.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationClass.sourcemap.txt @@ -26,6 +26,7 @@ sourceFile:sourceMapValidationClass.ts 3 > ^^^^^^^ 4 > ^ 5 > ^^^^^^^^ +6 > ^^^^^-> 1-> { > 2 > @@ -39,60 +40,22 @@ sourceFile:sourceMapValidationClass.ts 4 >Emitted(2, 22) Source(2, 24) + SourceIndex(0) name (Greeter) 5 >Emitted(2, 30) Source(2, 40) + SourceIndex(0) name (Greeter) --- ->>> var b = []; -1 >^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >, -2 > ...b: string[] -1 >Emitted(3, 9) Source(2, 42) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(3, 20) Source(2, 56) + SourceIndex(0) name (Greeter.constructor) ---- ->>> for (var _i = 1; _i < arguments.length; _i++) { -1->^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^^^ -5 > ^ -6 > ^^^^ -1-> -2 > ...b: string[] -3 > -4 > ...b: string[] -5 > -6 > ...b: string[] -1->Emitted(4, 14) Source(2, 42) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(4, 25) Source(2, 56) + SourceIndex(0) name (Greeter.constructor) -3 >Emitted(4, 26) Source(2, 42) + SourceIndex(0) name (Greeter.constructor) -4 >Emitted(4, 48) Source(2, 56) + SourceIndex(0) name (Greeter.constructor) -5 >Emitted(4, 49) Source(2, 42) + SourceIndex(0) name (Greeter.constructor) -6 >Emitted(4, 53) Source(2, 56) + SourceIndex(0) name (Greeter.constructor) ---- ->>> b[_i - 1] = arguments[_i]; -1 >^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 > -2 > ...b: string[] -1 >Emitted(5, 13) Source(2, 42) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(5, 39) Source(2, 56) + SourceIndex(0) name (Greeter.constructor) ---- ->>> } >>> this.greeting = greeting; -1 >^^^^^^^^ +1->^^^^^^^^ 2 > ^^^^^^^^^^^^^ 3 > ^^^ 4 > ^^^^^^^^ 5 > ^ -1 > +1-> 2 > greeting 3 > 4 > greeting 5 > : string -1 >Emitted(7, 9) Source(2, 24) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(7, 22) Source(2, 32) + SourceIndex(0) name (Greeter.constructor) -3 >Emitted(7, 25) Source(2, 24) + SourceIndex(0) name (Greeter.constructor) -4 >Emitted(7, 33) Source(2, 32) + SourceIndex(0) name (Greeter.constructor) -5 >Emitted(7, 34) Source(2, 40) + SourceIndex(0) name (Greeter.constructor) +1->Emitted(3, 9) Source(2, 24) + SourceIndex(0) name (Greeter.constructor) +2 >Emitted(3, 22) Source(2, 32) + SourceIndex(0) name (Greeter.constructor) +3 >Emitted(3, 25) Source(2, 24) + SourceIndex(0) name (Greeter.constructor) +4 >Emitted(3, 33) Source(2, 32) + SourceIndex(0) name (Greeter.constructor) +5 >Emitted(3, 34) Source(2, 40) + SourceIndex(0) name (Greeter.constructor) --- >>> this.x1 = 10; 1 >^^^^^^^^ @@ -111,11 +74,11 @@ sourceFile:sourceMapValidationClass.ts 3 > : number = 4 > 10 5 > ; -1 >Emitted(8, 9) Source(8, 13) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(8, 16) Source(8, 15) + SourceIndex(0) name (Greeter.constructor) -3 >Emitted(8, 19) Source(8, 26) + SourceIndex(0) name (Greeter.constructor) -4 >Emitted(8, 21) Source(8, 28) + SourceIndex(0) name (Greeter.constructor) -5 >Emitted(8, 22) Source(8, 29) + SourceIndex(0) name (Greeter.constructor) +1 >Emitted(4, 9) Source(8, 13) + SourceIndex(0) name (Greeter.constructor) +2 >Emitted(4, 16) Source(8, 15) + SourceIndex(0) name (Greeter.constructor) +3 >Emitted(4, 19) Source(8, 26) + SourceIndex(0) name (Greeter.constructor) +4 >Emitted(4, 21) Source(8, 28) + SourceIndex(0) name (Greeter.constructor) +5 >Emitted(4, 22) Source(8, 29) + SourceIndex(0) name (Greeter.constructor) --- >>> } 1 >^^^^ @@ -123,8 +86,8 @@ sourceFile:sourceMapValidationClass.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > 2 > } -1 >Emitted(9, 5) Source(3, 5) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(9, 6) Source(3, 6) + SourceIndex(0) name (Greeter.constructor) +1 >Emitted(5, 5) Source(3, 5) + SourceIndex(0) name (Greeter.constructor) +2 >Emitted(5, 6) Source(3, 6) + SourceIndex(0) name (Greeter.constructor) --- >>> Greeter.prototype.greet = function () { 1->^^^^ @@ -135,9 +98,9 @@ sourceFile:sourceMapValidationClass.ts > 2 > greet 3 > -1->Emitted(10, 5) Source(4, 5) + SourceIndex(0) name (Greeter) -2 >Emitted(10, 28) Source(4, 10) + SourceIndex(0) name (Greeter) -3 >Emitted(10, 31) Source(4, 5) + SourceIndex(0) name (Greeter) +1->Emitted(6, 5) Source(4, 5) + SourceIndex(0) name (Greeter) +2 >Emitted(6, 28) Source(4, 10) + SourceIndex(0) name (Greeter) +3 >Emitted(6, 31) Source(4, 5) + SourceIndex(0) name (Greeter) --- >>> return "

" + this.greeting + "

"; 1->^^^^^^^^ @@ -163,17 +126,17 @@ sourceFile:sourceMapValidationClass.ts 9 > + 10> "" 11> ; -1->Emitted(11, 9) Source(5, 9) + SourceIndex(0) name (Greeter.greet) -2 >Emitted(11, 15) Source(5, 15) + SourceIndex(0) name (Greeter.greet) -3 >Emitted(11, 16) Source(5, 16) + SourceIndex(0) name (Greeter.greet) -4 >Emitted(11, 22) Source(5, 22) + SourceIndex(0) name (Greeter.greet) -5 >Emitted(11, 25) Source(5, 25) + SourceIndex(0) name (Greeter.greet) -6 >Emitted(11, 29) Source(5, 29) + SourceIndex(0) name (Greeter.greet) -7 >Emitted(11, 30) Source(5, 30) + SourceIndex(0) name (Greeter.greet) -8 >Emitted(11, 38) Source(5, 38) + SourceIndex(0) name (Greeter.greet) -9 >Emitted(11, 41) Source(5, 41) + SourceIndex(0) name (Greeter.greet) -10>Emitted(11, 48) Source(5, 48) + SourceIndex(0) name (Greeter.greet) -11>Emitted(11, 49) Source(5, 49) + SourceIndex(0) name (Greeter.greet) +1->Emitted(7, 9) Source(5, 9) + SourceIndex(0) name (Greeter.greet) +2 >Emitted(7, 15) Source(5, 15) + SourceIndex(0) name (Greeter.greet) +3 >Emitted(7, 16) Source(5, 16) + SourceIndex(0) name (Greeter.greet) +4 >Emitted(7, 22) Source(5, 22) + SourceIndex(0) name (Greeter.greet) +5 >Emitted(7, 25) Source(5, 25) + SourceIndex(0) name (Greeter.greet) +6 >Emitted(7, 29) Source(5, 29) + SourceIndex(0) name (Greeter.greet) +7 >Emitted(7, 30) Source(5, 30) + SourceIndex(0) name (Greeter.greet) +8 >Emitted(7, 38) Source(5, 38) + SourceIndex(0) name (Greeter.greet) +9 >Emitted(7, 41) Source(5, 41) + SourceIndex(0) name (Greeter.greet) +10>Emitted(7, 48) Source(5, 48) + SourceIndex(0) name (Greeter.greet) +11>Emitted(7, 49) Source(5, 49) + SourceIndex(0) name (Greeter.greet) --- >>> }; 1 >^^^^ @@ -182,8 +145,8 @@ sourceFile:sourceMapValidationClass.ts 1 > > 2 > } -1 >Emitted(12, 5) Source(6, 5) + SourceIndex(0) name (Greeter.greet) -2 >Emitted(12, 6) Source(6, 6) + SourceIndex(0) name (Greeter.greet) +1 >Emitted(8, 5) Source(6, 5) + SourceIndex(0) name (Greeter.greet) +2 >Emitted(8, 6) Source(6, 6) + SourceIndex(0) name (Greeter.greet) --- >>> Greeter.prototype.fn = function () { 1->^^^^ @@ -196,9 +159,9 @@ sourceFile:sourceMapValidationClass.ts > private 2 > fn 3 > -1->Emitted(13, 5) Source(9, 13) + SourceIndex(0) name (Greeter) -2 >Emitted(13, 25) Source(9, 15) + SourceIndex(0) name (Greeter) -3 >Emitted(13, 28) Source(9, 5) + SourceIndex(0) name (Greeter) +1->Emitted(9, 5) Source(9, 13) + SourceIndex(0) name (Greeter) +2 >Emitted(9, 25) Source(9, 15) + SourceIndex(0) name (Greeter) +3 >Emitted(9, 28) Source(9, 5) + SourceIndex(0) name (Greeter) --- >>> return this.greeting; 1->^^^^^^^^ @@ -216,13 +179,13 @@ sourceFile:sourceMapValidationClass.ts 5 > . 6 > greeting 7 > ; -1->Emitted(14, 9) Source(10, 9) + SourceIndex(0) name (Greeter.fn) -2 >Emitted(14, 15) Source(10, 15) + SourceIndex(0) name (Greeter.fn) -3 >Emitted(14, 16) Source(10, 16) + SourceIndex(0) name (Greeter.fn) -4 >Emitted(14, 20) Source(10, 20) + SourceIndex(0) name (Greeter.fn) -5 >Emitted(14, 21) Source(10, 21) + SourceIndex(0) name (Greeter.fn) -6 >Emitted(14, 29) Source(10, 29) + SourceIndex(0) name (Greeter.fn) -7 >Emitted(14, 30) Source(10, 30) + SourceIndex(0) name (Greeter.fn) +1->Emitted(10, 9) Source(10, 9) + SourceIndex(0) name (Greeter.fn) +2 >Emitted(10, 15) Source(10, 15) + SourceIndex(0) name (Greeter.fn) +3 >Emitted(10, 16) Source(10, 16) + SourceIndex(0) name (Greeter.fn) +4 >Emitted(10, 20) Source(10, 20) + SourceIndex(0) name (Greeter.fn) +5 >Emitted(10, 21) Source(10, 21) + SourceIndex(0) name (Greeter.fn) +6 >Emitted(10, 29) Source(10, 29) + SourceIndex(0) name (Greeter.fn) +7 >Emitted(10, 30) Source(10, 30) + SourceIndex(0) name (Greeter.fn) --- >>> }; 1 >^^^^ @@ -231,8 +194,8 @@ sourceFile:sourceMapValidationClass.ts 1 > > 2 > } -1 >Emitted(15, 5) Source(11, 5) + SourceIndex(0) name (Greeter.fn) -2 >Emitted(15, 6) Source(11, 6) + SourceIndex(0) name (Greeter.fn) +1 >Emitted(11, 5) Source(11, 5) + SourceIndex(0) name (Greeter.fn) +2 >Emitted(11, 6) Source(11, 6) + SourceIndex(0) name (Greeter.fn) --- >>> Object.defineProperty(Greeter.prototype, "greetings", { 1->^^^^ @@ -242,15 +205,15 @@ sourceFile:sourceMapValidationClass.ts > 2 > get 3 > greetings -1->Emitted(16, 5) Source(12, 5) + SourceIndex(0) name (Greeter) -2 >Emitted(16, 27) Source(12, 9) + SourceIndex(0) name (Greeter) -3 >Emitted(16, 57) Source(12, 18) + SourceIndex(0) name (Greeter) +1->Emitted(12, 5) Source(12, 5) + SourceIndex(0) name (Greeter) +2 >Emitted(12, 27) Source(12, 9) + SourceIndex(0) name (Greeter) +3 >Emitted(12, 57) Source(12, 18) + SourceIndex(0) name (Greeter) --- >>> get: function () { 1 >^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(17, 14) Source(12, 5) + SourceIndex(0) name (Greeter) +1 >Emitted(13, 14) Source(12, 5) + SourceIndex(0) name (Greeter) --- >>> return this.greeting; 1->^^^^^^^^^^^^ @@ -268,13 +231,13 @@ sourceFile:sourceMapValidationClass.ts 5 > . 6 > greeting 7 > ; -1->Emitted(18, 13) Source(13, 9) + SourceIndex(0) name (Greeter.greetings) -2 >Emitted(18, 19) Source(13, 15) + SourceIndex(0) name (Greeter.greetings) -3 >Emitted(18, 20) Source(13, 16) + SourceIndex(0) name (Greeter.greetings) -4 >Emitted(18, 24) Source(13, 20) + SourceIndex(0) name (Greeter.greetings) -5 >Emitted(18, 25) Source(13, 21) + SourceIndex(0) name (Greeter.greetings) -6 >Emitted(18, 33) Source(13, 29) + SourceIndex(0) name (Greeter.greetings) -7 >Emitted(18, 34) Source(13, 30) + SourceIndex(0) name (Greeter.greetings) +1->Emitted(14, 13) Source(13, 9) + SourceIndex(0) name (Greeter.greetings) +2 >Emitted(14, 19) Source(13, 15) + SourceIndex(0) name (Greeter.greetings) +3 >Emitted(14, 20) Source(13, 16) + SourceIndex(0) name (Greeter.greetings) +4 >Emitted(14, 24) Source(13, 20) + SourceIndex(0) name (Greeter.greetings) +5 >Emitted(14, 25) Source(13, 21) + SourceIndex(0) name (Greeter.greetings) +6 >Emitted(14, 33) Source(13, 29) + SourceIndex(0) name (Greeter.greetings) +7 >Emitted(14, 34) Source(13, 30) + SourceIndex(0) name (Greeter.greetings) --- >>> }, 1 >^^^^^^^^ @@ -283,8 +246,8 @@ sourceFile:sourceMapValidationClass.ts 1 > > 2 > } -1 >Emitted(19, 9) Source(14, 5) + SourceIndex(0) name (Greeter.greetings) -2 >Emitted(19, 10) Source(14, 6) + SourceIndex(0) name (Greeter.greetings) +1 >Emitted(15, 9) Source(14, 5) + SourceIndex(0) name (Greeter.greetings) +2 >Emitted(15, 10) Source(14, 6) + SourceIndex(0) name (Greeter.greetings) --- >>> set: function (greetings) { 1->^^^^^^^^^^^^^ @@ -295,9 +258,9 @@ sourceFile:sourceMapValidationClass.ts > 2 > set greetings( 3 > greetings: string -1->Emitted(20, 14) Source(15, 5) + SourceIndex(0) name (Greeter) -2 >Emitted(20, 24) Source(15, 19) + SourceIndex(0) name (Greeter) -3 >Emitted(20, 33) Source(15, 36) + SourceIndex(0) name (Greeter) +1->Emitted(16, 14) Source(15, 5) + SourceIndex(0) name (Greeter) +2 >Emitted(16, 24) Source(15, 19) + SourceIndex(0) name (Greeter) +3 >Emitted(16, 33) Source(15, 36) + SourceIndex(0) name (Greeter) --- >>> this.greeting = greetings; 1->^^^^^^^^^^^^ @@ -315,13 +278,13 @@ sourceFile:sourceMapValidationClass.ts 5 > = 6 > greetings 7 > ; -1->Emitted(21, 13) Source(16, 9) + SourceIndex(0) name (Greeter.greetings) -2 >Emitted(21, 17) Source(16, 13) + SourceIndex(0) name (Greeter.greetings) -3 >Emitted(21, 18) Source(16, 14) + SourceIndex(0) name (Greeter.greetings) -4 >Emitted(21, 26) Source(16, 22) + SourceIndex(0) name (Greeter.greetings) -5 >Emitted(21, 29) Source(16, 25) + SourceIndex(0) name (Greeter.greetings) -6 >Emitted(21, 38) Source(16, 34) + SourceIndex(0) name (Greeter.greetings) -7 >Emitted(21, 39) Source(16, 35) + SourceIndex(0) name (Greeter.greetings) +1->Emitted(17, 13) Source(16, 9) + SourceIndex(0) name (Greeter.greetings) +2 >Emitted(17, 17) Source(16, 13) + SourceIndex(0) name (Greeter.greetings) +3 >Emitted(17, 18) Source(16, 14) + SourceIndex(0) name (Greeter.greetings) +4 >Emitted(17, 26) Source(16, 22) + SourceIndex(0) name (Greeter.greetings) +5 >Emitted(17, 29) Source(16, 25) + SourceIndex(0) name (Greeter.greetings) +6 >Emitted(17, 38) Source(16, 34) + SourceIndex(0) name (Greeter.greetings) +7 >Emitted(17, 39) Source(16, 35) + SourceIndex(0) name (Greeter.greetings) --- >>> }, 1 >^^^^^^^^ @@ -330,8 +293,8 @@ sourceFile:sourceMapValidationClass.ts 1 > > 2 > } -1 >Emitted(22, 9) Source(17, 5) + SourceIndex(0) name (Greeter.greetings) -2 >Emitted(22, 10) Source(17, 6) + SourceIndex(0) name (Greeter.greetings) +1 >Emitted(18, 9) Source(17, 5) + SourceIndex(0) name (Greeter.greetings) +2 >Emitted(18, 10) Source(17, 6) + SourceIndex(0) name (Greeter.greetings) --- >>> enumerable: true, >>> configurable: true @@ -339,7 +302,7 @@ sourceFile:sourceMapValidationClass.ts 1->^^^^^^^ 2 > ^^^^^^^^^^^^^-> 1-> -1->Emitted(25, 8) Source(14, 6) + SourceIndex(0) name (Greeter) +1->Emitted(21, 8) Source(14, 6) + SourceIndex(0) name (Greeter) --- >>> return Greeter; 1->^^^^ @@ -350,8 +313,8 @@ sourceFile:sourceMapValidationClass.ts > } > 2 > } -1->Emitted(26, 5) Source(18, 1) + SourceIndex(0) name (Greeter) -2 >Emitted(26, 19) Source(18, 2) + SourceIndex(0) name (Greeter) +1->Emitted(22, 5) Source(18, 1) + SourceIndex(0) name (Greeter) +2 >Emitted(22, 19) Source(18, 2) + SourceIndex(0) name (Greeter) --- >>>})(); 1 > @@ -380,9 +343,9 @@ sourceFile:sourceMapValidationClass.ts > this.greeting = greetings; > } > } -1 >Emitted(27, 1) Source(18, 1) + SourceIndex(0) name (Greeter) -2 >Emitted(27, 2) Source(18, 2) + SourceIndex(0) name (Greeter) -3 >Emitted(27, 2) Source(1, 1) + SourceIndex(0) -4 >Emitted(27, 6) Source(18, 2) + SourceIndex(0) +1 >Emitted(23, 1) Source(18, 1) + SourceIndex(0) name (Greeter) +2 >Emitted(23, 2) Source(18, 2) + SourceIndex(0) name (Greeter) +3 >Emitted(23, 2) Source(1, 1) + SourceIndex(0) +4 >Emitted(23, 6) Source(18, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationClass.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationFunctions.js b/tests/baselines/reference/sourceMapValidationFunctions.js index 58222aa48c782..f3aa03895cf65 100644 --- a/tests/baselines/reference/sourceMapValidationFunctions.js +++ b/tests/baselines/reference/sourceMapValidationFunctions.js @@ -21,19 +21,11 @@ function greet(greeting) { } function greet2(greeting, n, x) { if (n === void 0) { n = 10; } - var restParams = []; - for (var _i = 3; _i < arguments.length; _i++) { - restParams[_i - 3] = arguments[_i]; - } greetings++; return greetings; } function foo(greeting, n, x) { if (n === void 0) { n = 10; } - var restParams = []; - for (var _i = 3; _i < arguments.length; _i++) { - restParams[_i - 3] = arguments[_i]; - } return; } //# sourceMappingURL=sourceMapValidationFunctions.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationFunctions.js.map b/tests/baselines/reference/sourceMapValidationFunctions.js.map index c04ec524d2db5..813a5bbe363ed 100644 --- a/tests/baselines/reference/sourceMapValidationFunctions.js.map +++ b/tests/baselines/reference/sourceMapValidationFunctions.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationFunctions.js.map] -{"version":3,"file":"sourceMapValidationFunctions.js","sourceRoot":"","sources":["sourceMapValidationFunctions.ts"],"names":["greet","greet2","foo"],"mappings":"AAAA,IAAI,SAAS,GAAG,CAAC,CAAC;AAClB,SAAS,KAAK,CAAC,QAAgB;IAC3BA,SAASA,EAAEA,CAACA;IACZA,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA;AACD,SAAS,MAAM,CAAC,QAAgB,EAAE,CAAM,EAAE,CAAU;IAAlBC,iBAAMA,GAANA,MAAMA;IAAcA,oBAAuBA;SAAvBA,WAAuBA,CAAvBA,sBAAuBA,CAAvBA,IAAuBA;QAAvBA,mCAAuBA;;IACzEA,SAASA,EAAEA,CAACA;IACZA,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA;AACD,SAAS,GAAG,CAAC,QAAgB,EAAE,CAAM,EAAE,CAAU;IAAlBC,iBAAMA,GAANA,MAAMA;IAAcA,oBAAuBA;SAAvBA,WAAuBA,CAAvBA,sBAAuBA,CAAvBA,IAAuBA;QAAvBA,mCAAuBA;;IAEtEA,MAAMA,CAACA;AACXA,CAACA"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationFunctions.js","sourceRoot":"","sources":["sourceMapValidationFunctions.ts"],"names":["greet","greet2","foo"],"mappings":"AAAA,IAAI,SAAS,GAAG,CAAC,CAAC;AAClB,SAAS,KAAK,CAAC,QAAgB;IAC3BA,SAASA,EAAEA,CAACA;IACZA,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA;AACD,SAAS,MAAM,CAAC,QAAgB,EAAE,CAAM,EAAE,CAAU;IAAlBC,iBAAMA,GAANA,MAAMA;IACpCA,SAASA,EAAEA,CAACA;IACZA,MAAMA,CAACA,SAASA,CAACA;AACrBA,CAACA;AACD,SAAS,GAAG,CAAC,QAAgB,EAAE,CAAM,EAAE,CAAU;IAAlBC,iBAAMA,GAANA,MAAMA;IAEjCA,MAAMA,CAACA;AACXA,CAACA"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationFunctions.sourcemap.txt b/tests/baselines/reference/sourceMapValidationFunctions.sourcemap.txt index a9e43e404a747..12e2e378ef515 100644 --- a/tests/baselines/reference/sourceMapValidationFunctions.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationFunctions.sourcemap.txt @@ -136,59 +136,21 @@ sourceFile:sourceMapValidationFunctions.ts 3 >Emitted(7, 25) Source(6, 35) + SourceIndex(0) name (greet2) 4 >Emitted(7, 31) Source(6, 41) + SourceIndex(0) name (greet2) --- ->>> var restParams = []; -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >, x?: string, -2 > ...restParams: string[] -1 >Emitted(8, 5) Source(6, 55) + SourceIndex(0) name (greet2) -2 >Emitted(8, 25) Source(6, 78) + SourceIndex(0) name (greet2) ---- ->>> for (var _i = 3; _i < arguments.length; _i++) { -1->^^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^^^ -5 > ^ -6 > ^^^^ -1-> -2 > ...restParams: string[] -3 > -4 > ...restParams: string[] -5 > -6 > ...restParams: string[] -1->Emitted(9, 10) Source(6, 55) + SourceIndex(0) name (greet2) -2 >Emitted(9, 21) Source(6, 78) + SourceIndex(0) name (greet2) -3 >Emitted(9, 22) Source(6, 55) + SourceIndex(0) name (greet2) -4 >Emitted(9, 44) Source(6, 78) + SourceIndex(0) name (greet2) -5 >Emitted(9, 45) Source(6, 55) + SourceIndex(0) name (greet2) -6 >Emitted(9, 49) Source(6, 78) + SourceIndex(0) name (greet2) ---- ->>> restParams[_i - 3] = arguments[_i]; -1 >^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 > -2 > ...restParams: string[] -1 >Emitted(10, 9) Source(6, 55) + SourceIndex(0) name (greet2) -2 >Emitted(10, 44) Source(6, 78) + SourceIndex(0) name (greet2) ---- ->>> } >>> greetings++; 1 >^^^^ 2 > ^^^^^^^^^ 3 > ^^ 4 > ^ 5 > ^^^^^^-> -1 >): number { +1 >, x?: string, ...restParams: string[]): number { > 2 > greetings 3 > ++ 4 > ; -1 >Emitted(12, 5) Source(7, 5) + SourceIndex(0) name (greet2) -2 >Emitted(12, 14) Source(7, 14) + SourceIndex(0) name (greet2) -3 >Emitted(12, 16) Source(7, 16) + SourceIndex(0) name (greet2) -4 >Emitted(12, 17) Source(7, 17) + SourceIndex(0) name (greet2) +1 >Emitted(8, 5) Source(7, 5) + SourceIndex(0) name (greet2) +2 >Emitted(8, 14) Source(7, 14) + SourceIndex(0) name (greet2) +3 >Emitted(8, 16) Source(7, 16) + SourceIndex(0) name (greet2) +4 >Emitted(8, 17) Source(7, 17) + SourceIndex(0) name (greet2) --- >>> return greetings; 1->^^^^ @@ -202,11 +164,11 @@ sourceFile:sourceMapValidationFunctions.ts 3 > 4 > greetings 5 > ; -1->Emitted(13, 5) Source(8, 5) + SourceIndex(0) name (greet2) -2 >Emitted(13, 11) Source(8, 11) + SourceIndex(0) name (greet2) -3 >Emitted(13, 12) Source(8, 12) + SourceIndex(0) name (greet2) -4 >Emitted(13, 21) Source(8, 21) + SourceIndex(0) name (greet2) -5 >Emitted(13, 22) Source(8, 22) + SourceIndex(0) name (greet2) +1->Emitted(9, 5) Source(8, 5) + SourceIndex(0) name (greet2) +2 >Emitted(9, 11) Source(8, 11) + SourceIndex(0) name (greet2) +3 >Emitted(9, 12) Source(8, 12) + SourceIndex(0) name (greet2) +4 >Emitted(9, 21) Source(8, 21) + SourceIndex(0) name (greet2) +5 >Emitted(9, 22) Source(8, 22) + SourceIndex(0) name (greet2) --- >>>} 1 > @@ -215,8 +177,8 @@ sourceFile:sourceMapValidationFunctions.ts 1 > > 2 >} -1 >Emitted(14, 1) Source(9, 1) + SourceIndex(0) name (greet2) -2 >Emitted(14, 2) Source(9, 2) + SourceIndex(0) name (greet2) +1 >Emitted(10, 1) Source(9, 1) + SourceIndex(0) name (greet2) +2 >Emitted(10, 2) Source(9, 2) + SourceIndex(0) name (greet2) --- >>>function foo(greeting, n, x) { 1-> @@ -239,15 +201,15 @@ sourceFile:sourceMapValidationFunctions.ts 7 > n = 10 8 > , 9 > x?: string -1->Emitted(15, 1) Source(10, 1) + SourceIndex(0) -2 >Emitted(15, 10) Source(10, 10) + SourceIndex(0) -3 >Emitted(15, 13) Source(10, 13) + SourceIndex(0) -4 >Emitted(15, 14) Source(10, 14) + SourceIndex(0) -5 >Emitted(15, 22) Source(10, 30) + SourceIndex(0) -6 >Emitted(15, 24) Source(10, 32) + SourceIndex(0) -7 >Emitted(15, 25) Source(10, 38) + SourceIndex(0) -8 >Emitted(15, 27) Source(10, 40) + SourceIndex(0) -9 >Emitted(15, 28) Source(10, 50) + SourceIndex(0) +1->Emitted(11, 1) Source(10, 1) + SourceIndex(0) +2 >Emitted(11, 10) Source(10, 10) + SourceIndex(0) +3 >Emitted(11, 13) Source(10, 13) + SourceIndex(0) +4 >Emitted(11, 14) Source(10, 14) + SourceIndex(0) +5 >Emitted(11, 22) Source(10, 30) + SourceIndex(0) +6 >Emitted(11, 24) Source(10, 32) + SourceIndex(0) +7 >Emitted(11, 25) Source(10, 38) + SourceIndex(0) +8 >Emitted(11, 27) Source(10, 40) + SourceIndex(0) +9 >Emitted(11, 28) Source(10, 50) + SourceIndex(0) --- >>> if (n === void 0) { n = 10; } 1->^^^^ @@ -258,61 +220,23 @@ sourceFile:sourceMapValidationFunctions.ts 2 > n = 10 3 > 4 > n = 10 -1->Emitted(16, 5) Source(10, 32) + SourceIndex(0) name (foo) -2 >Emitted(16, 22) Source(10, 38) + SourceIndex(0) name (foo) -3 >Emitted(16, 25) Source(10, 32) + SourceIndex(0) name (foo) -4 >Emitted(16, 31) Source(10, 38) + SourceIndex(0) name (foo) ---- ->>> var restParams = []; -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >, x?: string, -2 > ...restParams: string[] -1 >Emitted(17, 5) Source(10, 52) + SourceIndex(0) name (foo) -2 >Emitted(17, 25) Source(10, 75) + SourceIndex(0) name (foo) ---- ->>> for (var _i = 3; _i < arguments.length; _i++) { -1->^^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^^^ -5 > ^ -6 > ^^^^ -1-> -2 > ...restParams: string[] -3 > -4 > ...restParams: string[] -5 > -6 > ...restParams: string[] -1->Emitted(18, 10) Source(10, 52) + SourceIndex(0) name (foo) -2 >Emitted(18, 21) Source(10, 75) + SourceIndex(0) name (foo) -3 >Emitted(18, 22) Source(10, 52) + SourceIndex(0) name (foo) -4 >Emitted(18, 44) Source(10, 75) + SourceIndex(0) name (foo) -5 >Emitted(18, 45) Source(10, 52) + SourceIndex(0) name (foo) -6 >Emitted(18, 49) Source(10, 75) + SourceIndex(0) name (foo) ---- ->>> restParams[_i - 3] = arguments[_i]; -1 >^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 > -2 > ...restParams: string[] -1 >Emitted(19, 9) Source(10, 52) + SourceIndex(0) name (foo) -2 >Emitted(19, 44) Source(10, 75) + SourceIndex(0) name (foo) +1->Emitted(12, 5) Source(10, 32) + SourceIndex(0) name (foo) +2 >Emitted(12, 22) Source(10, 38) + SourceIndex(0) name (foo) +3 >Emitted(12, 25) Source(10, 32) + SourceIndex(0) name (foo) +4 >Emitted(12, 31) Source(10, 38) + SourceIndex(0) name (foo) --- ->>> } >>> return; 1 >^^^^ 2 > ^^^^^^ 3 > ^ -1 >) +1 >, x?: string, ...restParams: string[]) >{ > 2 > return 3 > ; -1 >Emitted(21, 5) Source(12, 5) + SourceIndex(0) name (foo) -2 >Emitted(21, 11) Source(12, 11) + SourceIndex(0) name (foo) -3 >Emitted(21, 12) Source(12, 12) + SourceIndex(0) name (foo) +1 >Emitted(13, 5) Source(12, 5) + SourceIndex(0) name (foo) +2 >Emitted(13, 11) Source(12, 11) + SourceIndex(0) name (foo) +3 >Emitted(13, 12) Source(12, 12) + SourceIndex(0) name (foo) --- >>>} 1 > @@ -321,7 +245,7 @@ sourceFile:sourceMapValidationFunctions.ts 1 > > 2 >} -1 >Emitted(22, 1) Source(13, 1) + SourceIndex(0) name (foo) -2 >Emitted(22, 2) Source(13, 2) + SourceIndex(0) name (foo) +1 >Emitted(14, 1) Source(13, 1) + SourceIndex(0) name (foo) +2 >Emitted(14, 2) Source(13, 2) + SourceIndex(0) name (foo) --- >>>//# sourceMappingURL=sourceMapValidationFunctions.js.map \ No newline at end of file diff --git a/tests/baselines/reference/strictMode5.js b/tests/baselines/reference/strictMode5.js index c46de926dbb55..29fee3bf518c3 100644 --- a/tests/baselines/reference/strictMode5.js +++ b/tests/baselines/reference/strictMode5.js @@ -21,10 +21,6 @@ function bar(x: number = 10) { //// [strictMode5.js] function foo() { "use strict"; - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } } var A = (function () { function A() { diff --git a/tests/baselines/reference/stringLiteralTypeIsSubtypeOfString.js b/tests/baselines/reference/stringLiteralTypeIsSubtypeOfString.js index 37aa59bef433f..3f3fc84c53111 100644 --- a/tests/baselines/reference/stringLiteralTypeIsSubtypeOfString.js +++ b/tests/baselines/reference/stringLiteralTypeIsSubtypeOfString.js @@ -132,10 +132,6 @@ var C = (function () { return null; }; C.prototype.concat = function () { - var strings = []; - for (var _i = 0; _i < arguments.length; _i++) { - strings[_i - 0] = arguments[_i]; - } return null; }; C.prototype.indexOf = function (searchString, position) { diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.js b/tests/baselines/reference/subtypingWithCallSignatures2.js index a887c52d2a159..0f4be79a83493 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.js +++ b/tests/baselines/reference/subtypingWithCallSignatures2.js @@ -259,13 +259,7 @@ var r10arg1 = function () { } return x[0]; }; -var r10arg2 = function () { - var x = []; - for (var _i = 0; _i < arguments.length; _i++) { - x[_i - 0] = arguments[_i]; - } - return null; -}; +var r10arg2 = function () { return null; }; var r10 = foo10(r10arg1); // any var r10a = [r10arg1, r10arg2]; var r10b = [r10arg2, r10arg1]; diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.js b/tests/baselines/reference/subtypingWithCallSignatures3.js index fb7b0fef5510f..401b29b39c42b 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.js +++ b/tests/baselines/reference/subtypingWithCallSignatures3.js @@ -168,20 +168,8 @@ var Errors; var r3 = foo8(r3arg); // any var r3a = [r3arg2, r3arg]; var r3b = [r3arg, r3arg2]; - var r4arg = function () { - var x = []; - for (var _i = 0; _i < arguments.length; _i++) { - x[_i - 0] = arguments[_i]; - } - return null; - }; - var r4arg2 = function () { - var x = []; - for (var _i = 0; _i < arguments.length; _i++) { - x[_i - 0] = arguments[_i]; - } - return null; - }; + var r4arg = function () { return null; }; + var r4arg2 = function () { return null; }; var r4 = foo10(r4arg); // any var r4a = [r4arg2, r4arg]; var r4b = [r4arg, r4arg2]; diff --git a/tests/baselines/reference/undeclaredModuleError.js b/tests/baselines/reference/undeclaredModuleError.js index e7e9b70ee7b75..987e7e35f889b 100644 --- a/tests/baselines/reference/undeclaredModuleError.js +++ b/tests/baselines/reference/undeclaredModuleError.js @@ -20,10 +20,6 @@ define(["require", "exports", 'fs'], function (require, exports, fs) { function readdir(path, accept, callback) { } function join() { - var paths = []; - for (var _i = 0; _i < arguments.length; _i++) { - paths[_i - 0] = arguments[_i]; - } } function instrumentFile(covFileDir, covFileName, originalFilePath) { fs.readFile(originalFilePath, function () { diff --git a/tests/baselines/reference/underscoreTest1.js b/tests/baselines/reference/underscoreTest1.js index 290e7aa6c888b..7f4af2929c069 100644 --- a/tests/baselines/reference/underscoreTest1.js +++ b/tests/baselines/reference/underscoreTest1.js @@ -984,10 +984,6 @@ var fibonacci = _.memoize(function (n) { return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); }); var log = _.bind(function (message) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } }, Date); _.delay(log, 1000, 'logged later'); _.defer(function () { diff --git a/tests/baselines/reference/varArgParamTypeCheck.js b/tests/baselines/reference/varArgParamTypeCheck.js index c2a33416436a0..5d8a60a564a4b 100644 --- a/tests/baselines/reference/varArgParamTypeCheck.js +++ b/tests/baselines/reference/varArgParamTypeCheck.js @@ -23,10 +23,6 @@ sequence( //// [varArgParamTypeCheck.js] function sequence() { - var sequences = []; - for (var _i = 0; _i < arguments.length; _i++) { - sequences[_i - 0] = arguments[_i]; - } } function callback(clb) { } diff --git a/tests/baselines/reference/vararg.js b/tests/baselines/reference/vararg.js index 038afb90cbc50..c0260cd8d862a 100644 --- a/tests/baselines/reference/vararg.js +++ b/tests/baselines/reference/vararg.js @@ -57,10 +57,6 @@ var M; return result; }; C.prototype.fnope = function (x) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } }; C.prototype.fonly = function () { var rest = []; diff --git a/tests/cases/compiler/restParameterEmit.ts b/tests/cases/compiler/restParameterEmit.ts index f728ffca44ff0..49757b1d6d2c9 100644 --- a/tests/cases/compiler/restParameterEmit.ts +++ b/tests/cases/compiler/restParameterEmit.ts @@ -7,7 +7,7 @@ function shouldEmit2(x, y, z, ...rest) { } function shouldEmit3(a: string, b: number, ...rest: any[]) { - console.log(g()); + g(); return; function g(): any { @@ -30,7 +30,7 @@ function shouldNotEmit(x, y, z, ...rest) { var shouldNotEmit2 = (a, b, ...c) => a.concat([1,2,3]); function shouldNotEmit3(a: string, b: number, ...rest: any[]) { - console.log(g()); + g(); return; function g(): any { From eac85e122b6a01706fa2e09c22b38c06130c5376 Mon Sep 17 00:00:00 2001 From: Duncan Mak Date: Tue, 2 Sep 2014 02:52:27 -0400 Subject: [PATCH 12/12] Update baselines again --- .../reference/restParameterEmit.errors.txt | 53 ------- .../baselines/reference/restParameterEmit.js | 8 +- .../reference/restParameterEmit.types | 139 ++++++++++++++++++ 3 files changed, 143 insertions(+), 57 deletions(-) delete mode 100644 tests/baselines/reference/restParameterEmit.errors.txt create mode 100644 tests/baselines/reference/restParameterEmit.types diff --git a/tests/baselines/reference/restParameterEmit.errors.txt b/tests/baselines/reference/restParameterEmit.errors.txt deleted file mode 100644 index d099b80e488df..0000000000000 --- a/tests/baselines/reference/restParameterEmit.errors.txt +++ /dev/null @@ -1,53 +0,0 @@ -==== tests/cases/compiler/restParameterEmit.ts (2 errors) ==== - function shouldEmit(x, y, z, ...rest) { - return rest; - } - - function shouldEmit2(x, y, z, ...rest) { - var a = rest.concat([x, y, z]); - } - - function shouldEmit3(a: string, b: number, ...rest: any[]) { - console.log(g()); - ~~~~~~~ -!!! Cannot find name 'console'. - return; - - function g(): any { - return rest[0]; - } - } - - function shouldEmit4(a: number, ...rest: number[]) { - function g(x: number = rest[0]): number { - return a || x; - } - - return g(); - } - - function shouldNotEmit(x, y, z, ...rest) { - return; - } - - var shouldNotEmit2 = (a, b, ...c) => a.concat([1,2,3]); - - function shouldNotEmit3(a: string, b: number, ...rest: any[]) { - console.log(g()); - ~~~~~~~ -!!! Cannot find name 'console'. - return; - - function g(): any { - return a; - } - } - - function shouldNotEmit4(a: number, b: number[], ...rest: number[]) { - function g(x: number = b[0]): number { - return a || x; - } - - return g(); - } - \ No newline at end of file diff --git a/tests/baselines/reference/restParameterEmit.js b/tests/baselines/reference/restParameterEmit.js index 6e3f49f490d78..8fe758cebe3c5 100644 --- a/tests/baselines/reference/restParameterEmit.js +++ b/tests/baselines/reference/restParameterEmit.js @@ -8,7 +8,7 @@ function shouldEmit2(x, y, z, ...rest) { } function shouldEmit3(a: string, b: number, ...rest: any[]) { - console.log(g()); + g(); return; function g(): any { @@ -31,7 +31,7 @@ function shouldNotEmit(x, y, z, ...rest) { var shouldNotEmit2 = (a, b, ...c) => a.concat([1,2,3]); function shouldNotEmit3(a: string, b: number, ...rest: any[]) { - console.log(g()); + g(); return; function g(): any { @@ -68,7 +68,7 @@ function shouldEmit3(a, b) { for (var _i = 2; _i < arguments.length; _i++) { rest[_i - 2] = arguments[_i]; } - console.log(g()); + g(); return; function g() { return rest[0]; @@ -90,7 +90,7 @@ function shouldNotEmit(x, y, z) { } var shouldNotEmit2 = function (a, b) { return a.concat([1, 2, 3]); }; function shouldNotEmit3(a, b) { - console.log(g()); + g(); return; function g() { return a; diff --git a/tests/baselines/reference/restParameterEmit.types b/tests/baselines/reference/restParameterEmit.types new file mode 100644 index 0000000000000..b56b3d246e4f2 --- /dev/null +++ b/tests/baselines/reference/restParameterEmit.types @@ -0,0 +1,139 @@ +=== tests/cases/compiler/restParameterEmit.ts === +function shouldEmit(x, y, z, ...rest) { +>shouldEmit : (x: any, y: any, z: any, ...rest: any[]) => any[] +>x : any +>y : any +>z : any +>rest : any[] + + return rest; +>rest : any[] +} + +function shouldEmit2(x, y, z, ...rest) { +>shouldEmit2 : (x: any, y: any, z: any, ...rest: any[]) => void +>x : any +>y : any +>z : any +>rest : any[] + + var a = rest.concat([x, y, z]); +>a : any[] +>rest.concat([x, y, z]) : any[] +>rest.concat : { (...items: U[]): any[]; (...items: any[]): any[]; } +>rest : any[] +>concat : { (...items: U[]): any[]; (...items: any[]): any[]; } +>[x, y, z] : any[] +>x : any +>y : any +>z : any +} + +function shouldEmit3(a: string, b: number, ...rest: any[]) { +>shouldEmit3 : (a: string, b: number, ...rest: any[]) => void +>a : string +>b : number +>rest : any[] + + g(); +>g() : any +>g : () => any + + return; + + function g(): any { +>g : () => any + + return rest[0]; +>rest[0] : any +>rest : any[] + } +} + +function shouldEmit4(a: number, ...rest: number[]) { +>shouldEmit4 : (a: number, ...rest: number[]) => number +>a : number +>rest : number[] + + function g(x: number = rest[0]): number { +>g : (x?: number) => number +>x : number +>rest[0] : number +>rest : number[] + + return a || x; +>a || x : number +>a : number +>x : number + } + + return g(); +>g() : number +>g : (x?: number) => number +} + +function shouldNotEmit(x, y, z, ...rest) { +>shouldNotEmit : (x: any, y: any, z: any, ...rest: any[]) => void +>x : any +>y : any +>z : any +>rest : any[] + + return; +} + +var shouldNotEmit2 = (a, b, ...c) => a.concat([1,2,3]); +>shouldNotEmit2 : (a: any, b: any, ...c: any[]) => any +>(a, b, ...c) => a.concat([1,2,3]) : (a: any, b: any, ...c: any[]) => any +>a : any +>b : any +>c : any[] +>a.concat([1,2,3]) : any +>a.concat : any +>a : any +>concat : any +>[1,2,3] : number[] + +function shouldNotEmit3(a: string, b: number, ...rest: any[]) { +>shouldNotEmit3 : (a: string, b: number, ...rest: any[]) => void +>a : string +>b : number +>rest : any[] + + g(); +>g() : any +>g : () => any + + return; + + function g(): any { +>g : () => any + + return a; +>a : string + } +} + +function shouldNotEmit4(a: number, b: number[], ...rest: number[]) { +>shouldNotEmit4 : (a: number, b: number[], ...rest: number[]) => number +>a : number +>b : number[] +>rest : number[] + + function g(x: number = b[0]): number { +>g : (x?: number) => number +>x : number +>b[0] : number +>b : number[] + + return a || x; +>a || x : number +>a : number +>x : number + } + + return g(); +>g() : number +>g : (x?: number) => number +} +