Merge branch 'master' of https://github.com/Microsoft/TypeScript into for-ofES6

Conflicts:
	src/compiler/checker.ts
	tests/baselines/reference/constDeclarations-errors.errors.txt
This commit is contained in:
Jason Freeman
2015-02-28 16:30:10 -08:00
123 changed files with 3127 additions and 341 deletions
+16 -2
View File
@@ -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);
+100 -29
View File
@@ -746,7 +746,10 @@ module ts {
forEach(symbol.declarations, node => {
if (node.kind === SyntaxKind.SourceFile || node.kind === SyntaxKind.ModuleDeclaration) {
forEach((<ExportContainer>node).exportStars, exportStar => {
visit(resolveExternalModuleName(exportStar, exportStar.moduleSpecifier));
var moduleSymbol = resolveExternalModuleName(exportStar, exportStar.moduleSpecifier);
if (moduleSymbol) {
visit(moduleSymbol);
}
});
}
});
@@ -5079,10 +5082,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(<VariableDeclaration>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;
@@ -10631,25 +10687,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) {
@@ -10850,6 +10889,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 &&
(<PropertyAccessExpression>n.parent).name === n) {
return undefined;
}
// ignore property names in object binding patterns
if (n.parent.kind === SyntaxKind.BindingElement &&
(<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 && (<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,
@@ -10866,6 +10945,7 @@ module ts {
isEntityNameVisible,
getConstantValue,
isUnknownIdentifier,
getBlockScopedVariableId,
};
}
@@ -11642,15 +11722,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 {
@@ -404,6 +404,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}" },
+4
View File
@@ -1609,6 +1609,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
+231 -66
View File
@@ -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<string>;
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<string>;
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 = <Identifier>createNode(SyntaxKind.Identifier);
var result = <Identifier>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 = <SynthesizedNode>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) && (<SynthesizedNode>node).startsOnNewLine;
return nodeIsSynthesized(node) && (<SynthesizedNode>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 = <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 = <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 = <LiteralExpression>createSynthesizedNode(SyntaxKind.NumericLiteral);
zero.text = "0";
var result = <VoidExpression>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(<Declaration>name.parent);
}
@@ -3534,24 +3602,16 @@ module ts {
return expr;
}
function createVoidZero(): Expression {
var zero = <LiteralExpression>createNode(SyntaxKind.NumericLiteral);
zero.text = "0";
var result = <VoidExpression>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 = <BinaryExpression>createNode(SyntaxKind.BinaryExpression);
var equals = <BinaryExpression>createSynthesizedNode(SyntaxKind.BinaryExpression);
equals.left = value;
equals.operatorToken = createNode(SyntaxKind.EqualsEqualsEqualsToken);
equals.operatorToken = createSynthesizedNode(SyntaxKind.EqualsEqualsEqualsToken);
equals.right = createVoidZero();
var cond = <ConditionalExpression>createNode(SyntaxKind.ConditionalExpression);
var cond = <ConditionalExpression>createSynthesizedNode(SyntaxKind.ConditionalExpression);
cond.condition = equals;
cond.whenTrue = defaultValue;
cond.whenFalse = value;
@@ -3559,7 +3619,7 @@ module ts {
}
function createNumericLiteral(value: number) {
var node = <LiteralExpression>createNode(SyntaxKind.NumericLiteral);
var node = <LiteralExpression>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 <LeftHandSideExpression>expr;
}
var node = <ParenthesizedExpression>createNode(SyntaxKind.ParenthesizedExpression);
var node = <ParenthesizedExpression>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 = <PropertyAccessExpression>createNode(SyntaxKind.PropertyAccessExpression);
var node = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
node.expression = parenthesizeForAccess(object);
node.name = propName;
return node;
}
function createElementAccess(object: Expression, index: Expression): Expression {
var node = <ElementAccessExpression>createNode(SyntaxKind.ElementAccessExpression);
var node = <ElementAccessExpression>createSynthesizedNode(SyntaxKind.ElementAccessExpression);
node.expression = parenthesizeForAccess(object);
node.argumentExpression = index;
return node;
@@ -3723,8 +3783,31 @@ module ts {
}
}
else {
var isLet = renameNonTopLevelLetAndConst(<Identifier>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 <some-uniqie-name> = 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(<Identifier>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((<BindingPattern>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(<Identifier>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, (<Identifier>node).text);
var variableId = resolver.getBlockScopedVariableId(<Identifier>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 && !(<ConstructorDeclaration>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;
}
+2
View File
@@ -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 {
+44 -1
View File
@@ -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 = <SynthesizedNode>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<Diagnostic[]> = {};
+121 -14
View File
@@ -1795,33 +1795,140 @@ module ts {
});
}
function recordModuleName() {
var importPath = scanner.getTokenValue();
var pos = scanner.getTokenPos();
importedFiles.push({
fileName: importPath,
pos: pos,
end: pos + importPath.length
});
}
function processImport(): void {
scanner.setText(sourceText);
var token = scanner.scan();
// Look for:
// import foo = module("foo");
// import "mod";
// import d from "mod"
// import {a as A } from "mod";
// import * as NS from "mod"
// import d, {a, b as B} from "mod"
// import i = require("mod");
//
// export * from "mod"
// export {a as b} from "mod"
while (token !== SyntaxKind.EndOfFileToken) {
if (token === SyntaxKind.ImportKeyword) {
token = scanner.scan();
if (token === SyntaxKind.Identifier) {
token = scanner.scan();
if (token === SyntaxKind.EqualsToken) {
if (token === SyntaxKind.StringLiteral) {
// import "mod";
recordModuleName();
continue;
}
else {
if (token === SyntaxKind.Identifier) {
token = scanner.scan();
if (token === SyntaxKind.RequireKeyword) {
if (token === SyntaxKind.FromKeyword) {
token = scanner.scan();
if (token === SyntaxKind.OpenParenToken) {
if (token === SyntaxKind.StringLiteral) {
// import d from "mod";
recordModuleName();
continue
}
}
else if (token === SyntaxKind.EqualsToken) {
token = scanner.scan();
if (token === SyntaxKind.RequireKeyword) {
token = scanner.scan();
if (token === SyntaxKind.StringLiteral) {
var importPath = scanner.getTokenValue();
var pos = scanner.getTokenPos();
importedFiles.push({
fileName: importPath,
pos: pos,
end: pos + importPath.length
});
if (token === SyntaxKind.OpenParenToken) {
token = scanner.scan();
if (token === SyntaxKind.StringLiteral) {
// import i = require("mod");
recordModuleName();
continue;
}
}
}
}
else if (token === SyntaxKind.CommaToken) {
// consume comma and keep going
token = scanner.scan();
}
else {
// unknown syntax
continue;
}
}
if (token === SyntaxKind.OpenBraceToken) {
token = scanner.scan();
// consume "{ a as B, c, d as D}" clauses
while (token !== SyntaxKind.CloseBraceToken) {
token = scanner.scan();
}
if (token === SyntaxKind.CloseBraceToken) {
token = scanner.scan();
if (token === SyntaxKind.FromKeyword) {
token = scanner.scan();
if (token === SyntaxKind.StringLiteral) {
// import {a as A} from "mod";
// import d, {a, b as B} from "mod"
recordModuleName();
}
}
}
}
else if (token === SyntaxKind.AsteriskToken) {
token = scanner.scan();
if (token === SyntaxKind.AsKeyword) {
token = scanner.scan();
if (token === SyntaxKind.Identifier) {
token = scanner.scan();
if (token === SyntaxKind.FromKeyword) {
token = scanner.scan();
if (token === SyntaxKind.StringLiteral) {
// import * as NS from "mod"
// import d, * as NS from "mod"
recordModuleName();
}
}
}
}
}
}
}
else if (token === SyntaxKind.ExportKeyword) {
token = scanner.scan();
if (token === SyntaxKind.OpenBraceToken) {
token = scanner.scan();
// consume "{ a as B, c, d as D}" clauses
while (token !== SyntaxKind.CloseBraceToken) {
token = scanner.scan();
}
if (token === SyntaxKind.CloseBraceToken) {
token = scanner.scan();
if (token === SyntaxKind.FromKeyword) {
token = scanner.scan();
if (token === SyntaxKind.StringLiteral) {
// export {a as A} from "mod";
// export {a, b as B} from "mod"
recordModuleName();
}
}
}
}
else if (token === SyntaxKind.AsteriskToken) {
token = scanner.scan();
if (token === SyntaxKind.FromKeyword) {
token = scanner.scan();
if (token === SyntaxKind.StringLiteral) {
// export * from "mod"
recordModuleName();
}
}
}
}
@@ -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;
@@ -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
@@ -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;
@@ -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
@@ -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;
@@ -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
@@ -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;
@@ -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
@@ -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.
@@ -0,0 +1,4 @@
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts ===
let a: number = 1
>a : number
@@ -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
@@ -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.
@@ -0,0 +1,4 @@
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts ===
const a = 1
>a : number
@@ -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
@@ -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.
@@ -0,0 +1,4 @@
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts ===
const a: number = 1
>a : number
@@ -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.
@@ -0,0 +1,4 @@
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts ===
let a
>a : any
@@ -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.
@@ -0,0 +1,4 @@
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts ===
let a = 1
>a : number
@@ -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.
@@ -0,0 +1,4 @@
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts ===
let a: number
>a : number
@@ -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"}
{"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"}
@@ -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
@@ -4,9 +4,9 @@ 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(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 (9 errors) ====
@@ -28,7 +28,6 @@ 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, assigning to a const
@@ -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
@@ -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.
@@ -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;
@@ -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
@@ -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.
@@ -0,0 +1,5 @@
//// [downlevelLetConst1.ts]
const
//// [downlevelLetConst1.js]
var ;
@@ -0,0 +1,5 @@
//// [downlevelLetConst10.ts]
let a: number = 1
//// [downlevelLetConst10.js]
var a = 1;
@@ -0,0 +1,4 @@
=== tests/cases/compiler/downlevelLetConst10.ts ===
let a: number = 1
>a : number
@@ -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.
@@ -0,0 +1,7 @@
//// [downlevelLetConst11.ts]
"use strict";
let
//// [downlevelLetConst11.js]
"use strict";
var ;
@@ -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;
@@ -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
@@ -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 = {}));
@@ -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
}
@@ -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);
@@ -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
@@ -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);
@@ -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
@@ -0,0 +1,249 @@
tests/cases/compiler/downlevelLetConst16.ts(189,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(196,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(203,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(210,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(217,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
tests/cases/compiler/downlevelLetConst16.ts(224,5): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== 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 TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
use(x);
}
use(x);
}
function foo8() {
for (let [x] of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
use(x);
}
use(x);
}
function foo9() {
for (let {a: x} of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
use(x);
}
use(x);
}
function foo10() {
for (const x of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
use(x);
}
use(x);
}
function foo11() {
for (const [x] of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
use(x);
}
use(x);
}
function foo12() {
for (const {a: x} of []) {
~~~
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
use(x);
}
use(x);
}
@@ -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);
}
@@ -0,0 +1,74 @@
tests/cases/compiler/downlevelLetConst17.ts(66,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
==== 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 TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
use(x);
}
@@ -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);
}
@@ -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 } })
}
@@ -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; } });
}
@@ -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
@@ -0,0 +1,5 @@
//// [downlevelLetConst2.ts]
const a
//// [downlevelLetConst2.js]
var a;
@@ -0,0 +1,5 @@
//// [downlevelLetConst3.ts]
const a = 1
//// [downlevelLetConst3.js]
var a = 1;
@@ -0,0 +1,4 @@
=== tests/cases/compiler/downlevelLetConst3.ts ===
const a = 1
>a : number
@@ -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
@@ -0,0 +1,5 @@
//// [downlevelLetConst4.ts]
const a: number
//// [downlevelLetConst4.js]
var a;
@@ -0,0 +1,5 @@
//// [downlevelLetConst5.ts]
const a: number = 1
//// [downlevelLetConst5.js]
var a = 1;
@@ -0,0 +1,4 @@
=== tests/cases/compiler/downlevelLetConst5.ts ===
const a: number = 1
>a : number
@@ -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'.
@@ -0,0 +1,5 @@
//// [downlevelLetConst6.ts]
let
//// [downlevelLetConst6.js]
let;
@@ -0,0 +1,5 @@
//// [downlevelLetConst7.ts]
let a
//// [downlevelLetConst7.js]
var a;
@@ -0,0 +1,4 @@
=== tests/cases/compiler/downlevelLetConst7.ts ===
let a
>a : any
@@ -0,0 +1,5 @@
//// [downlevelLetConst8.ts]
let a = 1
//// [downlevelLetConst8.js]
var a = 1;
@@ -0,0 +1,4 @@
=== tests/cases/compiler/downlevelLetConst8.ts ===
let a = 1
>a : number
@@ -0,0 +1,5 @@
//// [downlevelLetConst9.ts]
let a: number
//// [downlevelLetConst9.js]
var a;
@@ -0,0 +1,4 @@
=== tests/cases/compiler/downlevelLetConst9.ts ===
let a: number
>a : number
+1 -1
View File
@@ -17,7 +17,7 @@ class FooIterator {
}
//// [for-of21.js]
for (var v of new FooIterator) {
for (const v of new FooIterator) {
v;
}
var Foo = (function () {
+1 -1
View File
@@ -17,7 +17,7 @@ class FooIterator {
}
//// [for-of23.js]
for (var v of new FooIterator) {
for (const v of new FooIterator) {
const v = 0; // new scope
}
var Foo = (function () {
+1 -1
View File
@@ -7,7 +7,7 @@ for (const [k, v] of map) {
//// [for-of50.js]
var map = new Map([["", true]]);
for (var [k, v] of map) {
for (const [k, v] of map) {
k;
v;
}
@@ -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;
@@ -9,9 +9,9 @@ a;
//// [letAsIdentifierInStrictMode.js]
"use strict";
var ;
let ;
var ;
10;
var a = 10;
let ;
var ;
30;
let a;
var a;
@@ -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.
@@ -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;
@@ -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
@@ -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.
@@ -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++) { }
@@ -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
@@ -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) {
}
@@ -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) {
}
@@ -3,5 +3,5 @@ for (let v of X) {
}
//// [parserES5ForOfStatement9.js]
for (let v of X) {
for (var v of X) {
}
@@ -3,5 +3,5 @@ for (const v of X) {
}
//// [parserForOfStatement10.js]
for (var v of X) {
for (const v of X) {
}
@@ -3,5 +3,5 @@ for (const [a, b] of X) {
}
//// [parserForOfStatement11.js]
for (var [a, b] of X) {
for (const [a, b] of X) {
}
@@ -3,5 +3,5 @@ for (const {a, b} of X) {
}
//// [parserForOfStatement12.js]
for (var { a, b } of X) {
for (const { a, b } of X) {
}
@@ -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; ;);
~~
@@ -17,13 +17,13 @@
//// [shadowingViaLocalValue.js]
{
let x;
var _x;
{
var x = 1;
}
}
{
let x1;
var _x1;
{
for (var x1 = 0;;)
;
@@ -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
@@ -0,0 +1 @@
const
@@ -0,0 +1 @@
let a: number = 1
@@ -0,0 +1,2 @@
"use strict";
let
@@ -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 };
@@ -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 };
}
@@ -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);
@@ -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);

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