diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 9e36fc3e662ae..f5b23ffb59b84 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -67,7 +67,8 @@ module ts { if (!file.locals) { file.locals = {}; - container = blockScopeContainer = file; + container = file; + setBlockScopeContainer(file, /*cleanLocals*/ false); bind(file); file.symbolCount = symbolCount; } @@ -77,6 +78,13 @@ module ts { return new Symbol(flags, name); } + function setBlockScopeContainer(node: Node, cleanLocals: boolean) { + blockScopeContainer = node; + if (cleanLocals) { + blockScopeContainer.locals = undefined; + } + } + function addDeclarationToSymbol(symbol: Symbol, node: Declaration, symbolKind: SymbolFlags) { symbol.flags |= symbolKind; if (!symbol.declarations) symbol.declarations = []; @@ -236,7 +244,13 @@ module ts { } if (isBlockScopeContainer) { - blockScopeContainer = node; + // in incremental scenarios we might reuse nodes that already have locals being allocated + // during the bind step these locals should be dropped to prevent using stale data. + // locals should always be dropped unless they were previously initialized by the binder + // these cases are: + // - node has locals (symbolKind & HasLocals) !== 0 + // - node is a source file + setBlockScopeContainer(node, /*cleanLocals*/ (symbolKind & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile); } forEachChild(node, bind); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 918090b3a9411..2776c6595a856 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5075,10 +5075,63 @@ module ts { checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkBlockScopedBindingCapturedInLoop(node, symbol); return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); } + function isInsideFunction(node: Node, threshold: Node): boolean { + var current = node; + while (current && current !== threshold) { + if (isAnyFunction(current)) { + return true; + } + current = current.parent; + } + + return false; + } + + function checkBlockScopedBindingCapturedInLoop(node: Identifier, symbol: Symbol): void { + if (languageVersion >= ScriptTarget.ES6 || + (symbol.flags & SymbolFlags.BlockScopedVariable) === 0 || + symbol.valueDeclaration.parent.kind === SyntaxKind.CatchClause) { + return; + } + + // - check if binding is used in some function + // (stop the walk when reaching container of binding declaration) + // - if first check succeeded - check if variable is declared inside the loop + + // nesting structure: + // (variable declaration or binding element) -> variable declaration list -> container + var container: Node = symbol.valueDeclaration; + while (container.kind !== SyntaxKind.VariableDeclarationList) { + container = container.parent; + } + // get the parent of variable declaration list + container = container.parent; + if (container.kind === SyntaxKind.VariableStatement) { + // if parent is variable statement - get its parent + container = container.parent; + } + + var inFunction = isInsideFunction(node.parent, container); + + var current = container; + while (current && !nodeStartsNewLexicalEnvironment(current)) { + if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { + if (inFunction) { + grammarErrorOnFirstToken(current, Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, declarationNameToString(node)); + } + // mark value declaration so during emit they can have a special handling + getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.BlockScopedBindingInLoop; + break; + } + current = current.parent; + } + } + function captureLexicalThis(node: Node, container: Node): void { var classNode = container.parent && container.parent.kind === SyntaxKind.ClassDeclaration ? container.parent : undefined; getNodeLinks(node).flags |= NodeCheckFlags.LexicalThis; @@ -10467,25 +10520,8 @@ module ts { } function makeUniqueName(baseName: string): string { - // First try '_name' - if (baseName.charCodeAt(0) !== CharacterCodes._) { - var baseName = "_" + baseName; - if (!isExistingName(baseName)) { - return generatedNames[baseName] = baseName; - } - } - // Find the first unique '_name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== CharacterCodes._) { - baseName += "_"; - } - var i = 1; - while (true) { - name = baseName + i; - if (!isExistingName(name)) { - return generatedNames[name] = name; - } - i++; - } + var name = generateUniqueName(baseName, isExistingName); + return generatedNames[name] = name; } function assignGeneratedName(node: Node, name: string) { @@ -10686,6 +10722,46 @@ module ts { !hasProperty(getGeneratedNamesForSourceFile(getSourceFile(location)), name); } + function getBlockScopedVariableId(n: Identifier): number { + Debug.assert(!nodeIsSynthesized(n)); + + // ignore name parts of property access expressions + if (n.parent.kind === SyntaxKind.PropertyAccessExpression && + (n.parent).name === n) { + return undefined; + } + + // ignore property names in object binding patterns + if (n.parent.kind === SyntaxKind.BindingElement && + (n.parent).propertyName === n) { + return undefined; + } + + // for names in variable declarations and binding elements try to short circuit and fetch symbol from the node + var declarationSymbol: Symbol = + (n.parent.kind === SyntaxKind.VariableDeclaration && (n.parent).name === n) || + n.parent.kind === SyntaxKind.BindingElement + ? getSymbolOfNode(n.parent) + : undefined; + + var symbol = declarationSymbol || + getNodeLinks(n).resolvedSymbol || + resolveName(n, n.text, SymbolFlags.BlockScopedVariable | SymbolFlags.Import, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); + + var isLetOrConst = + symbol && + (symbol.flags & SymbolFlags.BlockScopedVariable) && + symbol.valueDeclaration.parent.kind !== SyntaxKind.CatchClause; + + if (isLetOrConst) { + // side-effect of calling this method: + // assign id to symbol if it was not yet set + getSymbolLinks(symbol); + return symbol.id; + } + return undefined; + } + function createResolver(): EmitResolver { return { getGeneratedNameForNode, @@ -10702,6 +10778,7 @@ module ts { isEntityNameVisible, getConstantValue, isUnknownIdentifier, + getBlockScopedVariableId, }; } @@ -11443,7 +11520,8 @@ module ts { if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) { return grammarErrorOnNode(node, Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (isConst(node)) { + // const declarations should not be initialized in for-in for-of statements + if (isConst(node) && node.parent.parent.kind !== SyntaxKind.ForInStatement && node.parent.parent.kind !== SyntaxKind.ForOfStatement) { return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized); } } @@ -11485,15 +11563,6 @@ module ts { if (!declarationList.declarations.length) { return grammarErrorAtPos(getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty); } - - if (languageVersion < ScriptTarget.ES6) { - if (isLet(declarationList)) { - return grammarErrorOnFirstToken(declarationList, Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - else if (isConst(declarationList)) { - return grammarErrorOnFirstToken(declarationList, Diagnostics.const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - } } function allowLetAndConstDeclarations(parent: Node): boolean { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 88ae6eda36160..0e8d1bdd25fa2 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -397,6 +397,7 @@ module ts { Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." }, + Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: DiagnosticCategory.Error, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e78ae2dad27e8..cca74aac7ce68 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1581,6 +1581,10 @@ "category": "Error", "code": 4081 }, + "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher.": { + "category": "Error", + "code": 4091 + }, "The current host does not support the '{0}' option.": { "category": "Error", "code": 5001 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index bc1bf0d260747..c4f7c79939f5c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -28,9 +28,10 @@ module ts { typeName?: DeclarationName; } - interface SynthesizedNode extends Node { - leadingCommentRanges?: CommentRange[]; - trailingCommentRanges?: CommentRange[]; + // represents one LexicalEnvironment frame to store unique generated names + interface ScopeFrame { + names: Map; + previous: ScopeFrame; } type GetSymbolAccessibilityDiagnostic = (symbolAccesibilityResult: SymbolAccessiblityResult) => SymbolAccessibilityDiagnostic; @@ -369,7 +370,6 @@ module ts { var enclosingDeclaration: Node; var currentSourceFile: SourceFile; var reportedDeclarationError = false; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; @@ -1523,10 +1523,6 @@ module ts { return diagnostics; } - interface SynthesizedNode extends Node { - startsOnNewLine: boolean; - } - // @internal // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile): EmitResult { @@ -1578,6 +1574,11 @@ module ts { var currentSourceFile: SourceFile; + var lastFrame: ScopeFrame; + var currentScopeNames: Map; + + var generatedBlockScopeNames: string[]; + var extendsEmitted = false; var tempCount = 0; var tempVariables: Identifier[]; @@ -1652,6 +1653,50 @@ module ts { writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); return; + // enters the new lexical environment + // return value should be passed to matching call to exitNameScope. + function enterNameScope(): boolean { + var names = currentScopeNames; + currentScopeNames = undefined; + if (names) { + lastFrame = { names, previous: lastFrame }; + return true; + } + return false; + } + + function exitNameScope(popFrame: boolean): void { + if (popFrame) { + currentScopeNames = lastFrame.names; + lastFrame = lastFrame.previous; + } + else { + currentScopeNames = undefined; + } + } + + function generateUniqueNameForLocation(location: Node, baseName: string): string { + var name: string + // first try to check if base name can be used as is + if (!isExistingName(location, baseName)) { + name = baseName; + } + else { + name = generateUniqueName(baseName, n => isExistingName(location, n)); + } + + if (!currentScopeNames) { + currentScopeNames = {}; + } + + return currentScopeNames[name] = name; + } + + function isExistingName(location: Node, name: string) { + return !resolver.isUnknownIdentifier(location, name) || + (currentScopeNames && hasProperty(currentScopeNames, name)); + } + function initializeEmitterWithSourceMaps() { var sourceMapDir: string; // The directory in which sourcemap will be @@ -2018,14 +2063,14 @@ module ts { function createTempVariable(location: Node, forLoopVariable?: boolean): Identifier { var name = forLoopVariable ? "_i" : undefined; while (true) { - if (name && resolver.isUnknownIdentifier(location, name)) { + if (name && !isExistingName(location, name)) { break; } // _a .. _h, _j ... _z, _0, _1, ... name = "_" + (tempCount < 25 ? String.fromCharCode(tempCount + (tempCount < 8 ? 0 : 1) + CharacterCodes.a) : tempCount - 25); tempCount++; } - var result = createNode(SyntaxKind.Identifier); + var result = createSynthesizedNode(SyntaxKind.Identifier); result.text = name; return result; } @@ -2478,7 +2523,20 @@ module ts { } } + function getBlockScopedVariableId(node: Identifier): number { + // return undefined for synthesized nodes + return !nodeIsSynthesized(node) && resolver.getBlockScopedVariableId(node); + } + function emitIdentifier(node: Identifier) { + var variableId = getBlockScopedVariableId(node); + if (variableId !== undefined && generatedBlockScopeNames) { + var text = generatedBlockScopeNames[variableId]; + if (text) { + write(text); + return; + } + } if (!node.parent) { write(node.text); } @@ -2624,19 +2682,6 @@ module ts { } } - function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node { - var node = createNode(kind); - node.pos = -1; - node.end = -1; - node.startsOnNewLine = startsOnNewLine; - - return node; - } - - function isSynthesized(node: Node) { - return node.pos === -1 && node.end === -1; - } - function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number): void { var parenthesizedObjectLiteral = createDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex); return emit(parenthesizedObjectLiteral); @@ -3167,7 +3212,7 @@ module ts { write(tokenToString(node.operatorToken.kind)); - var shouldPlaceOnNewLine = !isSynthesized(node) && !nodeEndIsOnSameLineAsNodeStart(node.operatorToken, node.right); + var shouldPlaceOnNewLine = !nodeIsSynthesized(node) && !nodeEndIsOnSameLineAsNodeStart(node.operatorToken, node.right); // Check if the right expression is on a different line versus the operator itself. If so, // we'll emit newline. @@ -3185,7 +3230,7 @@ module ts { } function synthesizedNodeStartsOnNewLine(node: Node) { - return isSynthesized(node) && (node).startsOnNewLine; + return nodeIsSynthesized(node) && (node).startsOnNewLine; } function emitConditionalExpression(node: ConditionalExpression) { @@ -3287,6 +3332,32 @@ module ts { emitEmbeddedStatement(node.statement); } + function emitStartOfVariableDeclarationList(decl: Node, startPos?: number): void { + var tokenKind = SyntaxKind.VarKeyword; + if (decl && languageVersion >= ScriptTarget.ES6) { + if (isLet(decl)) { + tokenKind = SyntaxKind.LetKeyword; + } + else if (isConst(decl)) { + tokenKind = SyntaxKind.ConstKeyword; + } + } + + if (startPos !== undefined) { + emitToken(tokenKind, startPos); + } + else { + switch (tokenKind) { + case SyntaxKind.VarKeyword: + return write("var "); + case SyntaxKind.LetKeyword: + return write("let "); + case SyntaxKind.ConstKeyword: + return write("const "); + } + } + } + function emitForStatement(node: ForStatement) { var endPos = emitToken(SyntaxKind.ForKeyword, node.pos); write(" "); @@ -3294,17 +3365,9 @@ module ts { if (node.initializer && node.initializer.kind === SyntaxKind.VariableDeclarationList) { var variableDeclarationList = node.initializer; var declarations = variableDeclarationList.declarations; - if (declarations[0] && isLet(declarations[0])) { - emitToken(SyntaxKind.LetKeyword, endPos); - } - else if (declarations[0] && isConst(declarations[0])) { - emitToken(SyntaxKind.ConstKeyword, endPos); - } - else { - emitToken(SyntaxKind.VarKeyword, endPos); - } + emitStartOfVariableDeclarationList(declarations[0], endPos); write(" "); - emitCommaList(variableDeclarationList.declarations); + emitCommaList(declarations); } else if (node.initializer) { emit(node.initializer); @@ -3325,12 +3388,7 @@ module ts { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { var decl = variableDeclarationList.declarations[0]; - if (isLet(decl)) { - emitToken(SyntaxKind.LetKeyword, endPos); - } - else { - emitToken(SyntaxKind.VarKeyword, endPos); - } + emitStartOfVariableDeclarationList(decl, endPos); write(" "); emit(decl); } @@ -3479,6 +3537,14 @@ module ts { emitNode(node.name); emitEnd(node.name); } + + function createVoidZero(): Expression { + var zero = createSynthesizedNode(SyntaxKind.NumericLiteral); + zero.text = "0"; + var result = createSynthesizedNode(SyntaxKind.VoidExpression); + result.expression = zero; + return result; + } function emitExportMemberAssignments(name: Identifier) { if (exportSpecifiers && hasProperty(exportSpecifiers, name.text)) { @@ -3512,6 +3578,8 @@ module ts { if (emitCount++) { write(", "); } + + renameNonTopLevelLetAndConst(name); if (name.parent && (name.parent.kind === SyntaxKind.VariableDeclaration || name.parent.kind === SyntaxKind.BindingElement)) { emitModuleMemberName(name.parent); } @@ -3534,24 +3602,16 @@ module ts { return expr; } - function createVoidZero(): Expression { - var zero = createNode(SyntaxKind.NumericLiteral); - zero.text = "0"; - var result = createNode(SyntaxKind.VoidExpression); - result.expression = zero; - return result; - } - function createDefaultValueCheck(value: Expression, defaultValue: Expression): Expression { // The value expression will be evaluated twice, so for anything but a simple identifier // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = createNode(SyntaxKind.BinaryExpression); + var equals = createSynthesizedNode(SyntaxKind.BinaryExpression); equals.left = value; - equals.operatorToken = createNode(SyntaxKind.EqualsEqualsEqualsToken); + equals.operatorToken = createSynthesizedNode(SyntaxKind.EqualsEqualsEqualsToken); equals.right = createVoidZero(); - var cond = createNode(SyntaxKind.ConditionalExpression); + var cond = createSynthesizedNode(SyntaxKind.ConditionalExpression); cond.condition = equals; cond.whenTrue = defaultValue; cond.whenFalse = value; @@ -3559,7 +3619,7 @@ module ts { } function createNumericLiteral(value: number) { - var node = createNode(SyntaxKind.NumericLiteral); + var node = createSynthesizedNode(SyntaxKind.NumericLiteral); node.text = "" + value; return node; } @@ -3568,7 +3628,7 @@ module ts { if (expr.kind === SyntaxKind.Identifier || expr.kind === SyntaxKind.PropertyAccessExpression || expr.kind === SyntaxKind.ElementAccessExpression) { return expr; } - var node = createNode(SyntaxKind.ParenthesizedExpression); + var node = createSynthesizedNode(SyntaxKind.ParenthesizedExpression); node.expression = expr; return node; } @@ -3577,14 +3637,14 @@ module ts { if (propName.kind !== SyntaxKind.Identifier) { return createElementAccess(object, propName); } - var node = createNode(SyntaxKind.PropertyAccessExpression); + var node = createSynthesizedNode(SyntaxKind.PropertyAccessExpression); node.expression = parenthesizeForAccess(object); node.name = propName; return node; } function createElementAccess(object: Expression, index: Expression): Expression { - var node = createNode(SyntaxKind.ElementAccessExpression); + var node = createSynthesizedNode(SyntaxKind.ElementAccessExpression); node.expression = parenthesizeForAccess(object); node.argumentExpression = index; return node; @@ -3723,8 +3783,31 @@ module ts { } } else { + var isLet = renameNonTopLevelLetAndConst(node.name); emitModuleMemberName(node); - emitOptional(" = ", node.initializer); + + var initializer = node.initializer; + if (!initializer && languageVersion < ScriptTarget.ES6) { + + // downlevel emit for non-initialized let bindings defined in loops + // for (...) { let x; } + // should be + // for (...) { var = void 0; } + // this is necessary to preserve ES6 semantic in scenarios like + // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations + var isUninitializedLet = + (resolver.getNodeCheckFlags(node) & NodeCheckFlags.BlockScopedBindingInLoop) && + (getCombinedFlagsForIdentifier(node.name) & NodeFlags.Let); + + // NOTE: default initialization should not be added to let bindings in for-in\for-of statements + if (isUninitializedLet && + node.parent.parent.kind !== SyntaxKind.ForInStatement && + node.parent.parent.kind !== SyntaxKind.ForOfStatement) { + initializer = createVoidZero(); + } + } + + emitOptional(" = ", initializer); } } @@ -3737,18 +3820,86 @@ module ts { forEach((name).elements, emitExportVariableAssignments); } } + + function getEnclosingBlockScopeContainer(node: Node): Node { + var current = node; + while (current) { + if (isAnyFunction(current)) { + return current; + } + switch (current.kind) { + case SyntaxKind.SourceFile: + case SyntaxKind.SwitchKeyword: + case SyntaxKind.CatchClause: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + return current; + case SyntaxKind.Block: + // function block is not considered block-scope container + // see comment in binder.ts: bind(...), case for SyntaxKind.Block + if (!isAnyFunction(current.parent)) { + return current; + } + } + + current = current.parent; + } + } + + + function getCombinedFlagsForIdentifier(node: Identifier): NodeFlags { + if (!node.parent || (node.parent.kind !== SyntaxKind.VariableDeclaration && node.parent.kind !== SyntaxKind.BindingElement)) { + return 0; + } + + return getCombinedNodeFlags(node.parent); + } + + function renameNonTopLevelLetAndConst(node: Node): void { + // do not rename if + // - language version is ES6+ + // - node is synthesized + // - node is not identifier (can happen when tree is malformed) + // - node is definitely not name of variable declaration. + // it still can be part of parameter declaration, this check will be done next + if (languageVersion >= ScriptTarget.ES6 || + nodeIsSynthesized(node) || + node.kind !== SyntaxKind.Identifier || + (node.parent.kind !== SyntaxKind.VariableDeclaration && node.parent.kind !== SyntaxKind.BindingElement)) { + return; + } + + var combinedFlags = getCombinedFlagsForIdentifier(node); + if (((combinedFlags & NodeFlags.BlockScoped) === 0) || combinedFlags & NodeFlags.Export) { + // do not rename exported or non-block scoped variables + return; + } + + // here it is known that node is a block scoped variable + var list = getAncestor(node, SyntaxKind.VariableDeclarationList); + if (list.parent.kind === SyntaxKind.VariableStatement && list.parent.parent.kind === SyntaxKind.SourceFile) { + // do not rename variables that are defined on source file level + return; + } + + var blockScopeContainer = getEnclosingBlockScopeContainer(node); + var parent = blockScopeContainer.kind === SyntaxKind.SourceFile + ? blockScopeContainer + : blockScopeContainer.parent; + + var generatedName = generateUniqueNameForLocation(parent, (node).text); + var variableId = resolver.getBlockScopedVariableId(node); + if (!generatedBlockScopeNames) { + generatedBlockScopeNames = []; + } + generatedBlockScopeNames[variableId] = generatedName; + } function emitVariableStatement(node: VariableStatement) { if (!(node.flags & NodeFlags.Export)) { - if (isLet(node.declarationList)) { - write("let "); - } - else if (isConst(node.declarationList)) { - write("const "); - } - else { - write("var "); - } + emitStartOfVariableDeclarationList(node.declarationList); } emitCommaList(node.declarationList.declarations); write(";"); @@ -3925,6 +4076,8 @@ module ts { tempVariables = undefined; tempParameters = undefined; + var popFrame = enterNameScope() + // When targeting ES6, emit arrow function natively in ES6 if (shouldEmitAsArrowFunction(node)) { emitSignatureParametersForArrow(node); @@ -3956,6 +4109,8 @@ module ts { write(";"); } + exitNameScope(popFrame); + tempCount = saveTempCount; tempVariables = saveTempVariables; tempParameters = saveTempParameters; @@ -4277,6 +4432,9 @@ module ts { tempCount = 0; tempVariables = undefined; tempParameters = undefined; + + var popFrame = enterNameScope(); + // Emit the constructor overload pinned comments forEach(node.members, member => { if (member.kind === SyntaxKind.Constructor && !(member).body) { @@ -4337,6 +4495,9 @@ module ts { if (ctor) { emitTrailingComments(ctor); } + + exitNameScope(popFrame); + tempCount = saveTempCount; tempVariables = saveTempVariables; tempParameters = saveTempParameters; @@ -4469,7 +4630,11 @@ module ts { var saveTempVariables = tempVariables; tempCount = 0; tempVariables = undefined; + var popFrame = enterNameScope(); + emit(node.body); + + exitNameScope(popFrame); tempCount = saveTempCount; tempVariables = saveTempVariables; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index da8e1bdbe401e..27535f41e43d5 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1204,6 +1204,7 @@ module ts { // Returns the constant value this property access resolves to, or 'undefined' for a non-constant getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; isUnknownIdentifier(location: Node, name: string): boolean; + getBlockScopedVariableId(node: Identifier): number; } export const enum SymbolFlags { @@ -1329,6 +1330,7 @@ module ts { // Values for enum members have been computed, and any errors have been reported for them. EnumValuesComputed = 0x00000080, + BlockScopedBindingInLoop = 0x00000100, } export interface NodeLinks { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 01def791c0236..af574572055cf 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -7,6 +7,12 @@ module ts { isNoDefaultLib?: boolean } + export interface SynthesizedNode extends Node { + leadingCommentRanges?: CommentRange[]; + trailingCommentRanges?: CommentRange[]; + startsOnNewLine: boolean; + } + export function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration { var declarations = symbol.declarations; for (var i = 0; i < declarations.length; i++) { @@ -1133,7 +1139,44 @@ module ts { return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength: */newEndN - oldStartN); } - // @internal + export function nodeStartsNewLexicalEnvironment(n: Node): boolean { + return isAnyFunction(n) || n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.SourceFile; + } + + export function nodeIsSynthesized(node: Node): boolean { + return node.pos === -1 && node.end === -1; + } + + export function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node { + var node = createNode(kind); + node.pos = -1; + node.end = -1; + node.startsOnNewLine = startsOnNewLine; + return node; + } + + export function generateUniqueName(baseName: string, isExistingName: (name: string) => boolean): string { + // First try '_name' + if (baseName.charCodeAt(0) !== CharacterCodes._) { + var baseName = "_" + baseName; + if (!isExistingName(baseName)) { + return baseName; + } + } + // Find the first unique '_name_n', where n is a positive number + if (baseName.charCodeAt(baseName.length - 1) !== CharacterCodes._) { + baseName += "_"; + } + var i = 1; + while (true) { + var name = baseName + i; + if (!isExistingName(name)) { + return name; + } + i++; + } + } + export function createDiagnosticCollection(): DiagnosticCollection { var nonFileDiagnostics: Diagnostic[] = []; var fileDiagnostics: Map = {}; diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 7f5bc29906ae6..c399805e31e9d 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -940,6 +940,7 @@ declare module "typescript" { isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; isUnknownIdentifier(location: Node, name: string): boolean; + getBlockScopedVariableId(node: Identifier): number; } const enum SymbolFlags { FunctionScopedVariable = 1, @@ -1044,6 +1045,7 @@ declare module "typescript" { SuperStatic = 32, ContextChecked = 64, EnumValuesComputed = 128, + BlockScopedBindingInLoop = 256, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index d93a48b7852e9..5383e34132c88 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -3059,6 +3059,11 @@ declare module "typescript" { >location : Node >Node : Node >name : string + + getBlockScopedVariableId(node: Identifier): number; +>getBlockScopedVariableId : (node: Identifier) => number +>node : Identifier +>Identifier : Identifier } const enum SymbolFlags { >SymbolFlags : SymbolFlags @@ -3370,6 +3375,9 @@ declare module "typescript" { EnumValuesComputed = 128, >EnumValuesComputed : NodeCheckFlags + + BlockScopedBindingInLoop = 256, +>BlockScopedBindingInLoop : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 36dd2421adda7..ee5f2aca34c13 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -971,6 +971,7 @@ declare module "typescript" { isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; isUnknownIdentifier(location: Node, name: string): boolean; + getBlockScopedVariableId(node: Identifier): number; } const enum SymbolFlags { FunctionScopedVariable = 1, @@ -1075,6 +1076,7 @@ declare module "typescript" { SuperStatic = 32, ContextChecked = 64, EnumValuesComputed = 128, + BlockScopedBindingInLoop = 256, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 7a282b61f42c2..a462935a373af 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -3205,6 +3205,11 @@ declare module "typescript" { >location : Node >Node : Node >name : string + + getBlockScopedVariableId(node: Identifier): number; +>getBlockScopedVariableId : (node: Identifier) => number +>node : Identifier +>Identifier : Identifier } const enum SymbolFlags { >SymbolFlags : SymbolFlags @@ -3516,6 +3521,9 @@ declare module "typescript" { EnumValuesComputed = 128, >EnumValuesComputed : NodeCheckFlags + + BlockScopedBindingInLoop = 256, +>BlockScopedBindingInLoop : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 2ead514026192..e9f408a706399 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -972,6 +972,7 @@ declare module "typescript" { isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; isUnknownIdentifier(location: Node, name: string): boolean; + getBlockScopedVariableId(node: Identifier): number; } const enum SymbolFlags { FunctionScopedVariable = 1, @@ -1076,6 +1077,7 @@ declare module "typescript" { SuperStatic = 32, ContextChecked = 64, EnumValuesComputed = 128, + BlockScopedBindingInLoop = 256, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index 7a9d0523653be..d9614c6dcaf22 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -3155,6 +3155,11 @@ declare module "typescript" { >location : Node >Node : Node >name : string + + getBlockScopedVariableId(node: Identifier): number; +>getBlockScopedVariableId : (node: Identifier) => number +>node : Identifier +>Identifier : Identifier } const enum SymbolFlags { >SymbolFlags : SymbolFlags @@ -3466,6 +3471,9 @@ declare module "typescript" { EnumValuesComputed = 128, >EnumValuesComputed : NodeCheckFlags + + BlockScopedBindingInLoop = 256, +>BlockScopedBindingInLoop : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 1d1f9f03d680f..ba620b798ed90 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -1009,6 +1009,7 @@ declare module "typescript" { isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; isUnknownIdentifier(location: Node, name: string): boolean; + getBlockScopedVariableId(node: Identifier): number; } const enum SymbolFlags { FunctionScopedVariable = 1, @@ -1113,6 +1114,7 @@ declare module "typescript" { SuperStatic = 32, ContextChecked = 64, EnumValuesComputed = 128, + BlockScopedBindingInLoop = 256, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 55c48d1354bfc..03113d62c768d 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -3328,6 +3328,11 @@ declare module "typescript" { >location : Node >Node : Node >name : string + + getBlockScopedVariableId(node: Identifier): number; +>getBlockScopedVariableId : (node: Identifier) => number +>node : Identifier +>Identifier : Identifier } const enum SymbolFlags { >SymbolFlags : SymbolFlags @@ -3639,6 +3644,9 @@ declare module "typescript" { EnumValuesComputed = 128, >EnumValuesComputed : NodeCheckFlags + + BlockScopedBindingInLoop = 256, +>BlockScopedBindingInLoop : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/VariableDeclaration10_es6.errors.txt b/tests/baselines/reference/VariableDeclaration10_es6.errors.txt deleted file mode 100644 index b7d4bf2f1c3f9..0000000000000 --- a/tests/baselines/reference/VariableDeclaration10_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts(1,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts (1 errors) ==== - let a: number = 1 - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration10_es6.types b/tests/baselines/reference/VariableDeclaration10_es6.types new file mode 100644 index 0000000000000..47238fdd5a8f7 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration10_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts === +let a: number = 1 +>a : number + diff --git a/tests/baselines/reference/VariableDeclaration2_es6.errors.txt b/tests/baselines/reference/VariableDeclaration2_es6.errors.txt index 0d8214f54208b..35e0ad2821cf6 100644 --- a/tests/baselines/reference/VariableDeclaration2_es6.errors.txt +++ b/tests/baselines/reference/VariableDeclaration2_es6.errors.txt @@ -1,10 +1,7 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts(1,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts(1,7): error TS1155: 'const' declarations must be initialized -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts (1 errors) ==== const a - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. ~ !!! error TS1155: 'const' declarations must be initialized \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration3_es6.errors.txt b/tests/baselines/reference/VariableDeclaration3_es6.errors.txt deleted file mode 100644 index a3b09f70d2d77..0000000000000 --- a/tests/baselines/reference/VariableDeclaration3_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts(1,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts (1 errors) ==== - const a = 1 - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration3_es6.types b/tests/baselines/reference/VariableDeclaration3_es6.types new file mode 100644 index 0000000000000..a172c8114cbb6 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration3_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts === +const a = 1 +>a : number + diff --git a/tests/baselines/reference/VariableDeclaration4_es6.errors.txt b/tests/baselines/reference/VariableDeclaration4_es6.errors.txt index b4bb75b5658f6..33d956ee1e51e 100644 --- a/tests/baselines/reference/VariableDeclaration4_es6.errors.txt +++ b/tests/baselines/reference/VariableDeclaration4_es6.errors.txt @@ -1,10 +1,7 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts(1,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts(1,7): error TS1155: 'const' declarations must be initialized -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts (1 errors) ==== const a: number - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. ~ !!! error TS1155: 'const' declarations must be initialized \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration5_es6.errors.txt b/tests/baselines/reference/VariableDeclaration5_es6.errors.txt deleted file mode 100644 index c72d423e46069..0000000000000 --- a/tests/baselines/reference/VariableDeclaration5_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts(1,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts (1 errors) ==== - const a: number = 1 - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration5_es6.types b/tests/baselines/reference/VariableDeclaration5_es6.types new file mode 100644 index 0000000000000..a07894d533d85 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration5_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts === +const a: number = 1 +>a : number + diff --git a/tests/baselines/reference/VariableDeclaration7_es6.errors.txt b/tests/baselines/reference/VariableDeclaration7_es6.errors.txt deleted file mode 100644 index 83d12d463e6ed..0000000000000 --- a/tests/baselines/reference/VariableDeclaration7_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts(1,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts (1 errors) ==== - let a - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration7_es6.types b/tests/baselines/reference/VariableDeclaration7_es6.types new file mode 100644 index 0000000000000..321c1b07bbcdd --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration7_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts === +let a +>a : any + diff --git a/tests/baselines/reference/VariableDeclaration8_es6.errors.txt b/tests/baselines/reference/VariableDeclaration8_es6.errors.txt deleted file mode 100644 index e371c64c9a6f2..0000000000000 --- a/tests/baselines/reference/VariableDeclaration8_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts(1,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts (1 errors) ==== - let a = 1 - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration8_es6.types b/tests/baselines/reference/VariableDeclaration8_es6.types new file mode 100644 index 0000000000000..530b147136dc7 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration8_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts === +let a = 1 +>a : number + diff --git a/tests/baselines/reference/VariableDeclaration9_es6.errors.txt b/tests/baselines/reference/VariableDeclaration9_es6.errors.txt deleted file mode 100644 index 4a1890d46947f..0000000000000 --- a/tests/baselines/reference/VariableDeclaration9_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts(1,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts (1 errors) ==== - let a: number - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration9_es6.types b/tests/baselines/reference/VariableDeclaration9_es6.types new file mode 100644 index 0000000000000..6b29a04281b58 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration9_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts === +let a: number +>a : number + diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map index c450a844d5ac4..d4df74499d038 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map @@ -1,2 +1,2 @@ //// [computedPropertyNamesSourceMap2_ES5.js.map] -{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,AADA,CACA,EAAA,GADA,EAAA;IACA,EAAA,CACK,OAAO,CAFA,GAAA;QAGA,QAAQ,CAAC;IACb,CAAC,AAJA;IAAA,EAAA,CAKA,CAAA;IAJD,EAAA"} \ No newline at end of file +{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,AADA,CAAA,EAAA,GAAA,EAAA;IAAA,EAAA,CAEA,OAAO,CAFA,GAAA;QAGA,QAAQ,CAAC;IACb,CAAC,AAJA;IAAA,EAAA,CAKA,CAAA;IALA,EAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt index 8e5b2aac87769..e1a4f764f42ad 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt @@ -27,24 +27,24 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 5 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 9) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 9) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 5 > 6 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column -6 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 9) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 10) Source(1, 1) + SourceIndex(0) nameIndex (-1) +6 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 9) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 10) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 6 > -7 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -7 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 10) Source(1, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 12) Source(1, 1) + SourceIndex(0) nameIndex (-1) +7 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found +7 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 10) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 12) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 7 > -8 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -8 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 12) Source(1, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 15) Source(0, NaN) + SourceIndex(0) nameIndex (-1) +8 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column +8 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 10) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 15) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 8 > 9 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found -9 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 15) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 17) Source(0, NaN) + SourceIndex(0) nameIndex (-1) +9 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 12) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 17) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 9 > 1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) 2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0) 3 >Emitted(1, 6) Source(1, 6) + SourceIndex(0) 4 >Emitted(1, 9) Source(1, 9) + SourceIndex(0) 5 >Emitted(1, 9) Source(0, NaN) + SourceIndex(0) -6 >Emitted(1, 10) Source(1, 1) + SourceIndex(0) -7 >Emitted(1, 12) Source(1, 1) + SourceIndex(0) +6 >Emitted(1, 10) Source(0, NaN) + SourceIndex(0) +7 >Emitted(1, 12) Source(0, NaN) + SourceIndex(0) 8 >Emitted(1, 15) Source(0, NaN) + SourceIndex(0) 9 >Emitted(1, 17) Source(0, NaN) + SourceIndex(0) --- @@ -56,26 +56,25 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 5 > ^ 6 > ^^^ 1->!!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column -1->!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 15) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 5) Source(1, 1) + SourceIndex(0) nameIndex (-1) +1->!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 12) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 5) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 1-> 2 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found -2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 17) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 7) Source(1, 1) + SourceIndex(0) nameIndex (-1) +2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 15) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 7) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 2 > 3 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column -3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 17) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 8) Source(2, 6) + SourceIndex(0) nameIndex (-1) -3 > var v = { - > [ -4 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -4 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 5) Source(1, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 15) Source(2, 13) + SourceIndex(0) nameIndex (-1) +3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 15) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 8) Source(2, 6) + SourceIndex(0) nameIndex (-1) +3 > +4 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found +4 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 17) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 15) Source(2, 13) + SourceIndex(0) nameIndex (-1) 4 > "hello" -5 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -5 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 7) Source(1, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 16) Source(0, NaN) + SourceIndex(0) nameIndex (-1) +5 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column +5 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 17) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 16) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 5 > -6 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -6 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 8) Source(2, 14) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 19) Source(0, NaN) + SourceIndex(0) nameIndex (-1) +6 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found +6 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 5) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 19) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 6 > -1->Emitted(2, 5) Source(1, 1) + SourceIndex(0) -2 >Emitted(2, 7) Source(1, 1) + SourceIndex(0) +1->Emitted(2, 5) Source(0, NaN) + SourceIndex(0) +2 >Emitted(2, 7) Source(0, NaN) + SourceIndex(0) 3 >Emitted(2, 8) Source(2, 6) + SourceIndex(0) 4 >Emitted(2, 15) Source(2, 13) + SourceIndex(0) 5 >Emitted(2, 16) Source(0, NaN) + SourceIndex(0) @@ -85,14 +84,14 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 1 >^^^^^^^^ 2 > ^^^^^^^^ 3 > ^ -1 >!!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -1 >!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 15) Source(2, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 9) Source(3, 9) + SourceIndex(0) nameIndex (-1) +1 >!!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column +1 >!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 5) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 9) Source(3, 9) + SourceIndex(0) nameIndex (-1) 1 > 2 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found -2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 16) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 17) Source(3, 17) + SourceIndex(0) nameIndex (-1) +2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 7) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 17) Source(3, 17) + SourceIndex(0) nameIndex (-1) 2 > debugger 3 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column -3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 16) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 18) Source(3, 18) + SourceIndex(0) nameIndex (-1) +3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 7) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 18) Source(3, 18) + SourceIndex(0) nameIndex (-1) 3 > ; 1 >Emitted(3, 9) Source(3, 9) + SourceIndex(0) 2 >Emitted(3, 17) Source(3, 17) + SourceIndex(0) @@ -103,15 +102,15 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 2 > ^ 3 > 4 > ^^^^-> -1 >!!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found -1 >!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 19) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 5) Source(4, 5) + SourceIndex(0) nameIndex (-1) +1 >!!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: +1 >!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 8) Source(2, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 5) Source(4, 5) + SourceIndex(0) nameIndex (-1) 1 > > -2 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column -2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 19) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 6) Source(4, 6) + SourceIndex(0) nameIndex (-1) +2 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: +2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 15) Source(2, 16) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 6) Source(4, 6) + SourceIndex(0) nameIndex (-1) 2 > } -3 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 9) Source(3, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 6) Source(0, NaN) + SourceIndex(0) nameIndex (-1) +3 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found +3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 16) Source(0, 16) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 6) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 3 > 1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0) 2 >Emitted(4, 6) Source(4, 6) + SourceIndex(0) @@ -122,17 +121,17 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 2 > ^^ 3 > ^ 4 > ^ -1->!!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -1->!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 17) Source(3, 29) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 5) Source(0, NaN) + SourceIndex(0) nameIndex (-1) +1->!!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column +1->!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 16) Source(0, 16) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 5) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 1-> -2 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 18) Source(3, 30) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 7) Source(0, NaN) + SourceIndex(0) nameIndex (-1) +2 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found +2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 19) Source(0, 16) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 7) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 2 > -3 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(4, 5) Source(4, 17) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 8) Source(5, 2) + SourceIndex(0) nameIndex (-1) +3 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column +3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 19) Source(0, 16) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 8) Source(5, 2) + SourceIndex(0) nameIndex (-1) 3 > 4 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -4 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(4, 6) Source(4, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 9) Source(5, 2) + SourceIndex(0) nameIndex (-1) +4 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 9) Source(3, 16) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 9) Source(5, 2) + SourceIndex(0) nameIndex (-1) 4 > 1->Emitted(5, 5) Source(0, NaN) + SourceIndex(0) 2 >Emitted(5, 7) Source(0, NaN) + SourceIndex(0) @@ -143,15 +142,15 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 1 >^^^^ 2 > ^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >!!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found -1 >!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(4, 6) Source(0, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(6, 5) Source(1, 1) + SourceIndex(0) nameIndex (-1) +1 >!!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: +1 >!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 17) Source(3, 24) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(6, 5) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 1 > -2 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column -2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(4, 6) Source(0, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(6, 7) Source(1, 1) + SourceIndex(0) nameIndex (-1) +2 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: +2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 18) Source(3, 25) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(6, 7) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 2 > -1 >Emitted(6, 5) Source(1, 1) + SourceIndex(0) -2 >Emitted(6, 7) Source(1, 1) + SourceIndex(0) +1 >Emitted(6, 5) Source(0, NaN) + SourceIndex(0) +2 >Emitted(6, 7) Source(0, NaN) + SourceIndex(0) --- !!!! **** There are more source map entries in the sourceMap's mapping than what was encoded -!!!! **** Remaining decoded string: ;IAAA,EAAA,CAKA,CAAA;IAJD,EAAA +!!!! **** Remaining decoded string: ;IACb,CAAC,AAJA;IAAA,EAAA,CAKA,CAAA;IALA,EAAA >>>//# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map \ No newline at end of file diff --git a/tests/baselines/reference/constDeclarations-errors.errors.txt b/tests/baselines/reference/constDeclarations-errors.errors.txt index c0ae6635c5e78..10501beb1a540 100644 --- a/tests/baselines/reference/constDeclarations-errors.errors.txt +++ b/tests/baselines/reference/constDeclarations-errors.errors.txt @@ -4,13 +4,12 @@ tests/cases/compiler/constDeclarations-errors.ts(5,7): error TS1155: 'const' dec tests/cases/compiler/constDeclarations-errors.ts(5,11): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(5,15): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(5,27): error TS1155: 'const' declarations must be initialized -tests/cases/compiler/constDeclarations-errors.ts(8,11): error TS1155: 'const' declarations must be initialized -tests/cases/compiler/constDeclarations-errors.ts(11,27): error TS2449: The operand of an increment or decrement operator cannot be a constant. -tests/cases/compiler/constDeclarations-errors.ts(14,11): error TS1155: 'const' declarations must be initialized -tests/cases/compiler/constDeclarations-errors.ts(17,20): error TS1155: 'const' declarations must be initialized +tests/cases/compiler/constDeclarations-errors.ts(10,27): error TS2449: The operand of an increment or decrement operator cannot be a constant. +tests/cases/compiler/constDeclarations-errors.ts(13,11): error TS1155: 'const' declarations must be initialized +tests/cases/compiler/constDeclarations-errors.ts(16,20): error TS1155: 'const' declarations must be initialized -==== tests/cases/compiler/constDeclarations-errors.ts (10 errors) ==== +==== tests/cases/compiler/constDeclarations-errors.ts (9 errors) ==== // error, missing intialicer const c1; @@ -29,10 +28,7 @@ tests/cases/compiler/constDeclarations-errors.ts(17,20): error TS1155: 'const' d ~~ !!! error TS1155: 'const' declarations must be initialized - // error, can not be unintalized for(const c in {}) { } - ~ -!!! error TS1155: 'const' declarations must be initialized // error, assigning to a const for(const c8 = 0; c8 < 1; c8++) { } diff --git a/tests/baselines/reference/constDeclarations-errors.js b/tests/baselines/reference/constDeclarations-errors.js index 2947593b01d53..e7143f2564ae7 100644 --- a/tests/baselines/reference/constDeclarations-errors.js +++ b/tests/baselines/reference/constDeclarations-errors.js @@ -5,7 +5,6 @@ const c1; const c2: number; const c3, c4, c5 :string, c6; // error, missing initialicer -// error, can not be unintalized for(const c in {}) { } // error, assigning to a const @@ -22,8 +21,7 @@ for(const c10 = 0, c11; c10 < 1;) { } const c1; const c2; const c3, c4, c5, c6; // error, missing initialicer -// error, can not be unintalized -for (var c in {}) { } +for (const c in {}) { } // error, assigning to a const for (const c8 = 0; c8 < 1; c8++) { } // error, can not be unintalized diff --git a/tests/baselines/reference/constDeclarations-es5.errors.txt b/tests/baselines/reference/constDeclarations-es5.errors.txt deleted file mode 100644 index d15535349ace0..0000000000000 --- a/tests/baselines/reference/constDeclarations-es5.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -tests/cases/compiler/constDeclarations-es5.ts(2,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/constDeclarations-es5.ts(3,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/constDeclarations-es5.ts(4,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/compiler/constDeclarations-es5.ts (3 errors) ==== - - const z7 = false; - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. - const z8: number = 23; - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. - const z9 = 0, z10 :string = "", z11 = null; - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. - \ No newline at end of file diff --git a/tests/baselines/reference/constDeclarations-es5.js b/tests/baselines/reference/constDeclarations-es5.js index 20deb9dca371d..736260ad10251 100644 --- a/tests/baselines/reference/constDeclarations-es5.js +++ b/tests/baselines/reference/constDeclarations-es5.js @@ -6,6 +6,6 @@ const z9 = 0, z10 :string = "", z11 = null; //// [constDeclarations-es5.js] -const z7 = false; -const z8 = 23; -const z9 = 0, z10 = "", z11 = null; +var z7 = false; +var z8 = 23; +var z9 = 0, z10 = "", z11 = null; diff --git a/tests/baselines/reference/constDeclarations-es5.types b/tests/baselines/reference/constDeclarations-es5.types new file mode 100644 index 0000000000000..be55dc0febcfe --- /dev/null +++ b/tests/baselines/reference/constDeclarations-es5.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/constDeclarations-es5.ts === + +const z7 = false; +>z7 : boolean + +const z8: number = 23; +>z8 : number + +const z9 = 0, z10 :string = "", z11 = null; +>z9 : number +>z10 : string +>z11 : any + diff --git a/tests/baselines/reference/downlevelLetConst1.errors.txt b/tests/baselines/reference/downlevelLetConst1.errors.txt new file mode 100644 index 0000000000000..a46d1973e04fc --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst1.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/downlevelLetConst1.ts(1,6): error TS1123: Variable declaration list cannot be empty. + + +==== tests/cases/compiler/downlevelLetConst1.ts (1 errors) ==== + const + +!!! error TS1123: Variable declaration list cannot be empty. \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst1.js b/tests/baselines/reference/downlevelLetConst1.js new file mode 100644 index 0000000000000..3463c1003249e --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst1.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst1.ts] +const + +//// [downlevelLetConst1.js] +var ; diff --git a/tests/baselines/reference/downlevelLetConst10.js b/tests/baselines/reference/downlevelLetConst10.js new file mode 100644 index 0000000000000..8beb79b04b445 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst10.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst10.ts] +let a: number = 1 + +//// [downlevelLetConst10.js] +var a = 1; diff --git a/tests/baselines/reference/downlevelLetConst10.types b/tests/baselines/reference/downlevelLetConst10.types new file mode 100644 index 0000000000000..05fe302945586 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst10.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/downlevelLetConst10.ts === +let a: number = 1 +>a : number + diff --git a/tests/baselines/reference/downlevelLetConst11.errors.txt b/tests/baselines/reference/downlevelLetConst11.errors.txt new file mode 100644 index 0000000000000..42449bd3c8a34 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst11.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/downlevelLetConst11.ts(2,4): error TS1123: Variable declaration list cannot be empty. + + +==== tests/cases/compiler/downlevelLetConst11.ts (1 errors) ==== + "use strict"; + let + +!!! error TS1123: Variable declaration list cannot be empty. \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst11.js b/tests/baselines/reference/downlevelLetConst11.js new file mode 100644 index 0000000000000..377c7e6a9ed4a --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst11.js @@ -0,0 +1,7 @@ +//// [downlevelLetConst11.ts] +"use strict"; +let + +//// [downlevelLetConst11.js] +"use strict"; +var ; diff --git a/tests/baselines/reference/downlevelLetConst12.js b/tests/baselines/reference/downlevelLetConst12.js new file mode 100644 index 0000000000000..6437d17accb3e --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst12.js @@ -0,0 +1,22 @@ +//// [downlevelLetConst12.ts] + +'use strict' +// top level let\const should not be renamed +let foo; +const bar = 1; + +let [baz] = []; +let {a: baz2} = { a: 1 }; + +const [baz3] = [] +const {a: baz4} = { a: 1 }; + +//// [downlevelLetConst12.js] +'use strict'; +// top level let\const should not be renamed +var foo; +var bar = 1; +var baz = ([])[0]; +var baz2 = ({ a: 1 }).a; +var baz3 = ([])[0]; +var baz4 = ({ a: 1 }).a; diff --git a/tests/baselines/reference/downlevelLetConst12.types b/tests/baselines/reference/downlevelLetConst12.types new file mode 100644 index 0000000000000..90a814e0753c8 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst12.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/downlevelLetConst12.ts === + +'use strict' +// top level let\const should not be renamed +let foo; +>foo : any + +const bar = 1; +>bar : number + +let [baz] = []; +>baz : any +>[] : undefined[] + +let {a: baz2} = { a: 1 }; +>a : unknown +>baz2 : number +>{ a: 1 } : { a: number; } +>a : number + +const [baz3] = [] +>baz3 : any +>[] : undefined[] + +const {a: baz4} = { a: 1 }; +>a : unknown +>baz4 : number +>{ a: 1 } : { a: number; } +>a : number + diff --git a/tests/baselines/reference/downlevelLetConst13.js b/tests/baselines/reference/downlevelLetConst13.js new file mode 100644 index 0000000000000..8324d697e95fd --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst13.js @@ -0,0 +1,39 @@ +//// [downlevelLetConst13.ts] + +'use strict' +// exported let\const bindings should not be renamed + +export let foo = 10; +export const bar = "123" +export let [bar1] = [1]; +export const [bar2] = [2]; +export let {a: bar3} = { a: 1 }; +export const {a: bar4} = { a: 1 }; + +export module M { + export let baz = 100; + export const baz2 = true; + export let [bar5] = [1]; + export const [bar6] = [2]; + export let {a: bar7} = { a: 1 }; + export const {a: bar8} = { a: 1 }; +} + +//// [downlevelLetConst13.js] +'use strict'; +// exported let\const bindings should not be renamed +exports.foo = 10; +exports.bar = "123"; +exports.bar1 = ([1])[0]; +exports.bar2 = ([2])[0]; +exports.bar3 = ({ a: 1 }).a; +exports.bar4 = ({ a: 1 }).a; +var M; +(function (M) { + M.baz = 100; + M.baz2 = true; + M.bar5 = ([1])[0]; + M.bar6 = ([2])[0]; + M.bar7 = ({ a: 1 }).a; + M.bar8 = ({ a: 1 }).a; +})(M = exports.M || (exports.M = {})); diff --git a/tests/baselines/reference/downlevelLetConst13.types b/tests/baselines/reference/downlevelLetConst13.types new file mode 100644 index 0000000000000..e72e3936f4398 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst13.types @@ -0,0 +1,60 @@ +=== tests/cases/compiler/downlevelLetConst13.ts === + +'use strict' +// exported let\const bindings should not be renamed + +export let foo = 10; +>foo : number + +export const bar = "123" +>bar : string + +export let [bar1] = [1]; +>bar1 : number +>[1] : [number] + +export const [bar2] = [2]; +>bar2 : number +>[2] : [number] + +export let {a: bar3} = { a: 1 }; +>a : unknown +>bar3 : number +>{ a: 1 } : { a: number; } +>a : number + +export const {a: bar4} = { a: 1 }; +>a : unknown +>bar4 : number +>{ a: 1 } : { a: number; } +>a : number + +export module M { +>M : typeof M + + export let baz = 100; +>baz : number + + export const baz2 = true; +>baz2 : boolean + + export let [bar5] = [1]; +>bar5 : number +>[1] : [number] + + export const [bar6] = [2]; +>bar6 : number +>[2] : [number] + + export let {a: bar7} = { a: 1 }; +>a : unknown +>bar7 : number +>{ a: 1 } : { a: number; } +>a : number + + export const {a: bar8} = { a: 1 }; +>a : unknown +>bar8 : number +>{ a: 1 } : { a: number; } +>a : number +} diff --git a/tests/baselines/reference/downlevelLetConst14.js b/tests/baselines/reference/downlevelLetConst14.js new file mode 100644 index 0000000000000..212262dc43ae4 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst14.js @@ -0,0 +1,107 @@ +//// [downlevelLetConst14.ts] +'use strict' +declare function use(a: any); + +var x = 10; +var z0, z1, z2, z3; +{ + let x = 20; + use(x); + + let [z0] = [1]; + use(z0); + let [z1] = [1] + use(z1); + let {a: z2} = { a: 1 }; + use(z2); + let {a: z3} = { a: 1 }; + use(z3); +} +use(x); +use(z0); +use(z1); +use(z2); +use(z3); +var z6; +var y = true; +{ + let y = ""; + let [z6] = [true] + { + let y = 1; + let {a: z6} = {a: 1} + use(y); + use(z6); + } + use(y); + use(z6); +} +use(y); +use(z6); + +var z = false; +var z5 = 1; +{ + let z = ""; + let [z5] = [5]; + { + let _z = 1; + let {a: _z5} = { a: 1 }; + // try to step on generated name + use(_z); + } + use(z); +} +use(y); + +//// [downlevelLetConst14.js] +'use strict'; +var x = 10; +var z0, z1, z2, z3; +{ + var _x = 20; + use(_x); + var _z0 = ([1])[0]; + use(_z0); + var _z1 = ([1])[0]; + use(_z1); + var _z2 = ({ a: 1 }).a; + use(_z2); + var _z3 = ({ a: 1 }).a; + use(_z3); +} +use(x); +use(z0); +use(z1); +use(z2); +use(z3); +var z6; +var y = true; +{ + var _y = ""; + var _z6 = ([true])[0]; + { + var _y_1 = 1; + var _z6_1 = ({ a: 1 }).a; + use(_y_1); + use(_z6_1); + } + use(_y); + use(_z6); +} +use(y); +use(z6); +var z = false; +var z5 = 1; +{ + var _z = ""; + var _z5 = ([5])[0]; + { + var _z_1 = 1; + var _z5_1 = ({ a: 1 }).a; + // try to step on generated name + use(_z_1); + } + use(_z); +} +use(y); diff --git a/tests/baselines/reference/downlevelLetConst14.types b/tests/baselines/reference/downlevelLetConst14.types new file mode 100644 index 0000000000000..05b66948830ad --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst14.types @@ -0,0 +1,178 @@ +=== tests/cases/compiler/downlevelLetConst14.ts === +'use strict' +declare function use(a: any); +>use : (a: any) => any +>a : any + +var x = 10; +>x : number + +var z0, z1, z2, z3; +>z0 : any +>z1 : any +>z2 : any +>z3 : any +{ + let x = 20; +>x : number + + use(x); +>use(x) : any +>use : (a: any) => any +>x : number + + let [z0] = [1]; +>z0 : number +>[1] : [number] + + use(z0); +>use(z0) : any +>use : (a: any) => any +>z0 : number + + let [z1] = [1] +>z1 : number +>[1] : [number] + + use(z1); +>use(z1) : any +>use : (a: any) => any +>z1 : number + + let {a: z2} = { a: 1 }; +>a : unknown +>z2 : number +>{ a: 1 } : { a: number; } +>a : number + + use(z2); +>use(z2) : any +>use : (a: any) => any +>z2 : number + + let {a: z3} = { a: 1 }; +>a : unknown +>z3 : number +>{ a: 1 } : { a: number; } +>a : number + + use(z3); +>use(z3) : any +>use : (a: any) => any +>z3 : number +} +use(x); +>use(x) : any +>use : (a: any) => any +>x : number + +use(z0); +>use(z0) : any +>use : (a: any) => any +>z0 : any + +use(z1); +>use(z1) : any +>use : (a: any) => any +>z1 : any + +use(z2); +>use(z2) : any +>use : (a: any) => any +>z2 : any + +use(z3); +>use(z3) : any +>use : (a: any) => any +>z3 : any + +var z6; +>z6 : any + +var y = true; +>y : boolean +{ + let y = ""; +>y : string + + let [z6] = [true] +>z6 : boolean +>[true] : [boolean] + { + let y = 1; +>y : number + + let {a: z6} = {a: 1} +>a : unknown +>z6 : number +>{a: 1} : { a: number; } +>a : number + + use(y); +>use(y) : any +>use : (a: any) => any +>y : number + + use(z6); +>use(z6) : any +>use : (a: any) => any +>z6 : number + } + use(y); +>use(y) : any +>use : (a: any) => any +>y : string + + use(z6); +>use(z6) : any +>use : (a: any) => any +>z6 : boolean +} +use(y); +>use(y) : any +>use : (a: any) => any +>y : boolean + +use(z6); +>use(z6) : any +>use : (a: any) => any +>z6 : any + +var z = false; +>z : boolean + +var z5 = 1; +>z5 : number +{ + let z = ""; +>z : string + + let [z5] = [5]; +>z5 : number +>[5] : [number] + { + let _z = 1; +>_z : number + + let {a: _z5} = { a: 1 }; +>a : unknown +>_z5 : number +>{ a: 1 } : { a: number; } +>a : number + + // try to step on generated name + use(_z); +>use(_z) : any +>use : (a: any) => any +>_z : number + } + use(z); +>use(z) : any +>use : (a: any) => any +>z : string +} +use(y); +>use(y) : any +>use : (a: any) => any +>y : boolean + diff --git a/tests/baselines/reference/downlevelLetConst15.js b/tests/baselines/reference/downlevelLetConst15.js new file mode 100644 index 0000000000000..c9b677191975e --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst15.js @@ -0,0 +1,107 @@ +//// [downlevelLetConst15.ts] +'use strict' +declare function use(a: any); + +var x = 10; +var z0, z1, z2, z3; +{ + const x = 20; + use(x); + + const [z0] = [1]; + use(z0); + const [{a: z1}] = [{a: 1}] + use(z1); + const {a: z2} = { a: 1 }; + use(z2); + const {a: {b: z3}} = { a: {b: 1} }; + use(z3); +} +use(x); +use(z0); +use(z1); +use(z2); +use(z3); +var z6; +var y = true; +{ + const y = ""; + const [z6] = [true] + { + const y = 1; + const {a: z6} = { a: 1 } + use(y); + use(z6); + } + use(y); + use(z6); +} +use(y); +use(z6); + +var z = false; +var z5 = 1; +{ + const z = ""; + const [z5] = [5]; + { + const _z = 1; + const {a: _z5} = { a: 1 }; + // try to step on generated name + use(_z); + } + use(z); +} +use(y); + +//// [downlevelLetConst15.js] +'use strict'; +var x = 10; +var z0, z1, z2, z3; +{ + var _x = 20; + use(_x); + var _z0 = ([1])[0]; + use(_z0); + var _z1 = ([{ a: 1 }])[0].a; + use(_z1); + var _z2 = ({ a: 1 }).a; + use(_z2); + var _z3 = ({ a: { b: 1 } }).a.b; + use(_z3); +} +use(x); +use(z0); +use(z1); +use(z2); +use(z3); +var z6; +var y = true; +{ + var _y = ""; + var _z6 = ([true])[0]; + { + var _y_1 = 1; + var _z6_1 = ({ a: 1 }).a; + use(_y_1); + use(_z6_1); + } + use(_y); + use(_z6); +} +use(y); +use(z6); +var z = false; +var z5 = 1; +{ + var _z = ""; + var _z5 = ([5])[0]; + { + var _z_1 = 1; + var _z5_1 = ({ a: 1 }).a; + // try to step on generated name + use(_z_1); + } + use(_z); +} +use(y); diff --git a/tests/baselines/reference/downlevelLetConst15.types b/tests/baselines/reference/downlevelLetConst15.types new file mode 100644 index 0000000000000..008d132ab70bb --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst15.types @@ -0,0 +1,184 @@ +=== tests/cases/compiler/downlevelLetConst15.ts === +'use strict' +declare function use(a: any); +>use : (a: any) => any +>a : any + +var x = 10; +>x : number + +var z0, z1, z2, z3; +>z0 : any +>z1 : any +>z2 : any +>z3 : any +{ + const x = 20; +>x : number + + use(x); +>use(x) : any +>use : (a: any) => any +>x : number + + const [z0] = [1]; +>z0 : number +>[1] : [number] + + use(z0); +>use(z0) : any +>use : (a: any) => any +>z0 : number + + const [{a: z1}] = [{a: 1}] +>a : unknown +>z1 : number +>[{a: 1}] : [{ a: number; }] +>{a: 1} : { a: number; } +>a : number + + use(z1); +>use(z1) : any +>use : (a: any) => any +>z1 : number + + const {a: z2} = { a: 1 }; +>a : unknown +>z2 : number +>{ a: 1 } : { a: number; } +>a : number + + use(z2); +>use(z2) : any +>use : (a: any) => any +>z2 : number + + const {a: {b: z3}} = { a: {b: 1} }; +>a : unknown +>b : unknown +>z3 : number +>{ a: {b: 1} } : { a: { b: number; }; } +>a : { b: number; } +>{b: 1} : { b: number; } +>b : number + + use(z3); +>use(z3) : any +>use : (a: any) => any +>z3 : number +} +use(x); +>use(x) : any +>use : (a: any) => any +>x : number + +use(z0); +>use(z0) : any +>use : (a: any) => any +>z0 : any + +use(z1); +>use(z1) : any +>use : (a: any) => any +>z1 : any + +use(z2); +>use(z2) : any +>use : (a: any) => any +>z2 : any + +use(z3); +>use(z3) : any +>use : (a: any) => any +>z3 : any + +var z6; +>z6 : any + +var y = true; +>y : boolean +{ + const y = ""; +>y : string + + const [z6] = [true] +>z6 : boolean +>[true] : [boolean] + { + const y = 1; +>y : number + + const {a: z6} = { a: 1 } +>a : unknown +>z6 : number +>{ a: 1 } : { a: number; } +>a : number + + use(y); +>use(y) : any +>use : (a: any) => any +>y : number + + use(z6); +>use(z6) : any +>use : (a: any) => any +>z6 : number + } + use(y); +>use(y) : any +>use : (a: any) => any +>y : string + + use(z6); +>use(z6) : any +>use : (a: any) => any +>z6 : boolean +} +use(y); +>use(y) : any +>use : (a: any) => any +>y : boolean + +use(z6); +>use(z6) : any +>use : (a: any) => any +>z6 : any + +var z = false; +>z : boolean + +var z5 = 1; +>z5 : number +{ + const z = ""; +>z : string + + const [z5] = [5]; +>z5 : number +>[5] : [number] + { + const _z = 1; +>_z : number + + const {a: _z5} = { a: 1 }; +>a : unknown +>_z5 : number +>{ a: 1 } : { a: number; } +>a : number + + // try to step on generated name + use(_z); +>use(_z) : any +>use : (a: any) => any +>_z : number + } + use(z); +>use(z) : any +>use : (a: any) => any +>z : string +} +use(y); +>use(y) : any +>use : (a: any) => any +>y : boolean + diff --git a/tests/baselines/reference/downlevelLetConst16.errors.txt b/tests/baselines/reference/downlevelLetConst16.errors.txt new file mode 100644 index 0000000000000..dafdd5b7b074d --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst16.errors.txt @@ -0,0 +1,249 @@ +tests/cases/compiler/downlevelLetConst16.ts(189,5): error TS9003: 'for...of' statements are not currently supported. +tests/cases/compiler/downlevelLetConst16.ts(196,5): error TS9003: 'for...of' statements are not currently supported. +tests/cases/compiler/downlevelLetConst16.ts(203,5): error TS9003: 'for...of' statements are not currently supported. +tests/cases/compiler/downlevelLetConst16.ts(210,5): error TS9003: 'for...of' statements are not currently supported. +tests/cases/compiler/downlevelLetConst16.ts(217,5): error TS9003: 'for...of' statements are not currently supported. +tests/cases/compiler/downlevelLetConst16.ts(224,5): error TS9003: 'for...of' statements are not currently supported. + + +==== tests/cases/compiler/downlevelLetConst16.ts (6 errors) ==== + 'use strict' + + declare function use(a: any); + + var x = 10; + var y; + var z; + use(x); + use(y); + use(z); + function foo1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = {a: 1}; + use(z); + } + + function foo2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); + } + + class A { + m1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + m2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); + } + + } + + class B { + m1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + m2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + } + } + + function bar1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + } + + function bar2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + } + + module M1 { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + + module M2 { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); + } + + module M3 { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + + module M4 { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + use(y); + use(z); + } + + function foo3() { + for (let x; ;) { + use(x); + } + for (let [y] = []; ;) { + use(y); + } + for (let {a: z} = {a: 1}; ;) { + use(z); + } + use(x); + } + + function foo4() { + for (const x = 1; ;) { + use(x); + } + for (const [y] = []; ;) { + use(y); + } + for (const {a: z} = { a: 1 }; ;) { + use(z); + } + use(x); + } + + function foo5() { + for (let x in []) { + use(x); + } + use(x); + } + + function foo6() { + for (const x in []) { + use(x); + } + use(x); + } + + // TODO: once for-of is supported downlevel + function foo7() { + for (let x of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } + use(x); + } + + function foo8() { + for (let [x] of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } + use(x); + } + + function foo9() { + for (let {a: x} of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } + use(x); + } + + function foo10() { + for (const x of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } + use(x); + } + + function foo11() { + for (const [x] of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } + use(x); + } + + function foo12() { + for (const {a: x} of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } + use(x); + } \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst16.js b/tests/baselines/reference/downlevelLetConst16.js new file mode 100644 index 0000000000000..36da8ac36fe6c --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst16.js @@ -0,0 +1,441 @@ +//// [downlevelLetConst16.ts] +'use strict' + +declare function use(a: any); + +var x = 10; +var y; +var z; +use(x); +use(y); +use(z); +function foo1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = {a: 1}; + use(z); +} + +function foo2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); +} + +class A { + m1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + m2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); + } + +} + +class B { + m1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + m2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + } +} + +function bar1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); +} + +function bar2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); +} + +module M1 { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); +} + +module M2 { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); +} + +module M3 { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + +} + +module M4 { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + use(y); + use(z); +} + +function foo3() { + for (let x; ;) { + use(x); + } + for (let [y] = []; ;) { + use(y); + } + for (let {a: z} = {a: 1}; ;) { + use(z); + } + use(x); +} + +function foo4() { + for (const x = 1; ;) { + use(x); + } + for (const [y] = []; ;) { + use(y); + } + for (const {a: z} = { a: 1 }; ;) { + use(z); + } + use(x); +} + +function foo5() { + for (let x in []) { + use(x); + } + use(x); +} + +function foo6() { + for (const x in []) { + use(x); + } + use(x); +} + +// TODO: once for-of is supported downlevel +function foo7() { + for (let x of []) { + use(x); + } + use(x); +} + +function foo8() { + for (let [x] of []) { + use(x); + } + use(x); +} + +function foo9() { + for (let {a: x} of []) { + use(x); + } + use(x); +} + +function foo10() { + for (const x of []) { + use(x); + } + use(x); +} + +function foo11() { + for (const [x] of []) { + use(x); + } + use(x); +} + +function foo12() { + for (const {a: x} of []) { + use(x); + } + use(x); +} + +//// [downlevelLetConst16.js] +'use strict'; +var x = 10; +var y; +var z; +use(x); +use(y); +use(z); +function foo1() { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); +} +function foo2() { + { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + } + use(x); +} +var A = (function () { + function A() { + } + A.prototype.m1 = function () { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + }; + A.prototype.m2 = function () { + { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + } + use(x); + }; + return A; +})(); +var B = (function () { + function B() { + } + B.prototype.m1 = function () { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + }; + B.prototype.m2 = function () { + { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + } + use(x); + }; + return B; +})(); +function bar1() { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); +} +function bar2() { + { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + } + use(x); +} +var M1; +(function (M1) { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); +})(M1 || (M1 = {})); +var M2; +(function (M2) { + { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + } + use(x); +})(M2 || (M2 = {})); +var M3; +(function (M3) { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); +})(M3 || (M3 = {})); +var M4; +(function (M4) { + { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + } + use(x); + use(y); + use(z); +})(M4 || (M4 = {})); +function foo3() { + for (var _x = void 0;;) { + use(_x); + } + for (var _y = ([])[0];;) { + use(_y); + } + for (var _z = ({ a: 1 }).a;;) { + use(_z); + } + use(x); +} +function foo4() { + for (var _x = 1;;) { + use(_x); + } + for (var _y = ([])[0];;) { + use(_y); + } + for (var _z = ({ a: 1 }).a;;) { + use(_z); + } + use(x); +} +function foo5() { + for (var _x in []) { + use(_x); + } + use(x); +} +function foo6() { + for (var _x in []) { + use(_x); + } + use(x); +} +// TODO: once for-of is supported downlevel +function foo7() { + for (var _x of []) { + use(_x); + } + use(x); +} +function foo8() { + for (var _x = (void 0)[0] of []) { + use(_x); + } + use(x); +} +function foo9() { + for (var _x = (void 0).a of []) { + use(_x); + } + use(x); +} +function foo10() { + for (var _x of []) { + use(_x); + } + use(x); +} +function foo11() { + for (var _x = (void 0)[0] of []) { + use(_x); + } + use(x); +} +function foo12() { + for (var _x = (void 0).a of []) { + use(_x); + } + use(x); +} diff --git a/tests/baselines/reference/downlevelLetConst17.errors.txt b/tests/baselines/reference/downlevelLetConst17.errors.txt new file mode 100644 index 0000000000000..a185ca4abe1e1 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst17.errors.txt @@ -0,0 +1,74 @@ +tests/cases/compiler/downlevelLetConst17.ts(66,1): error TS9003: 'for...of' statements are not currently supported. + + +==== tests/cases/compiler/downlevelLetConst17.ts (1 errors) ==== + 'use strict' + + declare function use(a: any); + + var x; + for (let x = 10; ;) { + use(x); + } + use(x); + + for (const x = 10; ;) { + use(x); + } + + for (; ;) { + let x = 10; + use(x); + x = 1; + } + + for (; ;) { + const x = 10; + use(x); + } + + for (let x; ;) { + use(x); + x = 1; + } + + for (; ;) { + let x; + use(x); + x = 1; + } + + while (true) { + let x; + use(x); + } + + while (true) { + const x = true; + use(x); + } + + do { + let x; + use(x); + } while (true); + + do { + let x; + use(x); + } while (true); + + for (let x in []) { + use(x); + } + + for (const x in []) { + use(x); + } + + // TODO: update once for-of statements are supported downlevel + for (const x of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst17.js b/tests/baselines/reference/downlevelLetConst17.js new file mode 100644 index 0000000000000..1fe9c1a01edf4 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst17.js @@ -0,0 +1,124 @@ +//// [downlevelLetConst17.ts] +'use strict' + +declare function use(a: any); + +var x; +for (let x = 10; ;) { + use(x); +} +use(x); + +for (const x = 10; ;) { + use(x); +} + +for (; ;) { + let x = 10; + use(x); + x = 1; +} + +for (; ;) { + const x = 10; + use(x); +} + +for (let x; ;) { + use(x); + x = 1; +} + +for (; ;) { + let x; + use(x); + x = 1; +} + +while (true) { + let x; + use(x); +} + +while (true) { + const x = true; + use(x); +} + +do { + let x; + use(x); +} while (true); + +do { + let x; + use(x); +} while (true); + +for (let x in []) { + use(x); +} + +for (const x in []) { + use(x); +} + +// TODO: update once for-of statements are supported downlevel +for (const x of []) { + use(x); +} + +//// [downlevelLetConst17.js] +'use strict'; +var x; +for (var _x = 10;;) { + use(_x); +} +use(x); +for (var _x_1 = 10;;) { + use(_x_1); +} +for (;;) { + var _x_2 = 10; + use(_x_2); + _x_2 = 1; +} +for (;;) { + var _x_3 = 10; + use(_x_3); +} +for (var _x_4 = void 0;;) { + use(_x_4); + _x_4 = 1; +} +for (;;) { + var _x_5 = void 0; + use(_x_5); + _x_5 = 1; +} +while (true) { + var _x_6 = void 0; + use(_x_6); +} +while (true) { + var _x_7 = true; + use(_x_7); +} +do { + var _x_8 = void 0; + use(_x_8); +} while (true); +do { + var _x_9 = void 0; + use(_x_9); +} while (true); +for (var _x_10 in []) { + use(_x_10); +} +for (var _x_11 in []) { + use(_x_11); +} +// TODO: update once for-of statements are supported downlevel +for (var _x_12 of []) { + use(_x_12); +} diff --git a/tests/baselines/reference/downlevelLetConst18.errors.txt b/tests/baselines/reference/downlevelLetConst18.errors.txt new file mode 100644 index 0000000000000..8f30b0f802a60 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst18.errors.txt @@ -0,0 +1,60 @@ +tests/cases/compiler/downlevelLetConst18.ts(3,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(4,14): error TS2393: Duplicate function implementation. +tests/cases/compiler/downlevelLetConst18.ts(7,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(8,14): error TS2393: Duplicate function implementation. +tests/cases/compiler/downlevelLetConst18.ts(11,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(15,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(19,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(23,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(27,1): error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. + + +==== tests/cases/compiler/downlevelLetConst18.ts (9 errors) ==== + 'use strict' + + for (let x; ;) { + ~~~ +!!! error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. + function foo() { x }; + ~~~ +!!! error TS2393: Duplicate function implementation. + } + + for (let x; ;) { + ~~~ +!!! error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. + function foo() { x }; + ~~~ +!!! error TS2393: Duplicate function implementation. + } + + for (let x; ;) { + ~~~ +!!! error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. + (() => { x })(); + } + + for (const x = 1; ;) { + ~~~ +!!! error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. + (() => { x })(); + } + + for (let x; ;) { + ~~~ +!!! error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. + ({ foo() { x }}) + } + + for (let x; ;) { + ~~~ +!!! error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. + ({ get foo() { return x } }) + } + + for (let x; ;) { + ~~~ +!!! error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. + ({ set foo(v) { x } }) + } + \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst18.js b/tests/baselines/reference/downlevelLetConst18.js new file mode 100644 index 0000000000000..e9993a90bce61 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst18.js @@ -0,0 +1,57 @@ +//// [downlevelLetConst18.ts] +'use strict' + +for (let x; ;) { + function foo() { x }; +} + +for (let x; ;) { + function foo() { x }; +} + +for (let x; ;) { + (() => { x })(); +} + +for (const x = 1; ;) { + (() => { x })(); +} + +for (let x; ;) { + ({ foo() { x }}) +} + +for (let x; ;) { + ({ get foo() { return x } }) +} + +for (let x; ;) { + ({ set foo(v) { x } }) +} + + +//// [downlevelLetConst18.js] +'use strict'; +for (var x = void 0;;) { + function foo() { x; } + ; +} +for (var _x = void 0;;) { + function foo() { _x; } + ; +} +for (var _x_1 = void 0;;) { + (function () { _x_1; })(); +} +for (var _x_2 = 1;;) { + (function () { _x_2; })(); +} +for (var _x_3 = void 0;;) { + ({ foo: function () { _x_3; } }); +} +for (var _x_4 = void 0;;) { + ({ get foo() { return _x_4; } }); +} +for (var _x_5 = void 0;;) { + ({ set foo(v) { _x_5; } }); +} diff --git a/tests/baselines/reference/downlevelLetConst2.errors.txt b/tests/baselines/reference/downlevelLetConst2.errors.txt new file mode 100644 index 0000000000000..9da0c94a12e3d --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst2.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/downlevelLetConst2.ts(1,7): error TS1155: 'const' declarations must be initialized + + +==== tests/cases/compiler/downlevelLetConst2.ts (1 errors) ==== + const a + ~ +!!! error TS1155: 'const' declarations must be initialized \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst2.js b/tests/baselines/reference/downlevelLetConst2.js new file mode 100644 index 0000000000000..a73688cd4afd6 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst2.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst2.ts] +const a + +//// [downlevelLetConst2.js] +var a; diff --git a/tests/baselines/reference/downlevelLetConst3.js b/tests/baselines/reference/downlevelLetConst3.js new file mode 100644 index 0000000000000..f6ef605c261dc --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst3.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst3.ts] +const a = 1 + +//// [downlevelLetConst3.js] +var a = 1; diff --git a/tests/baselines/reference/downlevelLetConst3.types b/tests/baselines/reference/downlevelLetConst3.types new file mode 100644 index 0000000000000..6cd3f85e074d4 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst3.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/downlevelLetConst3.ts === +const a = 1 +>a : number + diff --git a/tests/baselines/reference/downlevelLetConst4.errors.txt b/tests/baselines/reference/downlevelLetConst4.errors.txt new file mode 100644 index 0000000000000..3bf3e58ceccda --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst4.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/downlevelLetConst4.ts(1,7): error TS1155: 'const' declarations must be initialized + + +==== tests/cases/compiler/downlevelLetConst4.ts (1 errors) ==== + const a: number + ~ +!!! error TS1155: 'const' declarations must be initialized \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst4.js b/tests/baselines/reference/downlevelLetConst4.js new file mode 100644 index 0000000000000..725aa5cde8fbf --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst4.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst4.ts] +const a: number + +//// [downlevelLetConst4.js] +var a; diff --git a/tests/baselines/reference/downlevelLetConst5.js b/tests/baselines/reference/downlevelLetConst5.js new file mode 100644 index 0000000000000..271c71b682922 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst5.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst5.ts] +const a: number = 1 + +//// [downlevelLetConst5.js] +var a = 1; diff --git a/tests/baselines/reference/downlevelLetConst5.types b/tests/baselines/reference/downlevelLetConst5.types new file mode 100644 index 0000000000000..dd8cdf9fcddec --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst5.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/downlevelLetConst5.ts === +const a: number = 1 +>a : number + diff --git a/tests/baselines/reference/downlevelLetConst6.errors.txt b/tests/baselines/reference/downlevelLetConst6.errors.txt new file mode 100644 index 0000000000000..bad0674c5c412 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/downlevelLetConst6.ts(1,1): error TS2304: Cannot find name 'let'. + + +==== tests/cases/compiler/downlevelLetConst6.ts (1 errors) ==== + let + ~~~ +!!! error TS2304: Cannot find name 'let'. \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst6.js b/tests/baselines/reference/downlevelLetConst6.js new file mode 100644 index 0000000000000..2a1aea002d932 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst6.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst6.ts] +let + +//// [downlevelLetConst6.js] +let; diff --git a/tests/baselines/reference/downlevelLetConst7.js b/tests/baselines/reference/downlevelLetConst7.js new file mode 100644 index 0000000000000..6020ddf247953 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst7.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst7.ts] +let a + +//// [downlevelLetConst7.js] +var a; diff --git a/tests/baselines/reference/downlevelLetConst7.types b/tests/baselines/reference/downlevelLetConst7.types new file mode 100644 index 0000000000000..9c76479ecf50b --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst7.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/downlevelLetConst7.ts === +let a +>a : any + diff --git a/tests/baselines/reference/downlevelLetConst8.js b/tests/baselines/reference/downlevelLetConst8.js new file mode 100644 index 0000000000000..5cc548c1361a7 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst8.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst8.ts] +let a = 1 + +//// [downlevelLetConst8.js] +var a = 1; diff --git a/tests/baselines/reference/downlevelLetConst8.types b/tests/baselines/reference/downlevelLetConst8.types new file mode 100644 index 0000000000000..a3b9986bbc857 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst8.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/downlevelLetConst8.ts === +let a = 1 +>a : number + diff --git a/tests/baselines/reference/downlevelLetConst9.js b/tests/baselines/reference/downlevelLetConst9.js new file mode 100644 index 0000000000000..c6bcfe27a8a26 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst9.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst9.ts] +let a: number + +//// [downlevelLetConst9.js] +var a; diff --git a/tests/baselines/reference/downlevelLetConst9.types b/tests/baselines/reference/downlevelLetConst9.types new file mode 100644 index 0000000000000..cab9ac82a6058 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst9.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/downlevelLetConst9.ts === +let a: number +>a : number + diff --git a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline index 8dc9355bca27c..9e2e9978f469d 100644 --- a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline @@ -1,5 +1,5 @@ EmitSkipped: false FileName : tests/cases/fourslash/inputFile1.js // File contains early errors. All outputs should be skipped. -const uninitialized_const_error; +var uninitialized_const_error; diff --git a/tests/baselines/reference/letAsIdentifierInStrictMode.js b/tests/baselines/reference/letAsIdentifierInStrictMode.js index e844bc1d1dcae..ccf099bcfc4ba 100644 --- a/tests/baselines/reference/letAsIdentifierInStrictMode.js +++ b/tests/baselines/reference/letAsIdentifierInStrictMode.js @@ -9,9 +9,9 @@ a; //// [letAsIdentifierInStrictMode.js] "use strict"; var ; -let ; +var ; 10; var a = 10; -let ; +var ; 30; -let a; +var a; diff --git a/tests/baselines/reference/letDeclarations-es5-1.errors.txt b/tests/baselines/reference/letDeclarations-es5-1.errors.txt deleted file mode 100644 index f8b5cf629d26d..0000000000000 --- a/tests/baselines/reference/letDeclarations-es5-1.errors.txt +++ /dev/null @@ -1,27 +0,0 @@ -tests/cases/compiler/letDeclarations-es5-1.ts(1,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5-1.ts(2,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5-1.ts(3,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5-1.ts(4,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5-1.ts(5,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5-1.ts(6,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/compiler/letDeclarations-es5-1.ts (6 errors) ==== - let l1; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l2: number; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l3, l4, l5 :string, l6; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l7 = false; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l8: number = 23; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l9 = 0, l10 :string = "", l11 = null; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/letDeclarations-es5-1.js b/tests/baselines/reference/letDeclarations-es5-1.js index 24c2c62e58fa7..35439c5966d0c 100644 --- a/tests/baselines/reference/letDeclarations-es5-1.js +++ b/tests/baselines/reference/letDeclarations-es5-1.js @@ -7,9 +7,9 @@ let l9 = 0, l10 :string = "", l11 = null; //// [letDeclarations-es5-1.js] -let l1; -let l2; -let l3, l4, l5, l6; -let l7 = false; -let l8 = 23; -let l9 = 0, l10 = "", l11 = null; +var l1; +var l2; +var l3, l4, l5, l6; +var l7 = false; +var l8 = 23; +var l9 = 0, l10 = "", l11 = null; diff --git a/tests/baselines/reference/letDeclarations-es5-1.types b/tests/baselines/reference/letDeclarations-es5-1.types new file mode 100644 index 0000000000000..fb45d521bd358 --- /dev/null +++ b/tests/baselines/reference/letDeclarations-es5-1.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/letDeclarations-es5-1.ts === + let l1; +>l1 : any + + let l2: number; +>l2 : number + + let l3, l4, l5 :string, l6; +>l3 : any +>l4 : any +>l5 : string +>l6 : any + + let l7 = false; +>l7 : boolean + + let l8: number = 23; +>l8 : number + + let l9 = 0, l10 :string = "", l11 = null; +>l9 : number +>l10 : string +>l11 : any + diff --git a/tests/baselines/reference/letDeclarations-es5.errors.txt b/tests/baselines/reference/letDeclarations-es5.errors.txt deleted file mode 100644 index 27d526f03eae7..0000000000000 --- a/tests/baselines/reference/letDeclarations-es5.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -tests/cases/compiler/letDeclarations-es5.ts(2,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(3,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(4,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(6,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(7,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(8,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(10,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(12,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/compiler/letDeclarations-es5.ts (8 errors) ==== - - let l1; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l2: number; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l3, l4, l5 :string, l6; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - let l7 = false; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l8: number = 23; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l9 = 0, l10 :string = "", l11 = null; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - for(let l11 in {}) { } - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - for(let l12 = 0; l12 < 9; l12++) { } - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - \ No newline at end of file diff --git a/tests/baselines/reference/letDeclarations-es5.js b/tests/baselines/reference/letDeclarations-es5.js index 4d2f5423ee0bd..4ad43d52f769d 100644 --- a/tests/baselines/reference/letDeclarations-es5.js +++ b/tests/baselines/reference/letDeclarations-es5.js @@ -14,11 +14,11 @@ for(let l12 = 0; l12 < 9; l12++) { } //// [letDeclarations-es5.js] -let l1; -let l2; -let l3, l4, l5, l6; -let l7 = false; -let l8 = 23; -let l9 = 0, l10 = "", l11 = null; -for (let l11 in {}) { } -for (let l12 = 0; l12 < 9; l12++) { } +var l1; +var l2; +var l3, l4, l5, l6; +var l7 = false; +var l8 = 23; +var l9 = 0, l10 = "", l11 = null; +for (var _l11 in {}) { } +for (var l12 = 0; l12 < 9; l12++) { } diff --git a/tests/baselines/reference/letDeclarations-es5.types b/tests/baselines/reference/letDeclarations-es5.types new file mode 100644 index 0000000000000..0d6e992886848 --- /dev/null +++ b/tests/baselines/reference/letDeclarations-es5.types @@ -0,0 +1,36 @@ +=== tests/cases/compiler/letDeclarations-es5.ts === + +let l1; +>l1 : any + +let l2: number; +>l2 : number + +let l3, l4, l5 :string, l6; +>l3 : any +>l4 : any +>l5 : string +>l6 : any + +let l7 = false; +>l7 : boolean + +let l8: number = 23; +>l8 : number + +let l9 = 0, l10 :string = "", l11 = null; +>l9 : number +>l10 : string +>l11 : any + +for(let l11 in {}) { } +>l11 : any +>{} : {} + +for(let l12 = 0; l12 < 9; l12++) { } +>l12 : number +>l12 < 9 : boolean +>l12 : number +>l12++ : number +>l12 : number + diff --git a/tests/baselines/reference/parserES5ForOfStatement13.js b/tests/baselines/reference/parserES5ForOfStatement13.js index 89706613add3d..3fac359c675b4 100644 --- a/tests/baselines/reference/parserES5ForOfStatement13.js +++ b/tests/baselines/reference/parserES5ForOfStatement13.js @@ -3,5 +3,5 @@ for (let {a, b} of X) { } //// [parserES5ForOfStatement13.js] -for (let _a = void 0, a = _a.a, b = _a.b of X) { +for (var _a = void 0, a = _a.a, b = _a.b of X) { } diff --git a/tests/baselines/reference/parserES5ForOfStatement14.js b/tests/baselines/reference/parserES5ForOfStatement14.js index 96aa327a62563..6d1fbbddd67bf 100644 --- a/tests/baselines/reference/parserES5ForOfStatement14.js +++ b/tests/baselines/reference/parserES5ForOfStatement14.js @@ -3,5 +3,5 @@ for (let [a, b] of X) { } //// [parserES5ForOfStatement14.js] -for (let _a = void 0, a = _a[0], b = _a[1] of X) { +for (var _a = void 0, a = _a[0], b = _a[1] of X) { } diff --git a/tests/baselines/reference/parserES5ForOfStatement9.js b/tests/baselines/reference/parserES5ForOfStatement9.js index e2ec49e9ac93f..856dd5982af77 100644 --- a/tests/baselines/reference/parserES5ForOfStatement9.js +++ b/tests/baselines/reference/parserES5ForOfStatement9.js @@ -3,5 +3,5 @@ for (let v of X) { } //// [parserES5ForOfStatement9.js] -for (let v of X) { +for (var v of X) { } diff --git a/tests/baselines/reference/parserForOfStatement10.js b/tests/baselines/reference/parserForOfStatement10.js index d0b482030900a..4d77c16388d25 100644 --- a/tests/baselines/reference/parserForOfStatement10.js +++ b/tests/baselines/reference/parserForOfStatement10.js @@ -3,5 +3,5 @@ for (const v of X) { } //// [parserForOfStatement10.js] -for (var v of X) { +for (const v of X) { } diff --git a/tests/baselines/reference/parserForOfStatement11.js b/tests/baselines/reference/parserForOfStatement11.js index daa3fb6df4883..5189f9e64af79 100644 --- a/tests/baselines/reference/parserForOfStatement11.js +++ b/tests/baselines/reference/parserForOfStatement11.js @@ -3,5 +3,5 @@ for (const [a, b] of X) { } //// [parserForOfStatement11.js] -for (var [a, b] of X) { +for (const [a, b] of X) { } diff --git a/tests/baselines/reference/parserForOfStatement12.js b/tests/baselines/reference/parserForOfStatement12.js index 2e62b90de5e4c..f27c8f41bd018 100644 --- a/tests/baselines/reference/parserForOfStatement12.js +++ b/tests/baselines/reference/parserForOfStatement12.js @@ -3,5 +3,5 @@ for (const {a, b} of X) { } //// [parserForOfStatement12.js] -for (var { a, b } of X) { +for (const { a, b } of X) { } diff --git a/tests/baselines/reference/shadowingViaLocalValue.errors.txt b/tests/baselines/reference/shadowingViaLocalValue.errors.txt index 8e6f16b91ccf5..67ab72ed22c5f 100644 --- a/tests/baselines/reference/shadowingViaLocalValue.errors.txt +++ b/tests/baselines/reference/shadowingViaLocalValue.errors.txt @@ -1,14 +1,10 @@ -tests/cases/compiler/shadowingViaLocalValue.ts(2,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. tests/cases/compiler/shadowingViaLocalValue.ts(4,13): error TS2481: Cannot initialize outer scoped variable 'x' in the same scope as block scoped declaration 'x'. -tests/cases/compiler/shadowingViaLocalValue.ts(9,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. tests/cases/compiler/shadowingViaLocalValue.ts(11,18): error TS2481: Cannot initialize outer scoped variable 'x1' in the same scope as block scoped declaration 'x1'. -==== tests/cases/compiler/shadowingViaLocalValue.ts (4 errors) ==== +==== tests/cases/compiler/shadowingViaLocalValue.ts (2 errors) ==== { let x; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. { var x = 1; ~ @@ -18,8 +14,6 @@ tests/cases/compiler/shadowingViaLocalValue.ts(11,18): error TS2481: Cannot init { let x1; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. { for (var x1 = 0; ;); ~~ diff --git a/tests/baselines/reference/shadowingViaLocalValue.js b/tests/baselines/reference/shadowingViaLocalValue.js index f99a209f0deda..e788caf5720c1 100644 --- a/tests/baselines/reference/shadowingViaLocalValue.js +++ b/tests/baselines/reference/shadowingViaLocalValue.js @@ -17,13 +17,13 @@ //// [shadowingViaLocalValue.js] { - let x; + var _x; { var x = 1; } } { - let x1; + var _x1; { for (var x1 = 0;;) ; diff --git a/tests/cases/compiler/constDeclarations-errors.ts b/tests/cases/compiler/constDeclarations-errors.ts index 09dc0e9679068..1c3ef8848b0b9 100644 --- a/tests/cases/compiler/constDeclarations-errors.ts +++ b/tests/cases/compiler/constDeclarations-errors.ts @@ -5,7 +5,6 @@ const c1; const c2: number; const c3, c4, c5 :string, c6; // error, missing initialicer -// error, can not be unintalized for(const c in {}) { } // error, assigning to a const diff --git a/tests/cases/compiler/downlevelLetConst1.ts b/tests/cases/compiler/downlevelLetConst1.ts new file mode 100644 index 0000000000000..8baacf4ea5443 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst1.ts @@ -0,0 +1 @@ +const \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst10.ts b/tests/cases/compiler/downlevelLetConst10.ts new file mode 100644 index 0000000000000..2b6e9657ef13f --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst10.ts @@ -0,0 +1 @@ +let a: number = 1 \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst11.ts b/tests/cases/compiler/downlevelLetConst11.ts new file mode 100644 index 0000000000000..aca60708232d9 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst11.ts @@ -0,0 +1,2 @@ +"use strict"; +let \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst12.ts b/tests/cases/compiler/downlevelLetConst12.ts new file mode 100644 index 0000000000000..5acefcdf7bf49 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst12.ts @@ -0,0 +1,12 @@ +// @target:es5 + +'use strict' +// top level let\const should not be renamed +let foo; +const bar = 1; + +let [baz] = []; +let {a: baz2} = { a: 1 }; + +const [baz3] = [] +const {a: baz4} = { a: 1 }; \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst13.ts b/tests/cases/compiler/downlevelLetConst13.ts new file mode 100644 index 0000000000000..af803e079bc3f --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst13.ts @@ -0,0 +1,21 @@ +// @target:es5 +// @module: commonjs + +'use strict' +// exported let\const bindings should not be renamed + +export let foo = 10; +export const bar = "123" +export let [bar1] = [1]; +export const [bar2] = [2]; +export let {a: bar3} = { a: 1 }; +export const {a: bar4} = { a: 1 }; + +export module M { + export let baz = 100; + export const baz2 = true; + export let [bar5] = [1]; + export const [bar6] = [2]; + export let {a: bar7} = { a: 1 }; + export const {a: bar8} = { a: 1 }; +} \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst14.ts b/tests/cases/compiler/downlevelLetConst14.ts new file mode 100644 index 0000000000000..0a77883809618 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst14.ts @@ -0,0 +1,55 @@ +// @target:es5 +'use strict' +declare function use(a: any); + +var x = 10; +var z0, z1, z2, z3; +{ + let x = 20; + use(x); + + let [z0] = [1]; + use(z0); + let [z1] = [1] + use(z1); + let {a: z2} = { a: 1 }; + use(z2); + let {a: z3} = { a: 1 }; + use(z3); +} +use(x); +use(z0); +use(z1); +use(z2); +use(z3); +var z6; +var y = true; +{ + let y = ""; + let [z6] = [true] + { + let y = 1; + let {a: z6} = {a: 1} + use(y); + use(z6); + } + use(y); + use(z6); +} +use(y); +use(z6); + +var z = false; +var z5 = 1; +{ + let z = ""; + let [z5] = [5]; + { + let _z = 1; + let {a: _z5} = { a: 1 }; + // try to step on generated name + use(_z); + } + use(z); +} +use(y); \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst15.ts b/tests/cases/compiler/downlevelLetConst15.ts new file mode 100644 index 0000000000000..abe06e1709bd9 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst15.ts @@ -0,0 +1,55 @@ +// @target:es5 +'use strict' +declare function use(a: any); + +var x = 10; +var z0, z1, z2, z3; +{ + const x = 20; + use(x); + + const [z0] = [1]; + use(z0); + const [{a: z1}] = [{a: 1}] + use(z1); + const {a: z2} = { a: 1 }; + use(z2); + const {a: {b: z3}} = { a: {b: 1} }; + use(z3); +} +use(x); +use(z0); +use(z1); +use(z2); +use(z3); +var z6; +var y = true; +{ + const y = ""; + const [z6] = [true] + { + const y = 1; + const {a: z6} = { a: 1 } + use(y); + use(z6); + } + use(y); + use(z6); +} +use(y); +use(z6); + +var z = false; +var z5 = 1; +{ + const z = ""; + const [z5] = [5]; + { + const _z = 1; + const {a: _z5} = { a: 1 }; + // try to step on generated name + use(_z); + } + use(z); +} +use(y); \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst16.ts b/tests/cases/compiler/downlevelLetConst16.ts new file mode 100644 index 0000000000000..2d592d253c9ff --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst16.ts @@ -0,0 +1,229 @@ +// @target:es5 +'use strict' + +declare function use(a: any); + +var x = 10; +var y; +var z; +use(x); +use(y); +use(z); +function foo1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = {a: 1}; + use(z); +} + +function foo2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); +} + +class A { + m1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + m2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); + } + +} + +class B { + m1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + m2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + } +} + +function bar1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); +} + +function bar2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); +} + +module M1 { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); +} + +module M2 { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); +} + +module M3 { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + +} + +module M4 { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + use(y); + use(z); +} + +function foo3() { + for (let x; ;) { + use(x); + } + for (let [y] = []; ;) { + use(y); + } + for (let {a: z} = {a: 1}; ;) { + use(z); + } + use(x); +} + +function foo4() { + for (const x = 1; ;) { + use(x); + } + for (const [y] = []; ;) { + use(y); + } + for (const {a: z} = { a: 1 }; ;) { + use(z); + } + use(x); +} + +function foo5() { + for (let x in []) { + use(x); + } + use(x); +} + +function foo6() { + for (const x in []) { + use(x); + } + use(x); +} + +// TODO: once for-of is supported downlevel +function foo7() { + for (let x of []) { + use(x); + } + use(x); +} + +function foo8() { + for (let [x] of []) { + use(x); + } + use(x); +} + +function foo9() { + for (let {a: x} of []) { + use(x); + } + use(x); +} + +function foo10() { + for (const x of []) { + use(x); + } + use(x); +} + +function foo11() { + for (const [x] of []) { + use(x); + } + use(x); +} + +function foo12() { + for (const {a: x} of []) { + use(x); + } + use(x); +} \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst17.ts b/tests/cases/compiler/downlevelLetConst17.ts new file mode 100644 index 0000000000000..5cbb7b605fee5 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst17.ts @@ -0,0 +1,69 @@ +// @target:es5 +'use strict' + +declare function use(a: any); + +var x; +for (let x = 10; ;) { + use(x); +} +use(x); + +for (const x = 10; ;) { + use(x); +} + +for (; ;) { + let x = 10; + use(x); + x = 1; +} + +for (; ;) { + const x = 10; + use(x); +} + +for (let x; ;) { + use(x); + x = 1; +} + +for (; ;) { + let x; + use(x); + x = 1; +} + +while (true) { + let x; + use(x); +} + +while (true) { + const x = true; + use(x); +} + +do { + let x; + use(x); +} while (true); + +do { + let x; + use(x); +} while (true); + +for (let x in []) { + use(x); +} + +for (const x in []) { + use(x); +} + +// TODO: update once for-of statements are supported downlevel +for (const x of []) { + use(x); +} \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst18.ts b/tests/cases/compiler/downlevelLetConst18.ts new file mode 100644 index 0000000000000..59f2ee7a46ee3 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst18.ts @@ -0,0 +1,30 @@ +// @target:es5 +'use strict' + +for (let x; ;) { + function foo() { x }; +} + +for (let x; ;) { + function foo() { x }; +} + +for (let x; ;) { + (() => { x })(); +} + +for (const x = 1; ;) { + (() => { x })(); +} + +for (let x; ;) { + ({ foo() { x }}) +} + +for (let x; ;) { + ({ get foo() { return x } }) +} + +for (let x; ;) { + ({ set foo(v) { x } }) +} diff --git a/tests/cases/compiler/downlevelLetConst2.ts b/tests/cases/compiler/downlevelLetConst2.ts new file mode 100644 index 0000000000000..06871c9a45c00 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst2.ts @@ -0,0 +1 @@ +const a \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst3.ts b/tests/cases/compiler/downlevelLetConst3.ts new file mode 100644 index 0000000000000..6779cd775c017 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst3.ts @@ -0,0 +1 @@ +const a = 1 \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst4.ts b/tests/cases/compiler/downlevelLetConst4.ts new file mode 100644 index 0000000000000..f96229b7eaffa --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst4.ts @@ -0,0 +1 @@ +const a: number \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst5.ts b/tests/cases/compiler/downlevelLetConst5.ts new file mode 100644 index 0000000000000..4a05e895a3cd4 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst5.ts @@ -0,0 +1 @@ +const a: number = 1 \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst6.ts b/tests/cases/compiler/downlevelLetConst6.ts new file mode 100644 index 0000000000000..33ae002d85961 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst6.ts @@ -0,0 +1 @@ +let \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst7.ts b/tests/cases/compiler/downlevelLetConst7.ts new file mode 100644 index 0000000000000..7350ac02e70c8 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst7.ts @@ -0,0 +1 @@ +let a \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst8.ts b/tests/cases/compiler/downlevelLetConst8.ts new file mode 100644 index 0000000000000..067c6699cfd7e --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst8.ts @@ -0,0 +1 @@ +let a = 1 \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst9.ts b/tests/cases/compiler/downlevelLetConst9.ts new file mode 100644 index 0000000000000..aab3d49c18cc1 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst9.ts @@ -0,0 +1 @@ +let a: number \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts index 2b6e9657ef13f..9e02b6de034ae 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts @@ -1 +1,2 @@ +// @target:es6 let a: number = 1 \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts index aca60708232d9..0de0f085a8af3 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts @@ -1,2 +1,3 @@ +// @target:es6 "use strict"; let \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration1_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration1_es6.ts index 8baacf4ea5443..27157193b2408 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration1_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration1_es6.ts @@ -1 +1,2 @@ +// @target:es6 const \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts index 06871c9a45c00..17986424b1334 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts @@ -1 +1,2 @@ +// @target:es6 const a \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts index 6779cd775c017..cd1b75836e5c1 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts @@ -1 +1,2 @@ +// @target:es6 const a = 1 \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts index f96229b7eaffa..e40c7b152838d 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts @@ -1 +1,2 @@ +// @target:es6 const a: number \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts index 4a05e895a3cd4..52738ea2f07e4 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts @@ -1 +1,2 @@ +// @target:es6 const a: number = 1 \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration6_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration6_es6.ts index 33ae002d85961..5fbd509be7615 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration6_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration6_es6.ts @@ -1 +1,2 @@ +// @target:es6 let \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts index 7350ac02e70c8..14f4b4834131a 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts @@ -1 +1,2 @@ +// @target:es6 let a \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts index 067c6699cfd7e..2bab0e1a1a434 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts @@ -1 +1,2 @@ +// @target:es6 let a = 1 \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts index aab3d49c18cc1..db3cd38806a83 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts @@ -1 +1,2 @@ +// @target:es6 let a: number \ No newline at end of file