From 6469375149b37a77d67f437eeedb6bf0c5f5d77a Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Sun, 4 Jan 2015 14:42:05 +0100 Subject: [PATCH 01/96] Remove tagged templates error when targeting ES3 or 5 --- src/compiler/checker.ts | 5 ----- src/compiler/diagnosticInformationMap.generated.ts | 1 - src/compiler/diagnosticMessages.json | 5 ----- 3 files changed, 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f8c4caa9630..ef17f35dad0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6319,11 +6319,6 @@ module ts { } function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type { - // Grammar checking - if (compilerOptions.target < ScriptTarget.ES6) { - grammarErrorOnFirstToken(node.template, Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - return getReturnTypeOfSignature(getResolvedSignature(node)); } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 99d8d0b72fb..c9c4edbe3ac 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -117,7 +117,6 @@ module ts { const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized", isEarly: true }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block.", isEarly: true }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block.", isEarly: true }, - Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher.", isEarly: true }, Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." }, Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional.", isEarly: true }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 5bec5301721..b6a4b83f430 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -539,11 +539,6 @@ "code": 1157, "isEarly": true }, - "Tagged templates are only available when targeting ECMAScript 6 and higher.": { - "category": "Error", - "code": 1159, - "isEarly": true - }, "Unterminated template literal.": { "category": "Error", "code": 1160 From c2d0bf82c4727bd7ac632f295e0f6b3a66aa3de1 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Sun, 4 Jan 2015 14:47:18 +0100 Subject: [PATCH 02/96] Emit tagged templates when targeting ES3 or 5 --- src/compiler/emitter.ts | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 237f3ab509a..54683c5e393 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2059,8 +2059,26 @@ module ts { return; } - Debug.assert(node.parent.kind !== SyntaxKind.TaggedTemplateExpression); - + if (node.parent.kind === SyntaxKind.TaggedTemplateExpression) { + // Emit should like: + // foo(["a", "b", "c"], expressions0, expression1) + // First we emit the string literal array + write("["); + emitLiteral(node.head); + forEach(node.templateSpans, templateSpan => { + write(", "); + emitLiteral(templateSpan.literal); + }); + write("]"); + + // Now we emit the expressions + forEach(node.templateSpans, templateSpan => { + write(", "); + emit(templateSpan.expression); + }); + return; + } + var emitOuterParens = isExpression(node.parent) && templateNeedsParens(node, node.parent); @@ -2487,10 +2505,15 @@ module ts { } function emitTaggedTemplateExpression(node: TaggedTemplateExpression): void { - Debug.assert(compilerOptions.target >= ScriptTarget.ES6, "Trying to emit a tagged template in pre-ES6 mode."); emit(node.tag); - write(" "); - emit(node.template); + if (compilerOptions.target >= ScriptTarget.ES6) { + write(" "); + emit(node.template); + } else { + write("("); + emit(node.template); + write(")"); + } } function emitParenExpression(node: ParenthesizedExpression) { From 69d724f5549934e2c9997cd371384631d775d784 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Sun, 4 Jan 2015 20:58:45 +0100 Subject: [PATCH 03/96] Fix tagged templates that consist of a single part MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Example: foo `bar` should compile to foo([“bar”]) --- src/compiler/emitter.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 54683c5e393..602e4ccc12c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2048,7 +2048,12 @@ module ts { } function getTemplateLiteralAsStringLiteral(node: LiteralExpression): string { - return '"' + escapeString(node.text) + '"'; + if (node.parent.kind === SyntaxKind.TaggedTemplateExpression) { + // Emit tagged template as foo(["string"]) + return '["' + escapeString(node.text) + '"]'; + } else { + return '"' + escapeString(node.text) + '"'; + } } function emitTemplateExpression(node: TemplateExpression): void { From 8f28c95b041ba8cf46e3da93973a95552ae83248 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Mon, 5 Jan 2015 20:30:38 +0100 Subject: [PATCH 04/96] Emit parens when an argument is a comma operator Example: foo`A${ 1 }B${ 2, 3 }C`; --- src/compiler/emitter.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 602e4ccc12c..f3e4cefa919 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2079,7 +2079,9 @@ module ts { // Now we emit the expressions forEach(node.templateSpans, templateSpan => { write(", "); - emit(templateSpan.expression); + var needsParens = templateSpan.expression.kind === SyntaxKind.BinaryExpression + && ( templateSpan.expression).operator === SyntaxKind.CommaToken; + emitParenthesized(templateSpan.expression, needsParens); }); return; } From a13af6b4821917d1195bf0ef97239fa3ddb48779 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Mon, 5 Jan 2015 21:22:12 +0100 Subject: [PATCH 05/96] Move code to separate functions --- src/compiler/emitter.ts | 59 ++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index f3e4cefa919..3300e542cc5 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2030,8 +2030,19 @@ module ts { } return false; } + + function emitDownlevelTaggedTemplateLiteral(node: LiteralExpression) { + // Emit tagged template as foo(["string"]) + write("["); + writer.writeLiteral(getTemplateLiteralAsStringLiteral(node)); + write("]"); + } function emitLiteral(node: LiteralExpression) { + if (node.parent.kind === SyntaxKind.TaggedTemplateExpression && compilerOptions.target < ScriptTarget.ES6) { + return emitDownlevelTaggedTemplateLiteral(node); + } + var text = compilerOptions.target < ScriptTarget.ES6 && isTemplateLiteralKind(node.kind) ? getTemplateLiteralAsStringLiteral(node) : node.parent ? getSourceTextOfNodeFromSourceFile(currentSourceFile, node) : node.text; @@ -2048,12 +2059,28 @@ module ts { } function getTemplateLiteralAsStringLiteral(node: LiteralExpression): string { - if (node.parent.kind === SyntaxKind.TaggedTemplateExpression) { - // Emit tagged template as foo(["string"]) - return '["' + escapeString(node.text) + '"]'; - } else { - return '"' + escapeString(node.text) + '"'; - } + return '"' + escapeString(node.text) + '"'; + } + + function emitDownlevelTaggedTemplate(node: TemplateExpression): void { + // Emit should like: + // foo(["a", "b", "c"], expressions0, expression1) + // First we emit the string literal array + write("["); + emitLiteral(node.head); + forEach(node.templateSpans, templateSpan => { + write(", "); + emitLiteral(templateSpan.literal); + }); + write("]"); + + // Now we emit the expressions + forEach(node.templateSpans, templateSpan => { + write(", "); + var needsParens = templateSpan.expression.kind === SyntaxKind.BinaryExpression + && ( templateSpan.expression).operator === SyntaxKind.CommaToken; + emitParenthesized(templateSpan.expression, needsParens); + }); } function emitTemplateExpression(node: TemplateExpression): void { @@ -2065,25 +2092,7 @@ module ts { } if (node.parent.kind === SyntaxKind.TaggedTemplateExpression) { - // Emit should like: - // foo(["a", "b", "c"], expressions0, expression1) - // First we emit the string literal array - write("["); - emitLiteral(node.head); - forEach(node.templateSpans, templateSpan => { - write(", "); - emitLiteral(templateSpan.literal); - }); - write("]"); - - // Now we emit the expressions - forEach(node.templateSpans, templateSpan => { - write(", "); - var needsParens = templateSpan.expression.kind === SyntaxKind.BinaryExpression - && ( templateSpan.expression).operator === SyntaxKind.CommaToken; - emitParenthesized(templateSpan.expression, needsParens); - }); - return; + return emitDownlevelTaggedTemplate(node); } var emitOuterParens = isExpression(node.parent) From 349841e2e34ab2bc640ad2b6e8d0e9dcf22fec9c Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Fri, 9 Jan 2015 21:22:42 +0100 Subject: [PATCH 06/96] Emit var in front of statement with tagged template --- src/compiler/binder.ts | 21 ++++++++ src/compiler/emitter.ts | 114 ++++++++++++++++++++++++++++++---------- src/compiler/types.ts | 2 + 3 files changed, 109 insertions(+), 28 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 201913a50b4..87501045e20 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -65,6 +65,7 @@ module ts { var container: Node; var blockScopeContainer: Node; var lastContainer: Node; + var statement: Statement; var symbolCount = 0; var Symbol = objectAllocator.getSymbolConstructor(); @@ -371,9 +372,25 @@ module ts { function getDestructuringParameterName(node: Declaration) { return "__" + indexOf((node.parent).parameters, node); } + + function bindTaggedTemplateExpression(node: TaggedTemplateExpression) { + if (file.languageVersion >= ScriptTarget.ES6) return; + + statement.downlevelTaggedTemplates.push(node); + } function bind(node: Node) { node.parent = parent; + + var savedStatement = statement; + + if (isStatement(node)) { + statement = node; + if (file.languageVersion < ScriptTarget.ES6) { + statement.downlevelTaggedTemplates = []; + } + } + switch (node.kind) { case SyntaxKind.TypeParameter: bindDeclaration(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes, /*isBlockScopeContainer*/ false); @@ -484,12 +501,16 @@ module ts { case SyntaxKind.SwitchStatement: bindChildren(node, 0, /*isBlockScopeContainer*/ true); break; + case SyntaxKind.TaggedTemplateExpression: + bindTaggedTemplateExpression( node); default: var saveParent = parent; parent = node; forEachChild(node, bind); parent = saveParent; } + + statement = savedStatement; } function bindParameter(node: ParameterDeclaration) { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 3300e542cc5..ddc8a110acd 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2030,19 +2030,8 @@ module ts { } return false; } - - function emitDownlevelTaggedTemplateLiteral(node: LiteralExpression) { - // Emit tagged template as foo(["string"]) - write("["); - writer.writeLiteral(getTemplateLiteralAsStringLiteral(node)); - write("]"); - } function emitLiteral(node: LiteralExpression) { - if (node.parent.kind === SyntaxKind.TaggedTemplateExpression && compilerOptions.target < ScriptTarget.ES6) { - return emitDownlevelTaggedTemplateLiteral(node); - } - var text = compilerOptions.target < ScriptTarget.ES6 && isTemplateLiteralKind(node.kind) ? getTemplateLiteralAsStringLiteral(node) : node.parent ? getSourceTextOfNodeFromSourceFile(currentSourceFile, node) : node.text; @@ -2062,25 +2051,89 @@ module ts { return '"' + escapeString(node.text) + '"'; } - function emitDownlevelTaggedTemplate(node: TemplateExpression): void { - // Emit should like: - // foo(["a", "b", "c"], expressions0, expression1) - // First we emit the string literal array - write("["); - emitLiteral(node.head); - forEach(node.templateSpans, templateSpan => { - write(", "); - emitLiteral(templateSpan.literal); - }); + function emitDownlevelRawTemplateLiteral(node: LiteralExpression, isLast: boolean) { + var text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" en "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + text = text.substring(1, text.length - (isLast ? 1 : 2)); + + write('"' + escapeString(text) + '"'); + } + + function emitDownlevelTaggedTemplateVariable(node: TaggedTemplateExpression) { + node.tempVariable = createTempVariable(node); + + write("var "); + emit(node.tempVariable); + write(";"); + writeLine(); + } + function emitDownlevelTaggedTemplateStrings(node: TaggedTemplateExpression, inLoop: boolean) { + if (!inLoop) { + node.tempVariable = createTempVariable(node); + + write("var "); + } else { + // node.tempVariable is initialized in emitDownlevelTaggedTemplateVariable + + write("("); + } + emit(node.tempVariable); + write(" = ["); + + if (node.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral) { + emit(node.template); + } else { + emit(( node.template).head); + forEach(( node.template).templateSpans, (child) => { + write(", "); + emit(child.literal); + }); + } write("]"); - // Now we emit the expressions - forEach(node.templateSpans, templateSpan => { + if (!inLoop) { + write(";"); + writeLine(); + } + else { write(", "); - var needsParens = templateSpan.expression.kind === SyntaxKind.BinaryExpression - && ( templateSpan.expression).operator === SyntaxKind.CommaToken; - emitParenthesized(templateSpan.expression, needsParens); - }); + } + emit(node.tempVariable); + write(".raw = ["); + if (node.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral) { + emitDownlevelRawTemplateLiteral( node.template, true); + } else { + emitDownlevelRawTemplateLiteral(( node.template).head, false); + forEach(( node.template).templateSpans, (child, index) => { + write(", "); + emitDownlevelRawTemplateLiteral(child.literal, index === ( node.template).templateSpans.length - 1); + }); + } + write("]"); + if (!inLoop) { + write(";"); + writeLine(); + } + } + + function emitDownlevelTaggedTemplate(node: LiteralExpression | TemplateExpression): void { + // Emit should like: + // foo(tempVar, expressions0, expression1) + emit(( node.parent).tempVariable); + + // Now we emit the expressions + if (node.kind === SyntaxKind.TemplateExpression) { + forEach(( node).templateSpans, templateSpan => { + write(", "); + var needsParens = templateSpan.expression.kind === SyntaxKind.BinaryExpression + && ( templateSpan.expression).operator === SyntaxKind.CommaToken; + emitParenthesized(templateSpan.expression, needsParens); + }); + } } function emitTemplateExpression(node: TemplateExpression): void { @@ -2527,7 +2580,7 @@ module ts { emit(node.template); } else { write("("); - emit(node.template); + emitDownlevelTaggedTemplate(node.template); write(")"); } } @@ -3969,6 +4022,11 @@ module ts { return; } + if (isStatement(node)) { + // TODO: Check whether node is a loop + forEach(( node).downlevelTaggedTemplates, node => emitDownlevelTaggedTemplateStrings(node, false)); + } + if (node.flags & NodeFlags.Ambient) { return emitPinnedOrTripleSlashComments(node); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 60ed8352b9a..52a95acfc91 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -692,6 +692,7 @@ module ts { export interface TaggedTemplateExpression extends MemberExpression { tag: LeftHandSideExpression; template: LiteralExpression | TemplateExpression; + tempVariable?: Identifier; // Initialized in emitter.ts } export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression; @@ -703,6 +704,7 @@ module ts { export interface Statement extends Node, ModuleElement { _statementBrand: any; + downlevelTaggedTemplates?: TaggedTemplateExpression[]; // Initialized in binder.ts } export interface Block extends Statement { From 28b90a2be31ab6766a53d7ab300410c2b76b9537 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Mon, 19 Jan 2015 11:09:27 +0100 Subject: [PATCH 07/96] Remove properties from types.ts --- src/compiler/types.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 52a95acfc91..60ed8352b9a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -692,7 +692,6 @@ module ts { export interface TaggedTemplateExpression extends MemberExpression { tag: LeftHandSideExpression; template: LiteralExpression | TemplateExpression; - tempVariable?: Identifier; // Initialized in emitter.ts } export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression; @@ -704,7 +703,6 @@ module ts { export interface Statement extends Node, ModuleElement { _statementBrand: any; - downlevelTaggedTemplates?: TaggedTemplateExpression[]; // Initialized in binder.ts } export interface Block extends Statement { From ed7ae27f4c068bea836c7f0402ba8ec9951d95ba Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Mon, 19 Jan 2015 11:09:57 +0100 Subject: [PATCH 08/96] Remove binding of tagged templates --- src/compiler/binder.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 87501045e20..23ccaba4b6c 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -372,12 +372,6 @@ module ts { function getDestructuringParameterName(node: Declaration) { return "__" + indexOf((node.parent).parameters, node); } - - function bindTaggedTemplateExpression(node: TaggedTemplateExpression) { - if (file.languageVersion >= ScriptTarget.ES6) return; - - statement.downlevelTaggedTemplates.push(node); - } function bind(node: Node) { node.parent = parent; @@ -501,8 +495,6 @@ module ts { case SyntaxKind.SwitchStatement: bindChildren(node, 0, /*isBlockScopeContainer*/ true); break; - case SyntaxKind.TaggedTemplateExpression: - bindTaggedTemplateExpression( node); default: var saveParent = parent; parent = node; From d339a52b6a7cd80248dc170e4eb373223fb754d6 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Mon, 19 Jan 2015 11:32:27 +0100 Subject: [PATCH 09/96] Remove statement from binder --- src/compiler/binder.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 23ccaba4b6c..aa44179ed24 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -65,7 +65,6 @@ module ts { var container: Node; var blockScopeContainer: Node; var lastContainer: Node; - var statement: Statement; var symbolCount = 0; var Symbol = objectAllocator.getSymbolConstructor(); @@ -376,15 +375,6 @@ module ts { function bind(node: Node) { node.parent = parent; - var savedStatement = statement; - - if (isStatement(node)) { - statement = node; - if (file.languageVersion < ScriptTarget.ES6) { - statement.downlevelTaggedTemplates = []; - } - } - switch (node.kind) { case SyntaxKind.TypeParameter: bindDeclaration(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes, /*isBlockScopeContainer*/ false); @@ -501,8 +491,6 @@ module ts { forEachChild(node, bind); parent = saveParent; } - - statement = savedStatement; } function bindParameter(node: ParameterDeclaration) { From 161545de97db60c298eb9db4fcf496970d636a62 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Mon, 19 Jan 2015 11:33:43 +0100 Subject: [PATCH 10/96] Change tagged template emit to new style --- src/compiler/emitter.ts | 82 ++++++++++++----------------------------- 1 file changed, 24 insertions(+), 58 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index ddc8a110acd..d0cbbff92f8 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2054,7 +2054,7 @@ module ts { function emitDownlevelRawTemplateLiteral(node: LiteralExpression, isLast: boolean) { var text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" en "}"), + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" @@ -2063,77 +2063,53 @@ module ts { write('"' + escapeString(text) + '"'); } - function emitDownlevelTaggedTemplateVariable(node: TaggedTemplateExpression) { - node.tempVariable = createTempVariable(node); - - write("var "); - emit(node.tempVariable); - write(";"); - writeLine(); - } - function emitDownlevelTaggedTemplateStrings(node: TaggedTemplateExpression, inLoop: boolean) { - if (!inLoop) { - node.tempVariable = createTempVariable(node); - - write("var "); - } else { - // node.tempVariable is initialized in emitDownlevelTaggedTemplateVariable - - write("("); - } - emit(node.tempVariable); + function emitDownlevelTaggedTemplate(node: TaggedTemplateExpression) { + var tempVariable = createTempVariable(node); + recordTempDeclaration(tempVariable); + write("("); + emit(tempVariable); write(" = ["); if (node.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral) { emit(node.template); - } else { + } + else { emit(( node.template).head); forEach(( node.template).templateSpans, (child) => { write(", "); emit(child.literal); }); } - write("]"); + write("], "); - if (!inLoop) { - write(";"); - writeLine(); - } - else { - write(", "); - } - emit(node.tempVariable); + emit(tempVariable); write(".raw = ["); if (node.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral) { emitDownlevelRawTemplateLiteral( node.template, true); - } else { + } + else { emitDownlevelRawTemplateLiteral(( node.template).head, false); forEach(( node.template).templateSpans, (child, index) => { write(", "); emitDownlevelRawTemplateLiteral(child.literal, index === ( node.template).templateSpans.length - 1); }); } - write("]"); - if (!inLoop) { - write(";"); - writeLine(); - } - } - - function emitDownlevelTaggedTemplate(node: LiteralExpression | TemplateExpression): void { - // Emit should like: - // foo(tempVar, expressions0, expression1) - emit(( node.parent).tempVariable); + write("], "); + + emit(node.tag); + write("("); + emit(tempVariable); // Now we emit the expressions - if (node.kind === SyntaxKind.TemplateExpression) { - forEach(( node).templateSpans, templateSpan => { + if (node.template.kind === SyntaxKind.TemplateExpression) { + forEach(( node.template).templateSpans, templateSpan => { write(", "); var needsParens = templateSpan.expression.kind === SyntaxKind.BinaryExpression && ( templateSpan.expression).operator === SyntaxKind.CommaToken; emitParenthesized(templateSpan.expression, needsParens); }); } + write("))"); } function emitTemplateExpression(node: TemplateExpression): void { @@ -2144,10 +2120,6 @@ module ts { return; } - if (node.parent.kind === SyntaxKind.TaggedTemplateExpression) { - return emitDownlevelTaggedTemplate(node); - } - var emitOuterParens = isExpression(node.parent) && templateNeedsParens(node, node.parent); @@ -2574,14 +2546,13 @@ module ts { } function emitTaggedTemplateExpression(node: TaggedTemplateExpression): void { - emit(node.tag); if (compilerOptions.target >= ScriptTarget.ES6) { + emit(node.tag); write(" "); emit(node.template); - } else { - write("("); - emitDownlevelTaggedTemplate(node.template); - write(")"); + } + else { + emitDownlevelTaggedTemplate(node); } } @@ -4022,11 +3993,6 @@ module ts { return; } - if (isStatement(node)) { - // TODO: Check whether node is a loop - forEach(( node).downlevelTaggedTemplates, node => emitDownlevelTaggedTemplateStrings(node, false)); - } - if (node.flags & NodeFlags.Ambient) { return emitPinnedOrTripleSlashComments(node); } From 434c908c369e2f837b29650e607baeddc1be25c1 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Mon, 19 Jan 2015 11:45:48 +0100 Subject: [PATCH 11/96] Re-add debug assert & fix indent --- src/compiler/emitter.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d0cbbff92f8..3631d1f1d1c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2061,7 +2061,7 @@ module ts { text = text.substring(1, text.length - (isLast ? 1 : 2)); write('"' + escapeString(text) + '"'); - } + } function emitDownlevelTaggedTemplate(node: TaggedTemplateExpression) { var tempVariable = createTempVariable(node); @@ -2120,6 +2120,8 @@ module ts { return; } + Debug.assert(node.parent.kind !== SyntaxKind.TaggedTemplateExpression); + var emitOuterParens = isExpression(node.parent) && templateNeedsParens(node, node.parent); From cbec9a3a3a4646a660cd32b01f1a6959f9e03dce Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Fri, 23 Jan 2015 15:44:21 +0100 Subject: [PATCH 12/96] Respond to CR --- src/compiler/emitter.ts | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 3631d1f1d1c..a4374690fb0 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2051,16 +2051,21 @@ module ts { return '"' + escapeString(node.text) + '"'; } - function emitDownlevelRawTemplateLiteral(node: LiteralExpression, isLast: boolean) { + function emitDownlevelRawTemplateLiteral(node: LiteralExpression) { var text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node); // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" + var isLast = node.kind === SyntaxKind.NoSubstitutionTemplateLiteral || node.kind === SyntaxKind.TemplateTail; text = text.substring(1, text.length - (isLast ? 1 : 2)); - write('"' + escapeString(text) + '"'); + // Newline normalization + text = text.replace(/\r\n?/g, "\n"); + text = escapeString(text); + + write('"' + text + '"'); } function emitDownlevelTaggedTemplate(node: TaggedTemplateExpression) { @@ -2074,8 +2079,8 @@ module ts { emit(node.template); } else { - emit(( node.template).head); - forEach(( node.template).templateSpans, (child) => { + emit((node.template).head); + forEach((node.template).templateSpans, (child) => { write(", "); emit(child.literal); }); @@ -2085,13 +2090,13 @@ module ts { emit(tempVariable); write(".raw = ["); if (node.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral) { - emitDownlevelRawTemplateLiteral( node.template, true); + emitDownlevelRawTemplateLiteral(node.template); } else { - emitDownlevelRawTemplateLiteral(( node.template).head, false); - forEach(( node.template).templateSpans, (child, index) => { + emitDownlevelRawTemplateLiteral((node.template).head); + forEach((node.template).templateSpans, (child, index) => { write(", "); - emitDownlevelRawTemplateLiteral(child.literal, index === ( node.template).templateSpans.length - 1); + emitDownlevelRawTemplateLiteral(child.literal); }); } write("], "); @@ -2102,10 +2107,10 @@ module ts { // Now we emit the expressions if (node.template.kind === SyntaxKind.TemplateExpression) { - forEach(( node.template).templateSpans, templateSpan => { + forEach((node.template).templateSpans, templateSpan => { write(", "); var needsParens = templateSpan.expression.kind === SyntaxKind.BinaryExpression - && ( templateSpan.expression).operator === SyntaxKind.CommaToken; + && (templateSpan.expression).operator === SyntaxKind.CommaToken; emitParenthesized(templateSpan.expression, needsParens); }); } From 39027d901a8adcc69c7b0d4ce669269406bf40a4 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Fri, 23 Jan 2015 15:46:32 +0100 Subject: [PATCH 13/96] Rename emitParenthesized to emitParenthesizedIf --- src/compiler/emitter.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a4374690fb0..5e7d2d25027 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1953,7 +1953,7 @@ module ts { } } - function emitParenthesized(node: Node, parenthesized: boolean) { + function emitParenthesizedIf(node: Node, parenthesized: boolean) { if (parenthesized) { write("("); } @@ -2111,7 +2111,7 @@ module ts { write(", "); var needsParens = templateSpan.expression.kind === SyntaxKind.BinaryExpression && (templateSpan.expression).operator === SyntaxKind.CommaToken; - emitParenthesized(templateSpan.expression, needsParens); + emitParenthesizedIf(templateSpan.expression, needsParens); }); } write("))"); @@ -2149,7 +2149,7 @@ module ts { var needsParens = templateSpan.expression.kind !== SyntaxKind.ParenthesizedExpression && comparePrecedenceToBinaryPlus(templateSpan.expression) !== Comparison.GreaterThan; write(" + "); - emitParenthesized(templateSpan.expression, needsParens); + emitParenthesizedIf(templateSpan.expression, needsParens); // Only emit if the literal is non-empty. // The binary '+' operator is left-associative, so the first string concatenation // with the head will force the result up to this point to be a string. @@ -2395,7 +2395,7 @@ module ts { var e = elements[pos]; if (e.kind === SyntaxKind.SpreadElementExpression) { e = (e).expression; - emitParenthesized(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccess(e)); + emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccess(e)); pos++; } else { @@ -2703,7 +2703,7 @@ module ts { function emitExpressionStatement(node: ExpressionStatement) { emitLeadingComments(node); - emitParenthesized(node.expression, /*parenthesized*/ node.expression.kind === SyntaxKind.ArrowFunction); + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === SyntaxKind.ArrowFunction); write(";"); emitTrailingComments(node); } From 04dd08da70e98aa7e82f0ad23e8f20eb91287050 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Fri, 6 Feb 2015 16:45:26 +0100 Subject: [PATCH 14/96] Resolve missed merge conflict --- src/compiler/emitter.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 04a487396e2..5059448903c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2818,7 +2818,6 @@ module ts { function emitExpressionStatement(node: ExpressionStatement) { emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === SyntaxKind.ArrowFunction); - emitParenthesized(node.expression, /*parenthesized*/ node.expression.kind === SyntaxKind.ArrowFunction); write(";"); } From 8e16e1d010cca171c1da63bc285c6bccc50049c3 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Fri, 6 Feb 2015 17:02:30 +0100 Subject: [PATCH 15/96] Update baselines --- ...ateStringsTypeArgumentInference.errors.txt | 86 +------------------ ...gedTemplateStringsTypeArgumentInference.js | 57 ++++++------ ...tringsWithIncompatibleTypedTags.errors.txt | 38 +------- ...emplateStringsWithIncompatibleTypedTags.js | 19 ++-- ...ithManyCallAndMemberExpressions.errors.txt | 21 ----- ...StringsWithManyCallAndMemberExpressions.js | 3 +- ...ingsWithManyCallAndMemberExpressions.types | 38 ++++++++ ...eStringsWithOverloadResolution1.errors.txt | 20 +---- ...dTemplateStringsWithOverloadResolution1.js | 13 +-- ...eStringsWithOverloadResolution2.errors.txt | 27 ------ ...dTemplateStringsWithOverloadResolution2.js | 5 +- ...mplateStringsWithOverloadResolution2.types | 60 +++++++++++++ ...eStringsWithOverloadResolution3.errors.txt | 68 +-------------- ...dTemplateStringsWithOverloadResolution3.js | 45 +++++----- ...mplateStringsWithTagsTypedAsAny.errors.txt | 64 -------------- ...taggedTemplateStringsWithTagsTypedAsAny.js | 21 ++--- ...gedTemplateStringsWithTagsTypedAsAny.types | 66 ++++++++++++++ ...essionsInSubstitutionExpression.errors.txt | 5 +- ...tionExpressionsInSubstitutionExpression.js | 5 +- ...gedTemplateStringsWithTypedTags.errors.txt | 64 -------------- .../taggedTemplateStringsWithTypedTags.js | 17 ++-- .../taggedTemplateStringsWithTypedTags.types | 82 ++++++++++++++++++ .../reference/templateStringInModuleName.js | 5 +- .../templateStringInObjectLiteral.js | 5 +- .../templateStringInPropertyName1.js | 3 +- .../templateStringInPropertyName2.js | 3 +- .../templateStringInTaggedTemplate.errors.txt | 7 +- .../templateStringInTaggedTemplate.js | 3 +- ...tringsArrayTypeDefinedInES5Mode.errors.txt | 7 +- ...emplateStringsArrayTypeDefinedInES5Mode.js | 3 +- ...ringsArrayTypeNotDefinedES5Mode.errors.txt | 7 +- ...mplateStringsArrayTypeNotDefinedES5Mode.js | 3 +- 32 files changed, 370 insertions(+), 500 deletions(-) delete mode 100644 tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.errors.txt create mode 100644 tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.types delete mode 100644 tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.errors.txt create mode 100644 tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.types delete mode 100644 tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt create mode 100644 tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.types delete mode 100644 tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt create mode 100644 tests/baselines/reference/taggedTemplateStringsWithTypedTags.types diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt index 275fdac6ac7..f3706ae8f17 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt @@ -1,143 +1,69 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(5,10): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(9,17): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(13,16): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(16,16): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(20,16): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(23,16): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(27,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(28,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(29,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(33,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(34,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(35,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(39,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(40,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(41,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(45,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(46,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(47,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(51,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(52,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(53,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(57,23): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(58,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(64,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(64,25): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Property 'z' is missing in type '{ x: number; y: string; }'. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,25): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(81,25): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(86,23): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(90,25): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -==== tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts (30 errors) ==== +==== tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts (2 errors) ==== // Generic tag with one parameter function noParams(n: T) { } noParams ``; - ~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic tag with parameter which does not use type parameter function noGenericParams(n: string[]) { } noGenericParams ``; - ~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic tag with multiple type parameters and only one used in parameter type annotation function someGenerics1a(n: T, m: number) { } someGenerics1a `${3}`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. function someGenerics1b(n: string[], m: U) { } someGenerics1b `${3}`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic tag with argument of function type whose parameter is of type parameter type function someGenerics2a(strs: string[], n: (x: T) => void) { } someGenerics2a `${(n: string) => n}`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. function someGenerics2b(strs: string[], n: (x: T, y: U) => void) { } someGenerics2b `${ (n: string, x: number) => n }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter function someGenerics3(strs: string[], producer: () => T) { } someGenerics3 `${() => ''}`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. someGenerics3 `${() => undefined}`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. someGenerics3 `${() => 3}`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type function someGenerics4(strs: string[], n: T, f: (x: U) => void) { } someGenerics4 `${4}${ () => null }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. someGenerics4 `${''}${ () => 3 }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. someGenerics4 `${ null }${ null }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type function someGenerics5(strs: string[], n: T, f: (x: U) => void) { } someGenerics5 `${ 4 } ${ () => null }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. someGenerics5 `${ '' }${ () => 3 }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. someGenerics5 `${null}${null}`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic tag with multiple arguments of function types that each have parameters of the same generic type function someGenerics6(strs: string[], a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { } someGenerics6 `${ n => n }${ n => n}${ n => n}`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. someGenerics6 `${ n => n }${ n => n}${ n => n}`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. someGenerics6 `${ (n: number) => n }${ (n: number) => n }${ (n: number) => n }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic tag with multiple arguments of function types that each have parameters of different generic type function someGenerics7(strs: string[], a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { } someGenerics7 `${ n => n }${ n => n }${ n => n }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. someGenerics7 `${ n => n }${ n => n }${ n => n }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. someGenerics7 `${(n: number) => n}${ (n: string) => n}${ (n: number) => n}`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic tag with argument of generic function type function someGenerics8(strs: string[], n: T): T { return n; } var x = someGenerics8 `${ someGenerics7 }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. x `${null}${null}${null}`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic tag with multiple parameters of generic type passed arguments with no best common type function someGenerics9(strs: string[], a: T, b: T, c: T): T { @@ -147,8 +73,6 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var a9a: {}; // Generic tag with multiple parameters of generic type passed arguments with multiple best common types @@ -166,27 +90,19 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Property 'z' is missing in type '{ x: number; y: string; }'. - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var a9e: {}; // Generic tag with multiple parameters of generic type passed arguments with a single best common type var a9d = someGenerics9 `${ { x: 3 }}${ { x: 6 }}${ { x: 6 } }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var a9d: { x: number; }; // Generic tag with multiple parameters of generic type where one argument is of type 'any' var anyVar: any; var a = someGenerics9 `${ 7 }${ anyVar }${ 4 }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var a: any; // Generic tag with multiple parameters of generic type where one argument is [] and the other is not 'any' var arr = someGenerics9 `${ [] }${ null }${ undefined }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var arr: any[]; \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js index 6f3d4ed803a..04f74aa3752 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js @@ -97,76 +97,77 @@ var arr: any[]; // Generic tag with one parameter function noParams(n) { } -noParams ""; +(_a = [""], _a.raw = [""], noParams(_a)); // Generic tag with parameter which does not use type parameter function noGenericParams(n) { } -noGenericParams ""; +(_b = [""], _b.raw = [""], noGenericParams(_b)); // Generic tag with multiple type parameters and only one used in parameter type annotation function someGenerics1a(n, m) { } -someGenerics1a "" + 3; +(_c = ["", ""], _c.raw = ["", ""], someGenerics1a(_c, 3)); function someGenerics1b(n, m) { } -someGenerics1b "" + 3; +(_d = ["", ""], _d.raw = ["", ""], someGenerics1b(_d, 3)); // Generic tag with argument of function type whose parameter is of type parameter type function someGenerics2a(strs, n) { } -someGenerics2a "" + function (n) { return n; }; +(_e = ["", ""], _e.raw = ["", ""], someGenerics2a(_e, function (n) { return n; })); function someGenerics2b(strs, n) { } -someGenerics2b "" + function (n, x) { return n; }; +(_f = ["", ""], _f.raw = ["", ""], someGenerics2b(_f, function (n, x) { return n; })); // Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter function someGenerics3(strs, producer) { } -someGenerics3 "" + function () { return ''; }; -someGenerics3 "" + function () { return undefined; }; -someGenerics3 "" + function () { return 3; }; +(_g = ["", ""], _g.raw = ["", ""], someGenerics3(_g, function () { return ''; })); +(_h = ["", ""], _h.raw = ["", ""], someGenerics3(_h, function () { return undefined; })); +(_j = ["", ""], _j.raw = ["", ""], someGenerics3(_j, function () { return 3; })); // 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type function someGenerics4(strs, n, f) { } -someGenerics4 "" + 4 + function () { return null; }; -someGenerics4 "" + '' + function () { return 3; }; -someGenerics4 "" + null + null; +(_k = ["", "", ""], _k.raw = ["", "", ""], someGenerics4(_k, 4, function () { return null; })); +(_l = ["", "", ""], _l.raw = ["", "", ""], someGenerics4(_l, '', function () { return 3; })); +(_m = ["", "", ""], _m.raw = ["", "", ""], someGenerics4(_m, null, null)); // 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type function someGenerics5(strs, n, f) { } -someGenerics5 4 + " " + function () { return null; }; -someGenerics5 "" + '' + function () { return 3; }; -someGenerics5 "" + null + null; +(_n = ["", " ", ""], _n.raw = ["", " ", ""], someGenerics5(_n, 4, function () { return null; })); +(_o = ["", "", ""], _o.raw = ["", "", ""], someGenerics5(_o, '', function () { return 3; })); +(_p = ["", "", ""], _p.raw = ["", "", ""], someGenerics5(_p, null, null)); // Generic tag with multiple arguments of function types that each have parameters of the same generic type function someGenerics6(strs, a, b, c) { } -someGenerics6 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; -someGenerics6 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; -someGenerics6 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; +(_q = ["", "", "", ""], _q.raw = ["", "", "", ""], someGenerics6(_q, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); +(_r = ["", "", "", ""], _r.raw = ["", "", "", ""], someGenerics6(_r, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); +(_s = ["", "", "", ""], _s.raw = ["", "", "", ""], someGenerics6(_s, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); // Generic tag with multiple arguments of function types that each have parameters of different generic type function someGenerics7(strs, a, b, c) { } -someGenerics7 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; -someGenerics7 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; -someGenerics7 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; +(_t = ["", "", "", ""], _t.raw = ["", "", "", ""], someGenerics7(_t, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); +(_u = ["", "", "", ""], _u.raw = ["", "", "", ""], someGenerics7(_u, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); +(_v = ["", "", "", ""], _v.raw = ["", "", "", ""], someGenerics7(_v, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); // Generic tag with argument of generic function type function someGenerics8(strs, n) { return n; } -var x = someGenerics8 "" + someGenerics7; -x "" + null + null + null; +var x = (_w = ["", ""], _w.raw = ["", ""], someGenerics8(_w, someGenerics7)); +(_x = ["", "", "", ""], _x.raw = ["", "", "", ""], x(_x, null, null, null)); // Generic tag with multiple parameters of generic type passed arguments with no best common type function someGenerics9(strs, a, b, c) { return null; } -var a9a = someGenerics9 "" + '' + 0 + []; +var a9a = (_y = ["", "", "", ""], _y.raw = ["", "", "", ""], someGenerics9(_y, '', 0, [])); var a9a; -var a9e = someGenerics9 "" + undefined + { x: 6, z: new Date() } + { x: 6, y: '' }; +var a9e = (_z = ["", "", "", ""], _z.raw = ["", "", "", ""], someGenerics9(_z, undefined, { x: 6, z: new Date() }, { x: 6, y: '' })); var a9e; // Generic tag with multiple parameters of generic type passed arguments with a single best common type -var a9d = someGenerics9 "" + { x: 3 } + { x: 6 } + { x: 6 }; +var a9d = (_0 = ["", "", "", ""], _0.raw = ["", "", "", ""], someGenerics9(_0, { x: 3 }, { x: 6 }, { x: 6 })); var a9d; // Generic tag with multiple parameters of generic type where one argument is of type 'any' var anyVar; -var a = someGenerics9 "" + 7 + anyVar + 4; +var a = (_1 = ["", "", "", ""], _1.raw = ["", "", "", ""], someGenerics9(_1, 7, anyVar, 4)); var a; // Generic tag with multiple parameters of generic type where one argument is [] and the other is not 'any' -var arr = someGenerics9 "" + [] + null + undefined; +var arr = (_2 = ["", "", "", ""], _2.raw = ["", "", "", ""], someGenerics9(_2, [], null, undefined)); var arr; +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2; diff --git a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt index 6b389218f65..166769fbbf5 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt @@ -1,24 +1,12 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(12,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(16,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(20,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,19): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,40): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,50): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,57): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (18 errors) ==== +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (6 errors) ==== interface I { (stringParts: string[], ...rest: boolean[]): I; g: I; @@ -31,56 +19,32 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped var f: I; f `abc` - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc`.member - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`.member; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc`["member"]; - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`["member"]; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc`[0].member `abc${1}def${2}ghi`; - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. diff --git a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.js b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.js index c3e145afb2b..9d113793228 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.js +++ b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.js @@ -35,14 +35,15 @@ f.thisIsNotATag(`abc${1}def${2}ghi`); //// [taggedTemplateStringsWithIncompatibleTypedTags.js] var f; -f "abc"; -f "abc" + 1 + "def" + 2 + "ghi"; -f "abc".member; -f "abc" + 1 + "def" + 2 + "ghi".member; -f "abc"["member"]; -f "abc" + 1 + "def" + 2 + "ghi"["member"]; -f "abc"[0].member "abc" + 1 + "def" + 2 + "ghi"; -f "abc" + 1 + "def" + 2 + "ghi"["member"].member "abc" + 1 + "def" + 2 + "ghi"; -f "abc" + true + "def" + true + "ghi"["member"].member "abc" + 1 + "def" + 2 + "ghi"; +(_a = ["abc"], _a.raw = ["abc"], f(_a)); +(_b = ["abc", "def", "ghi"], _b.raw = ["abc", "def", "ghi"], f(_b, 1, 2)); +(_c = ["abc"], _c.raw = ["abc"], f(_c)).member; +(_d = ["abc", "def", "ghi"], _d.raw = ["abc", "def", "ghi"], f(_d, 1, 2)).member; +(_e = ["abc"], _e.raw = ["abc"], f(_e))["member"]; +(_f = ["abc", "def", "ghi"], _f.raw = ["abc", "def", "ghi"], f(_f, 1, 2))["member"]; +(_g = ["abc", "def", "ghi"], _g.raw = ["abc", "def", "ghi"], (_h = ["abc"], _h.raw = ["abc"], f(_h))[0].member(_g, 1, 2)); +(_j = ["abc", "def", "ghi"], _j.raw = ["abc", "def", "ghi"], (_k = ["abc", "def", "ghi"], _k.raw = ["abc", "def", "ghi"], f(_k, 1, 2))["member"].member(_j, 1, 2)); +(_l = ["abc", "def", "ghi"], _l.raw = ["abc", "def", "ghi"], (_m = ["abc", "def", "ghi"], _m.raw = ["abc", "def", "ghi"], f(_m, true, true))["member"].member(_l, 1, 2)); f.thisIsNotATag("abc"); f.thisIsNotATag("abc" + 1 + "def" + 2 + "ghi"); +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; diff --git a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.errors.txt deleted file mode 100644 index 17c0b330dbb..00000000000 --- a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts(13,23): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts (1 errors) ==== - interface I { - (strs: string[], ...subs: number[]): I; - member: { - new (s: string): { - new (n: number): { - new (): boolean; - } - } - }; - } - var f: I; - - var x = new new new f `abc${ 0 }def`.member("hello")(42) === true; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.js b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.js index d507e951721..1814816283b 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.js +++ b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.js @@ -17,4 +17,5 @@ var x = new new new f `abc${ 0 }def`.member("hello")(42) === true; //// [taggedTemplateStringsWithManyCallAndMemberExpressions.js] var f; -var x = new new new f "abc" + 0 + "def".member("hello")(42) === true; +var x = new new new (_a = ["abc", "def"], _a.raw = ["abc", "def"], f(_a, 0)).member("hello")(42) === true; +var _a; diff --git a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.types b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.types new file mode 100644 index 00000000000..6fa83bbde3d --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts === +interface I { +>I : I + + (strs: string[], ...subs: number[]): I; +>strs : string[] +>subs : number[] +>I : I + + member: { +>member : new (s: string) => new (n: number) => new () => boolean + + new (s: string): { +>s : string + + new (n: number): { +>n : number + + new (): boolean; + } + } + }; +} +var f: I; +>f : I +>I : I + +var x = new new new f `abc${ 0 }def`.member("hello")(42) === true; +>x : boolean +>new new new f `abc${ 0 }def`.member("hello")(42) === true : boolean +>new new new f `abc${ 0 }def`.member("hello")(42) : boolean +>new new f `abc${ 0 }def`.member("hello")(42) : new () => boolean +>new f `abc${ 0 }def`.member("hello") : new (n: number) => new () => boolean +>f `abc${ 0 }def`.member : new (s: string) => new (n: number) => new () => boolean +>f : I +>member : new (s: string) => new (n: number) => new () => boolean + + diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt index e4c79537ce2..9e450cbb368 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt @@ -1,16 +1,10 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(12,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(16,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(17,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(18,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(20,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,9): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts (10 errors) ==== +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts (4 errors) ==== function foo(strs: string[]): number; function foo(strs: string[], x: number): string; function foo(strs: string[], x: number, y: number): boolean; @@ -31,25 +25,13 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio !!! error TS2346: Supplied parameters do not match any signature of call target. var u = foo ``; // number - ~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var v = foo `${1}`; // string - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var w = foo `${1}${2}`; // boolean - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var x = foo `${1}${true}`; // boolean (with error) - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~ !!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. var y = foo `${1}${"2"}`; // {} - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var z = foo `${1}${2}${3}`; // any (with error) ~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.js b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.js index 23298e1df13..431447df22e 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.js +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.js @@ -36,9 +36,10 @@ var c = foo([], 1, 2); // boolean var d = foo([], 1, true); // boolean (with error) var e = foo([], 1, "2"); // {} var f = foo([], 1, 2, 3); // any (with error) -var u = foo ""; // number -var v = foo "" + 1; // string -var w = foo "" + 1 + 2; // boolean -var x = foo "" + 1 + true; // boolean (with error) -var y = foo "" + 1 + "2"; // {} -var z = foo "" + 1 + 2 + 3; // any (with error) +var u = (_a = [""], _a.raw = [""], foo(_a)); // number +var v = (_b = ["", ""], _b.raw = ["", ""], foo(_b, 1)); // string +var w = (_c = ["", "", ""], _c.raw = ["", "", ""], foo(_c, 1, 2)); // boolean +var x = (_d = ["", "", ""], _d.raw = ["", "", ""], foo(_d, 1, true)); // boolean (with error) +var y = (_e = ["", "", ""], _e.raw = ["", "", ""], foo(_e, 1, "2")); // {} +var z = (_f = ["", "", "", ""], _f.raw = ["", "", "", ""], foo(_f, 1, 2, 3)); // any (with error) +var _a, _b, _c, _d, _e, _f; diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.errors.txt deleted file mode 100644 index 3bf4af39779..00000000000 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.errors.txt +++ /dev/null @@ -1,27 +0,0 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution2.ts(8,14): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution2.ts(17,14): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution2.ts (2 errors) ==== - - function foo1(strs: TemplateStringsArray, x: number): string; - function foo1(strs: string[], x: number): number; - function foo1(...stuff: any[]): any { - return undefined; - } - - var a = foo1 `${1}`; // string - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - var b = foo1([], 1); // number - - function foo2(strs: string[], x: number): number; - function foo2(strs: TemplateStringsArray, x: number): string; - function foo2(...stuff: any[]): any { - return undefined; - } - - var c = foo2 `${1}`; // number - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - var d = foo2([], 1); // number \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.js b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.js index 0b1447a3d3f..f12008f9581 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.js +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.js @@ -26,7 +26,7 @@ function foo1() { } return undefined; } -var a = foo1 "" + 1; // string +var a = (_a = ["", ""], _a.raw = ["", ""], foo1(_a, 1)); // string var b = foo1([], 1); // number function foo2() { var stuff = []; @@ -35,5 +35,6 @@ function foo2() { } return undefined; } -var c = foo2 "" + 1; // number +var c = (_b = ["", ""], _b.raw = ["", ""], foo2(_b, 1)); // number var d = foo2([], 1); // number +var _a, _b; diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.types b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.types new file mode 100644 index 00000000000..0863ac3fafc --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.types @@ -0,0 +1,60 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution2.ts === + +function foo1(strs: TemplateStringsArray, x: number): string; +>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; } +>strs : TemplateStringsArray +>TemplateStringsArray : TemplateStringsArray +>x : number + +function foo1(strs: string[], x: number): number; +>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; } +>strs : string[] +>x : number + +function foo1(...stuff: any[]): any { +>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; } +>stuff : any[] + + return undefined; +>undefined : undefined +} + +var a = foo1 `${1}`; // string +>a : string +>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; } + +var b = foo1([], 1); // number +>b : number +>foo1([], 1) : number +>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; } +>[] : undefined[] + +function foo2(strs: string[], x: number): number; +>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; } +>strs : string[] +>x : number + +function foo2(strs: TemplateStringsArray, x: number): string; +>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; } +>strs : TemplateStringsArray +>TemplateStringsArray : TemplateStringsArray +>x : number + +function foo2(...stuff: any[]): any { +>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; } +>stuff : any[] + + return undefined; +>undefined : undefined +} + +var c = foo2 `${1}`; // number +>c : number +>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; } + +var d = foo2([], 1); // number +>d : number +>foo2([], 1) : number +>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; } +>[] : undefined[] + diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.errors.txt index c1a6b228b01..0d65c3fd13b 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.errors.txt @@ -1,34 +1,12 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(7,21): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(10,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(10,9): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(16,20): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(17,20): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(19,4): error TS2339: Property 'foo' does not exist on type 'Date'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(23,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(26,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(34,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(35,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(36,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(40,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(41,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(42,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(45,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(45,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(54,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(55,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(56,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(57,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(60,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(63,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(63,9): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(64,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(64,18): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(70,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(70,18): error TS2339: Property 'toFixed' does not exist on type 'string'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(71,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts (28 errors) ==== +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts (6 errors) ==== // Ambiguous call picks the first overload in declaration order function fn1(strs: TemplateStringsArray, s: string): string; @@ -36,13 +14,9 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio function fn1() { return null; } var s: string = fn1 `${ undefined }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // No candidate overloads found fn1 `${ {} }`; // Error - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~ !!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. @@ -51,11 +25,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio function fn2() { return undefined; } var d1: Date = fn2 `${ 0 }${ undefined }`; // contextually typed - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var d2 = fn2 `${ 0 }${ undefined }`; // any - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. d1.foo(); // error ~~~ @@ -64,13 +34,9 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio // Generic and non-generic overload where generic overload is the only candidate fn2 `${ 0 }${ '' }`; // OK - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic and non-generic overload where non-generic overload is the only candidate fn2 `${ '' }${ 0 }`; // OK - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic overloads with differing arity function fn3(strs: TemplateStringsArray, n: T): string; @@ -79,33 +45,19 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio function fn3() { return null; } var s = fn3 `${ 3 }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var s = fn3 `${'' }${ 3 }${ '' }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var n = fn3 `${ 5 }${ 5 }${ 5 }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var n: number; // Generic overloads with differing arity tagging with arguments matching each overload type parameter count var s = fn3 `${ 4 }` - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var s = fn3 `${ '' }${ '' }${ '' }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var n = fn3 `${ '' }${ '' }${ 3 }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic overloads with differing arity tagging with argument count that doesn't match any overload fn3 ``; // Error ~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. - ~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic overloads with constraints function fn4(strs: TemplateStringsArray, n: T, m: U); @@ -115,32 +67,18 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio // Generic overloads with constraints tagged with types that satisfy the constraints fn4 `${ '' }${ 3 }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. fn4 `${ 3 }${ '' }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. fn4 `${ 3 }${ undefined }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. fn4 `${ '' }${ null }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic overloads with constraints called with type arguments that do not satisfy the constraints fn4 `${ null }${ null }`; // Error - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints fn4 `${ true }${ null }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~ !!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. fn4 `${ null }${ true }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~ !!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. @@ -149,12 +87,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio function fn5(strs: TemplateStringsArray, f: (n: number) => void): number; function fn5() { return undefined; } fn5 `${ (n) => n.toFixed() }`; // will error; 'n' should have type 'string'. - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~~ !!! error TS2339: Property 'toFixed' does not exist on type 'string'. fn5 `${ (n) => n.substr(0) }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js index dc8a08b4fc4..8c7cb986cd7 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js @@ -77,47 +77,48 @@ fn5 `${ (n) => n.substr(0) }`; function fn1() { return null; } -var s = fn1 "" + undefined; +var s = (_a = ["", ""], _a.raw = ["", ""], fn1(_a, undefined)); // No candidate overloads found -fn1 "" + {}; // Error +(_b = ["", ""], _b.raw = ["", ""], fn1(_b, {})); // Error function fn2() { return undefined; } -var d1 = fn2 "" + 0 + undefined; // contextually typed -var d2 = fn2 "" + 0 + undefined; // any +var d1 = (_c = ["", "", ""], _c.raw = ["", "", ""], fn2(_c, 0, undefined)); // contextually typed +var d2 = (_d = ["", "", ""], _d.raw = ["", "", ""], fn2(_d, 0, undefined)); // any d1.foo(); // error d2(); // no error (typed as any) // Generic and non-generic overload where generic overload is the only candidate -fn2 "" + 0 + ''; // OK +(_e = ["", "", ""], _e.raw = ["", "", ""], fn2(_e, 0, '')); // OK // Generic and non-generic overload where non-generic overload is the only candidate -fn2 "" + '' + 0; // OK +(_f = ["", "", ""], _f.raw = ["", "", ""], fn2(_f, '', 0)); // OK function fn3() { return null; } -var s = fn3 "" + 3; -var s = fn3 "" + '' + 3 + ''; -var n = fn3 "" + 5 + 5 + 5; +var s = (_g = ["", ""], _g.raw = ["", ""], fn3(_g, 3)); +var s = (_h = ["", "", "", ""], _h.raw = ["", "", "", ""], fn3(_h, '', 3, '')); +var n = (_j = ["", "", "", ""], _j.raw = ["", "", "", ""], fn3(_j, 5, 5, 5)); var n; // Generic overloads with differing arity tagging with arguments matching each overload type parameter count -var s = fn3 "" + 4; -var s = fn3 "" + '' + '' + ''; -var n = fn3 "" + '' + '' + 3; +var s = (_k = ["", ""], _k.raw = ["", ""], fn3(_k, 4)); +var s = (_l = ["", "", "", ""], _l.raw = ["", "", "", ""], fn3(_l, '', '', '')); +var n = (_m = ["", "", "", ""], _m.raw = ["", "", "", ""], fn3(_m, '', '', 3)); // Generic overloads with differing arity tagging with argument count that doesn't match any overload -fn3 ""; // Error +(_n = [""], _n.raw = [""], fn3(_n)); // Error function fn4() { } // Generic overloads with constraints tagged with types that satisfy the constraints -fn4 "" + '' + 3; -fn4 "" + 3 + ''; -fn4 "" + 3 + undefined; -fn4 "" + '' + null; +(_o = ["", "", ""], _o.raw = ["", "", ""], fn4(_o, '', 3)); +(_p = ["", "", ""], _p.raw = ["", "", ""], fn4(_p, 3, '')); +(_q = ["", "", ""], _q.raw = ["", "", ""], fn4(_q, 3, undefined)); +(_r = ["", "", ""], _r.raw = ["", "", ""], fn4(_r, '', null)); // Generic overloads with constraints called with type arguments that do not satisfy the constraints -fn4 "" + null + null; // Error +(_s = ["", "", ""], _s.raw = ["", "", ""], fn4(_s, null, null)); // Error // Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints -fn4 "" + true + null; -fn4 "" + null + true; +(_t = ["", "", ""], _t.raw = ["", "", ""], fn4(_t, true, null)); +(_u = ["", "", ""], _u.raw = ["", "", ""], fn4(_u, null, true)); function fn5() { return undefined; } -fn5 "" + function (n) { return n.toFixed(); }; // will error; 'n' should have type 'string'. -fn5 "" + function (n) { return n.substr(0); }; +(_v = ["", ""], _v.raw = ["", ""], fn5(_v, function (n) { return n.toFixed(); })); // will error; 'n' should have type 'string'. +(_w = ["", ""], _w.raw = ["", ""], fn5(_w, function (n) { return n.substr(0); })); +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w; diff --git a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt deleted file mode 100644 index 2557d6cc94a..00000000000 --- a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt +++ /dev/null @@ -1,64 +0,0 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(3,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(5,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(7,7): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(9,7): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(11,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(13,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(15,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(17,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,32): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,46): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts (12 errors) ==== - var f: any; - - f `abc` - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc${1}def${2}ghi`; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f.g.h `abc` - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f.g.h `abc${1}def${2}ghi`; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc`.member - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc${1}def${2}ghi`.member; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc`["member"]; - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc${1}def${2}ghi`["member"]; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f.thisIsNotATag(`abc`); - - f.thisIsNotATag(`abc${1}def${2}ghi`); \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.js b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.js index d5c6b8b31f6..fd83d9d0ba0 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.js +++ b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.js @@ -27,15 +27,16 @@ f.thisIsNotATag(`abc${1}def${2}ghi`); //// [taggedTemplateStringsWithTagsTypedAsAny.js] var f; -f "abc"; -f "abc" + 1 + "def" + 2 + "ghi"; -f.g.h "abc"; -f.g.h "abc" + 1 + "def" + 2 + "ghi"; -f "abc".member; -f "abc" + 1 + "def" + 2 + "ghi".member; -f "abc"["member"]; -f "abc" + 1 + "def" + 2 + "ghi"["member"]; -f "abc"["member"].someOtherTag "abc" + 1 + "def" + 2 + "ghi"; -f "abc" + 1 + "def" + 2 + "ghi"["member"].someOtherTag "abc" + 1 + "def" + 2 + "ghi"; +(_a = ["abc"], _a.raw = ["abc"], f(_a)); +(_b = ["abc", "def", "ghi"], _b.raw = ["abc", "def", "ghi"], f(_b, 1, 2)); +(_c = ["abc"], _c.raw = ["abc"], f.g.h(_c)); +(_d = ["abc", "def", "ghi"], _d.raw = ["abc", "def", "ghi"], f.g.h(_d, 1, 2)); +(_e = ["abc"], _e.raw = ["abc"], f(_e)).member; +(_f = ["abc", "def", "ghi"], _f.raw = ["abc", "def", "ghi"], f(_f, 1, 2)).member; +(_g = ["abc"], _g.raw = ["abc"], f(_g))["member"]; +(_h = ["abc", "def", "ghi"], _h.raw = ["abc", "def", "ghi"], f(_h, 1, 2))["member"]; +(_j = ["abc", "def", "ghi"], _j.raw = ["abc", "def", "ghi"], (_k = ["abc"], _k.raw = ["abc"], f(_k))["member"].someOtherTag(_j, 1, 2)); +(_l = ["abc", "def", "ghi"], _l.raw = ["abc", "def", "ghi"], (_m = ["abc", "def", "ghi"], _m.raw = ["abc", "def", "ghi"], f(_m, 1, 2))["member"].someOtherTag(_l, 1, 2)); f.thisIsNotATag("abc"); f.thisIsNotATag("abc" + 1 + "def" + 2 + "ghi"); +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; diff --git a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.types b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.types new file mode 100644 index 00000000000..a9b7c9dfdca --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.types @@ -0,0 +1,66 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts === +var f: any; +>f : any + +f `abc` +>f : any + +f `abc${1}def${2}ghi`; +>f : any + +f.g.h `abc` +>f.g.h : any +>f.g : any +>f : any +>g : any +>h : any + +f.g.h `abc${1}def${2}ghi`; +>f.g.h : any +>f.g : any +>f : any +>g : any +>h : any + +f `abc`.member +>f `abc`.member : any +>f : any +>member : any + +f `abc${1}def${2}ghi`.member; +>f `abc${1}def${2}ghi`.member : any +>f : any +>member : any + +f `abc`["member"]; +>f `abc`["member"] : any +>f : any + +f `abc${1}def${2}ghi`["member"]; +>f `abc${1}def${2}ghi`["member"] : any +>f : any + +f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; +>f `abc`["member"].someOtherTag : any +>f `abc`["member"] : any +>f : any +>someOtherTag : any + +f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; +>f `abc${1}def${2}ghi`["member"].someOtherTag : any +>f `abc${1}def${2}ghi`["member"] : any +>f : any +>someOtherTag : any + +f.thisIsNotATag(`abc`); +>f.thisIsNotATag(`abc`) : any +>f.thisIsNotATag : any +>f : any +>thisIsNotATag : any + +f.thisIsNotATag(`abc${1}def${2}ghi`); +>f.thisIsNotATag(`abc${1}def${2}ghi`) : any +>f.thisIsNotATag : any +>f : any +>thisIsNotATag : any + diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt index b38a70ca18b..88bfac23211 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt @@ -1,15 +1,12 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,31): error TS2322: Type 'string' is not assignable to type 'number'. -==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (2 errors) ==== +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (1 errors) ==== function foo(...rest: any[]) { } foo `${function (x: number) { x = "bad"; } }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js index eb46f4b603f..10a8f1f2a12 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js +++ b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js @@ -13,6 +13,7 @@ function foo() { rest[_i - 0] = arguments[_i]; } } -foo "" + function (x) { +(_a = ["", ""], _a.raw = ["", ""], foo(_a, function (x) { x = "bad"; -}; +})); +var _a; diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt deleted file mode 100644 index 28050ec96c1..00000000000 --- a/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt +++ /dev/null @@ -1,64 +0,0 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(12,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(14,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(16,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(18,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(20,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(22,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,19): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,40): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts (10 errors) ==== - interface I { - (stringParts: string[], ...rest: number[]): I; - g: I; - h: I; - member: I; - thisIsNotATag(x: string): void - [x: number]: I; - } - - var f: I; - - f `abc` - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc${1}def${2}ghi`; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc`.member - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc${1}def${2}ghi`.member; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc`["member"]; - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc${1}def${2}ghi`["member"]; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc`[0].member `abc${1}def${2}ghi`; - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - ~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - f.thisIsNotATag(`abc`); - - f.thisIsNotATag(`abc${1}def${2}ghi`); - \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypedTags.js b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.js index c2424a07a47..fcc2cda86dc 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTypedTags.js +++ b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.js @@ -33,13 +33,14 @@ f.thisIsNotATag(`abc${1}def${2}ghi`); //// [taggedTemplateStringsWithTypedTags.js] var f; -f "abc"; -f "abc" + 1 + "def" + 2 + "ghi"; -f "abc".member; -f "abc" + 1 + "def" + 2 + "ghi".member; -f "abc"["member"]; -f "abc" + 1 + "def" + 2 + "ghi"["member"]; -f "abc"[0].member "abc" + 1 + "def" + 2 + "ghi"; -f "abc" + 1 + "def" + 2 + "ghi"["member"].member "abc" + 1 + "def" + 2 + "ghi"; +(_a = ["abc"], _a.raw = ["abc"], f(_a)); +(_b = ["abc", "def", "ghi"], _b.raw = ["abc", "def", "ghi"], f(_b, 1, 2)); +(_c = ["abc"], _c.raw = ["abc"], f(_c)).member; +(_d = ["abc", "def", "ghi"], _d.raw = ["abc", "def", "ghi"], f(_d, 1, 2)).member; +(_e = ["abc"], _e.raw = ["abc"], f(_e))["member"]; +(_f = ["abc", "def", "ghi"], _f.raw = ["abc", "def", "ghi"], f(_f, 1, 2))["member"]; +(_g = ["abc", "def", "ghi"], _g.raw = ["abc", "def", "ghi"], (_h = ["abc"], _h.raw = ["abc"], f(_h))[0].member(_g, 1, 2)); +(_j = ["abc", "def", "ghi"], _j.raw = ["abc", "def", "ghi"], (_k = ["abc", "def", "ghi"], _k.raw = ["abc", "def", "ghi"], f(_k, 1, 2))["member"].member(_j, 1, 2)); f.thisIsNotATag("abc"); f.thisIsNotATag("abc" + 1 + "def" + 2 + "ghi"); +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypedTags.types b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.types new file mode 100644 index 00000000000..5c8ba71188b --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.types @@ -0,0 +1,82 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts === +interface I { +>I : I + + (stringParts: string[], ...rest: number[]): I; +>stringParts : string[] +>rest : number[] +>I : I + + g: I; +>g : I +>I : I + + h: I; +>h : I +>I : I + + member: I; +>member : I +>I : I + + thisIsNotATag(x: string): void +>thisIsNotATag : (x: string) => void +>x : string + + [x: number]: I; +>x : number +>I : I +} + +var f: I; +>f : I +>I : I + +f `abc` +>f : I + +f `abc${1}def${2}ghi`; +>f : I + +f `abc`.member +>f `abc`.member : I +>f : I +>member : I + +f `abc${1}def${2}ghi`.member; +>f `abc${1}def${2}ghi`.member : I +>f : I +>member : I + +f `abc`["member"]; +>f `abc`["member"] : I +>f : I + +f `abc${1}def${2}ghi`["member"]; +>f `abc${1}def${2}ghi`["member"] : I +>f : I + +f `abc`[0].member `abc${1}def${2}ghi`; +>f `abc`[0].member : I +>f `abc`[0] : I +>f : I +>member : I + +f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; +>f `abc${1}def${2}ghi`["member"].member : I +>f `abc${1}def${2}ghi`["member"] : I +>f : I +>member : I + +f.thisIsNotATag(`abc`); +>f.thisIsNotATag(`abc`) : void +>f.thisIsNotATag : (x: string) => void +>f : I +>thisIsNotATag : (x: string) => void + +f.thisIsNotATag(`abc${1}def${2}ghi`); +>f.thisIsNotATag(`abc${1}def${2}ghi`) : void +>f.thisIsNotATag : (x: string) => void +>f : I +>thisIsNotATag : (x: string) => void + diff --git a/tests/baselines/reference/templateStringInModuleName.js b/tests/baselines/reference/templateStringInModuleName.js index 561f308a3d0..36f619176e4 100644 --- a/tests/baselines/reference/templateStringInModuleName.js +++ b/tests/baselines/reference/templateStringInModuleName.js @@ -7,10 +7,11 @@ declare module `M${2}` { //// [templateStringInModuleName.js] declare; -module "M1"; +(_a = ["M1"], _a.raw = ["M1"], module(_a)); { } declare; -module "M" + 2; +(_b = ["M", ""], _b.raw = ["M", ""], module(_b, 2)); { } +var _a, _b; diff --git a/tests/baselines/reference/templateStringInObjectLiteral.js b/tests/baselines/reference/templateStringInObjectLiteral.js index b026aedf4d3..0381e9a95e7 100644 --- a/tests/baselines/reference/templateStringInObjectLiteral.js +++ b/tests/baselines/reference/templateStringInObjectLiteral.js @@ -5,7 +5,8 @@ var x = { } //// [templateStringInObjectLiteral.js] -var x = { +var x = (_a = ["b"], _a.raw = ["b"], { a: "abc" + 123 + "def" -} "b"; +}(_a)); 321; +var _a; diff --git a/tests/baselines/reference/templateStringInPropertyName1.js b/tests/baselines/reference/templateStringInPropertyName1.js index 5a396398f67..239ba78d827 100644 --- a/tests/baselines/reference/templateStringInPropertyName1.js +++ b/tests/baselines/reference/templateStringInPropertyName1.js @@ -4,5 +4,6 @@ var x = { } //// [templateStringInPropertyName1.js] -var x = {} "a"; +var x = (_a = ["a"], _a.raw = ["a"], {}(_a)); 321; +var _a; diff --git a/tests/baselines/reference/templateStringInPropertyName2.js b/tests/baselines/reference/templateStringInPropertyName2.js index 623f6a69a41..8a71a6e30be 100644 --- a/tests/baselines/reference/templateStringInPropertyName2.js +++ b/tests/baselines/reference/templateStringInPropertyName2.js @@ -4,5 +4,6 @@ var x = { } //// [templateStringInPropertyName2.js] -var x = {} "abc" + 123 + "def" + 456 + "ghi"; +var x = (_a = ["abc", "def", "ghi"], _a.raw = ["abc", "def", "ghi"], {}(_a, 123, 456)); 321; +var _a; diff --git a/tests/baselines/reference/templateStringInTaggedTemplate.errors.txt b/tests/baselines/reference/templateStringInTaggedTemplate.errors.txt index 9106cdb6151..18ce24a0b3b 100644 --- a/tests/baselines/reference/templateStringInTaggedTemplate.errors.txt +++ b/tests/baselines/reference/templateStringInTaggedTemplate.errors.txt @@ -1,10 +1,7 @@ tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts(1,42): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -==== tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts (2 errors) ==== +==== tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts (1 errors) ==== `I AM THE ${ `${ `TAG` } ` } PORTION` `I ${ "AM" } THE TEMPLATE PORTION` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. \ No newline at end of file +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInTaggedTemplate.js b/tests/baselines/reference/templateStringInTaggedTemplate.js index c6d98b0f826..61964b06d47 100644 --- a/tests/baselines/reference/templateStringInTaggedTemplate.js +++ b/tests/baselines/reference/templateStringInTaggedTemplate.js @@ -2,4 +2,5 @@ `I AM THE ${ `${ `TAG` } ` } PORTION` `I ${ "AM" } THE TEMPLATE PORTION` //// [templateStringInTaggedTemplate.js] -"I AM THE " + "TAG" + " " + " PORTION" "I " + "AM" + " THE TEMPLATE PORTION"; +(_a = ["I ", " THE TEMPLATE PORTION"], _a.raw = ["I ", " THE TEMPLATE PORTION"], "I AM THE " + "TAG" + " " + " PORTION"(_a, "AM")); +var _a; diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index 61b82bcb459..7ac2eff8652 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -2,10 +2,9 @@ lib.d.ts(515,11): error TS2300: Duplicate identifier 'TemplateStringsArray'. tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'. tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{ [x: number]: undefined; }'. -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(10,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (3 errors) ==== +==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (2 errors) ==== class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ @@ -20,6 +19,4 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(10,3): error TS !!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. !!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'. - f `abcdef${ 1234 }${ 5678 }ghijkl`; - ~~~~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. \ No newline at end of file + f `abcdef${ 1234 }${ 5678 }ghijkl`; \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.js b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.js index a724943c0f3..5d5f925fe69 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.js +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.js @@ -19,4 +19,5 @@ var TemplateStringsArray = (function () { function f(x, y, z) { } f({}, 10, 10); -f "abcdef" + 1234 + 5678 + "ghijkl"; +(_a = ["abcdef", "", "ghijkl"], _a.raw = ["abcdef", "", "ghijkl"], f(_a, 1234, 5678)); +var _a; diff --git a/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.errors.txt index b233ad963c7..e8bf38c1048 100644 --- a/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.errors.txt @@ -1,9 +1,8 @@ tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(5,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{ [x: number]: undefined; }'. -tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(7,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -==== tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts (2 errors) ==== +==== tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts (1 errors) ==== function f(x: TemplateStringsArray, y: number, z: number) { } @@ -13,6 +12,4 @@ tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(7,3): error TS !!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. !!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'. - f `abcdef${ 1234 }${ 5678 }ghijkl`; - ~~~~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. \ No newline at end of file + f `abcdef${ 1234 }${ 5678 }ghijkl`; \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.js b/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.js index c6cc4ee8408..69d61d79554 100644 --- a/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.js +++ b/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.js @@ -11,4 +11,5 @@ f `abcdef${ 1234 }${ 5678 }ghijkl`; function f(x, y, z) { } f({}, 10, 10); -f "abcdef" + 1234 + 5678 + "ghijkl"; +(_a = ["abcdef", "", "ghijkl"], _a.raw = ["abcdef", "", "ghijkl"], f(_a, 1234, 5678)); +var _a; From f77bedd6f671a8a70c0baa4ec3558f8628177de0 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Fri, 13 Feb 2015 18:34:32 +0100 Subject: [PATCH 16/96] Emit parens for tag of tagged template if necessary --- src/compiler/emitter.ts | 6 +++--- tests/baselines/reference/templateStringInObjectLiteral.js | 4 ++-- tests/baselines/reference/templateStringInPropertyName1.js | 2 +- tests/baselines/reference/templateStringInPropertyName2.js | 2 +- tests/baselines/reference/templateStringInTaggedTemplate.js | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5059448903c..108fa8a5e41 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2189,7 +2189,7 @@ module ts { } write("], "); - emit(node.tag); + emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); @@ -2475,7 +2475,7 @@ module ts { emit((node).expression); } - function needsParenthesisForPropertyAccess(node: Expression) { + function needsParenthesisForPropertyAccessOrInvocation(node: Expression) { switch (node.kind) { case SyntaxKind.Identifier: case SyntaxKind.ArrayLiteralExpression: @@ -2517,7 +2517,7 @@ module ts { var e = elements[pos]; if (e.kind === SyntaxKind.SpreadElementExpression) { e = (e).expression; - emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccess(e)); + emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; } else { diff --git a/tests/baselines/reference/templateStringInObjectLiteral.js b/tests/baselines/reference/templateStringInObjectLiteral.js index 0381e9a95e7..5a096b0adfa 100644 --- a/tests/baselines/reference/templateStringInObjectLiteral.js +++ b/tests/baselines/reference/templateStringInObjectLiteral.js @@ -5,8 +5,8 @@ var x = { } //// [templateStringInObjectLiteral.js] -var x = (_a = ["b"], _a.raw = ["b"], { +var x = (_a = ["b"], _a.raw = ["b"], ({ a: "abc" + 123 + "def" -}(_a)); +})(_a)); 321; var _a; diff --git a/tests/baselines/reference/templateStringInPropertyName1.js b/tests/baselines/reference/templateStringInPropertyName1.js index 239ba78d827..18e35c475e3 100644 --- a/tests/baselines/reference/templateStringInPropertyName1.js +++ b/tests/baselines/reference/templateStringInPropertyName1.js @@ -4,6 +4,6 @@ var x = { } //// [templateStringInPropertyName1.js] -var x = (_a = ["a"], _a.raw = ["a"], {}(_a)); +var x = (_a = ["a"], _a.raw = ["a"], ({})(_a)); 321; var _a; diff --git a/tests/baselines/reference/templateStringInPropertyName2.js b/tests/baselines/reference/templateStringInPropertyName2.js index 8a71a6e30be..1a2995ca08f 100644 --- a/tests/baselines/reference/templateStringInPropertyName2.js +++ b/tests/baselines/reference/templateStringInPropertyName2.js @@ -4,6 +4,6 @@ var x = { } //// [templateStringInPropertyName2.js] -var x = (_a = ["abc", "def", "ghi"], _a.raw = ["abc", "def", "ghi"], {}(_a, 123, 456)); +var x = (_a = ["abc", "def", "ghi"], _a.raw = ["abc", "def", "ghi"], ({})(_a, 123, 456)); 321; var _a; diff --git a/tests/baselines/reference/templateStringInTaggedTemplate.js b/tests/baselines/reference/templateStringInTaggedTemplate.js index 61964b06d47..3ba70ba84b6 100644 --- a/tests/baselines/reference/templateStringInTaggedTemplate.js +++ b/tests/baselines/reference/templateStringInTaggedTemplate.js @@ -2,5 +2,5 @@ `I AM THE ${ `${ `TAG` } ` } PORTION` `I ${ "AM" } THE TEMPLATE PORTION` //// [templateStringInTaggedTemplate.js] -(_a = ["I ", " THE TEMPLATE PORTION"], _a.raw = ["I ", " THE TEMPLATE PORTION"], "I AM THE " + "TAG" + " " + " PORTION"(_a, "AM")); +(_a = ["I ", " THE TEMPLATE PORTION"], _a.raw = ["I ", " THE TEMPLATE PORTION"], ("I AM THE " + "TAG" + " " + " PORTION")(_a, "AM")); var _a; From a0bcd7eabfa2c7a9706e0aff3cd752fd95c6864b Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Sat, 14 Feb 2015 00:48:46 -0800 Subject: [PATCH 17/96] initial revision of downlevel compilation for let/const bindings --- src/compiler/checker.ts | 37 +++++-- src/compiler/emitter.ts | 238 +++++++++++++++++++++++++++++++++++----- src/compiler/types.ts | 1 + 3 files changed, 237 insertions(+), 39 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cccd74e3907..68eb3e3e960 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -264,7 +264,7 @@ module ts { Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; - } + } if (symbol.flags & SymbolFlags.Import) { var target = resolveImport(symbol); @@ -10207,7 +10207,30 @@ module ts { } function isUnknownIdentifier(location: Node, name: string): boolean { - return !resolveName(location, name, SymbolFlags.Value, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); + return !resolveName(location, name, SymbolFlags.Value | SymbolFlags.Import, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); + } + + function getBlockScopedVariableId(n: Identifier): number { + Debug.assert(n.parent !== undefined); + + // ignore name parts of property access expressions + if (n.parent.kind === SyntaxKind.PropertyAccessExpression && + (n.parent).name === n) { + return undefined; + } + + // for names in variable declarations and binding elements try to short circuit and fetch symbol from the node + var declarationSymbol: Symbol = + (n.parent.kind === SyntaxKind.VariableDeclaration && (n.parent).name === n) || + n.parent.kind === SyntaxKind.BindingElement + ? getSymbolOfNode(n.parent) + : undefined; + + var symbol = declarationSymbol || + getNodeLinks(n).resolvedSymbol || + resolveName(n, n.text, SymbolFlags.BlockScopedVariable | SymbolFlags.Import, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); + + return symbol && symbol.flags & SymbolFlags.BlockScopedVariable ? symbol.id : undefined; } function createResolver(): EmitResolver { @@ -10226,6 +10249,7 @@ module ts { isEntityNameVisible, getConstantValue, isUnknownIdentifier, + getBlockScopedVariableId, }; } @@ -10953,15 +10977,6 @@ module ts { if (!declarationList.declarations.length) { return grammarErrorAtPos(getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty); } - - if (languageVersion < ScriptTarget.ES6) { - if (isLet(declarationList)) { - return grammarErrorOnFirstToken(declarationList, Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - else if (isConst(declarationList)) { - return grammarErrorOnFirstToken(declarationList, Diagnostics.const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - } } function allowLetAndConstDeclarations(parent: Node): boolean { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 6a2338268e8..a6681b032ce 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -21,6 +21,12 @@ module ts { diagnosticMessage: DiagnosticMessage; typeName?: DeclarationName; } + + interface ScopeFrame { + names: Map; + previous: ScopeFrame; + } + type GetSymbolAccessibilityDiagnostic = (symbolAccesibilityResult: SymbolAccessiblityResult) => SymbolAccessibilityDiagnostic; interface EmitTextWriterWithSymbolWriter extends EmitTextWriter, SymbolWriter { @@ -353,7 +359,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; @@ -1557,6 +1562,11 @@ module ts { var currentSourceFile: SourceFile; + var lastFrame: ScopeFrame; + var currentScopeNames: Map; + + var generatedBlockScopeNames: string[]; + var extendsEmitted = false; var tempCount = 0; var tempVariables: Identifier[]; @@ -1629,6 +1639,82 @@ module ts { writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); return; + function enterScope(): boolean { + var names = currentScopeNames; + currentScopeNames = undefined; + if (names) { + lastFrame = { names, previous: lastFrame }; + return true; + } + return false; + } + + function exitScope(popFrame: boolean): void { + if (popFrame) { + currentScopeNames = lastFrame.names; + lastFrame = lastFrame.previous; + } + else { + currentScopeNames = undefined; + } + } + + function makeUniqueName(location: Node, baseName: string): string { + if (!isExistingName(location, baseName)) { + // use current name as is + return setGeneratedName(baseName); + } + + // First try '_name' + if (baseName.charCodeAt(0) !== CharacterCodes._) { + var baseName = "_" + baseName; + if (!isExistingName(location, baseName)) { + return setGeneratedName(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(location, name)) { + return setGeneratedName(name); + } + i++; + } + } + + function setGeneratedName(name: string): string { + if (!currentScopeNames) { + currentScopeNames = {}; + } + + return currentScopeNames[name] = name; + } + + + function isExistingName(location: Node, name: string) { + if (!resolver.isUnknownIdentifier(location, name)) { + return true; + } + + if (currentScopeNames && hasProperty(currentScopeNames, name)) { + return true; + } + + var frame = lastFrame; + while (frame) { + if (hasProperty(frame.names, name)) { + return true; + } + frame = frame.previous; + } + + return false; + } + function initializeEmitterWithSourceMaps() { var sourceMapDir: string; // The directory in which sourcemap will be @@ -1990,7 +2076,7 @@ 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, ... @@ -2338,7 +2424,20 @@ module ts { writeTextOfNode(currentSourceFile, node); } + function getBlockScopedVariableId(node: Identifier): number { + // return undefined for synthesized nodes + return node.parent && resolver.getBlockScopedVariableId(node); + } + function emitIdentifier(node: Identifier) { + var symbolId = getBlockScopedVariableId(node); + if (symbolId !== undefined && generatedBlockScopeNames) { + var text = generatedBlockScopeNames[symbolId]; + if (text) { + write(text); + return; + } + } if (!node.parent) { write(node.text); } @@ -2881,6 +2980,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(" "); @@ -2888,17 +3013,9 @@ module ts { if (node.initializer && node.initializer.kind === SyntaxKind.VariableDeclarationList) { var variableDeclarationList = node.initializer; var declarations = variableDeclarationList.declarations; - if (declarations[0] && isLet(declarations[0])) { - emitToken(SyntaxKind.LetKeyword, endPos); - } - else if (declarations[0] && isConst(declarations[0])) { - emitToken(SyntaxKind.ConstKeyword, endPos); - } - else { - emitToken(SyntaxKind.VarKeyword, endPos); - } + emitStartOfVariableDeclarationList(declarations[0], endPos); write(" "); - emitCommaList(variableDeclarationList.declarations); + emitCommaList(declarations); } else if (node.initializer) { emit(node.initializer); @@ -2919,12 +3036,7 @@ module ts { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { var decl = variableDeclarationList.declarations[0]; - if (isLet(decl)) { - emitToken(SyntaxKind.LetKeyword, endPos); - } - else { - emitToken(SyntaxKind.VarKeyword, endPos); - } + emitStartOfVariableDeclarationList(decl, endPos); write(" "); emit(decl); } @@ -3075,6 +3187,8 @@ module ts { if (emitCount++) { write(", "); } + + renameNonTopLevelLetAndConst(name); if (name.parent && (name.parent.kind === SyntaxKind.VariableDeclaration || name.parent.kind === SyntaxKind.BindingElement)) { emitModuleMemberName(name.parent); } @@ -3184,7 +3298,7 @@ module ts { emitDestructuringAssignment(e, createElementAccess(value, createNumericLiteral(i))); } else { - if (i === elements.length - 1) { + if (i === elements.length - 1 && (e).expression.kind === SyntaxKind.Identifier) { value = ensureIdentifier(value); emitAssignment((e).expression, value); write(".slice(" + i + ")"); @@ -3286,22 +3400,75 @@ module ts { } } else { + renameNonTopLevelLetAndConst(node.name); emitModuleMemberName(node); emitOptional(" = ", node.initializer); } } + function getEnclosingBlockScopeContainer(node: Node): Node { + var current = node; + while (current) { + if (isAnyFunction(current)) { + return current.parent; + } + switch (current.kind) { + case SyntaxKind.CatchClause: + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.SwitchKeyword: + return current.parent; + case SyntaxKind.Block: + if (isAnyFunction(current.parent)) { + return current.parent.parent; + } + else { + return current.parent; + } + case SyntaxKind.SourceFile: + return current; + } + + current = current.parent; + } + } + + function renameNonTopLevelLetAndConst(node: Node): void { + // do not rename if + // - language version is ES6+ + // - node is synthesized (does not have a parent) + // - 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 || + !node.parent || + (node.parent.kind !== SyntaxKind.VariableDeclaration && node.parent.kind !== SyntaxKind.BindingElement)) { + return; + } + + var combinedFlags = getCombinedNodeFlags(node.parent); + 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 generatedName = makeUniqueName(getEnclosingBlockScopeContainer(node), (node).text); + var symbolId = resolver.getBlockScopedVariableId(node); + if (!generatedBlockScopeNames) { + generatedBlockScopeNames = []; + } + generatedBlockScopeNames[symbolId] = 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(";"); @@ -3472,6 +3639,8 @@ module ts { tempVariables = undefined; tempParameters = undefined; + var popFrame = enterScope() + // When targeting ES6, emit arrow function natively in ES6 if (shouldEmitAsArrowFunction(node)) { emitSignatureParametersForArrow(node); @@ -3563,6 +3732,9 @@ module ts { emitEnd(node); write(";"); } + + exitScope(popFrame); + tempCount = saveTempCount; tempVariables = saveTempVariables; tempParameters = saveTempParameters; @@ -3773,6 +3945,9 @@ module ts { tempCount = 0; tempVariables = undefined; tempParameters = undefined; + + var popFrame = enterScope(); + // Emit the constructor overload pinned comments forEach(node.members, member => { if (member.kind === SyntaxKind.Constructor && !(member).body) { @@ -3833,6 +4008,9 @@ module ts { if (ctor) { emitTrailingComments(ctor); } + + exitScope(popFrame); + tempCount = saveTempCount; tempVariables = saveTempVariables; tempParameters = saveTempParameters; @@ -3962,7 +4140,11 @@ module ts { var saveTempVariables = tempVariables; tempCount = 0; tempVariables = undefined; + var popFrame = enterScope(); + emit(node.body); + + exitScope(popFrame); tempCount = saveTempCount; tempVariables = saveTempVariables; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 12c5af21e12..b4e848f1e52 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1138,6 +1138,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 { From ba52d60c7a99223c47477063b26095678912d19b Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Sat, 14 Feb 2015 14:23:37 -0800 Subject: [PATCH 18/96] try only names generated in current scope with testing if name is unique --- src/compiler/emitter.ts | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a6681b032ce..da19862e3d8 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1696,23 +1696,7 @@ module ts { function isExistingName(location: Node, name: string) { - if (!resolver.isUnknownIdentifier(location, name)) { - return true; - } - - if (currentScopeNames && hasProperty(currentScopeNames, name)) { - return true; - } - - var frame = lastFrame; - while (frame) { - if (hasProperty(frame.names, name)) { - return true; - } - frame = frame.previous; - } - - return false; + return !resolver.isUnknownIdentifier(location, name) || (currentScopeNames && hasProperty(currentScopeNames, name)); } function initializeEmitterWithSourceMaps() { From 7f5fb8bc19005a0082fd627f82c8606799709178 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Sat, 14 Feb 2015 16:11:58 -0800 Subject: [PATCH 19/96] drop locals in block-scope container nodes during binding --- src/compiler/binder.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index be9e9a525c0..5657ce4e8e0 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -78,7 +78,8 @@ module ts { if (!file.locals) { file.locals = {}; - container = blockScopeContainer = file; + container = file; + setBlockScopeContainer(file, /*cleanLocals*/ false); bind(file); file.symbolCount = symbolCount; } @@ -88,6 +89,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 = []; @@ -244,7 +252,10 @@ module ts { } if (isBlockScopeContainer) { - blockScopeContainer = node; + // clean locals in block scope container if + // - current node does not have local variables + // - current node is not source file (source file always have locals) + setBlockScopeContainer(node, /*cleanLocals*/ (symbolKind & SymbolFlags.HasLocals) == 0 && node.kind !== SyntaxKind.SourceFile); } forEachChild(node, bind); @@ -347,7 +358,8 @@ module ts { addDeclarationToSymbol(symbol, node, SymbolFlags.FunctionScopedVariable); var saveParent = parent; var savedBlockScopeContainer = blockScopeContainer; - parent = blockScopeContainer = node; + parent = node; + setBlockScopeContainer(node, /*cleanLocals*/ true); forEachChild(node, bind); parent = saveParent; blockScopeContainer = savedBlockScopeContainer; From 5f2588f018040f5fcd2a5cb9e31d90fd72b4c597 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Sun, 15 Feb 2015 18:44:25 -0800 Subject: [PATCH 20/96] show error if block scoped variable declared in the loop is captured in closure --- src/compiler/checker.ts | 45 +++++++++++++++++++ .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++ src/compiler/types.ts | 1 + 4 files changed, 51 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4fd925947f4..211331579cd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4905,10 +4905,55 @@ module ts { checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkBlockScopedBindingCapturedInLoop(node, symbol); return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); } + function isNameScopeBoundary(n: Node): boolean { + return isAnyFunction(n) || n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.SourceFile; + } + + function checkBlockScopedBindingCapturedInLoop(node: Identifier, symbol: Symbol): void { + if (languageVersion >= ScriptTarget.ES6 || (symbol.flags & SymbolFlags.BlockScopedVariable) === 0) { + 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 + + // var decl -> var decl list -> parent + var container = (symbol.valueDeclaration).parent.parent; + if (container.kind === SyntaxKind.VariableStatement) { + container = container.parent; + } + + var inFunction = false; + var current = node.parent; + while (current && current !== container) { + if (isAnyFunction(current)) { + inFunction = true; + break; + } + current = current.parent; + } + + if (!inFunction) { + return; + } + + var current: Node = container; + while (current && !isNameScopeBoundary(current)) { + if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { + getNodeLinks(current).flags |= NodeCheckFlags.BlockScopedBindingCapturedInLoop; + grammarErrorOnFirstToken(current, Diagnostics.Code_in_the_loop_captures_block_scoped_variable_0_in_closure_This_is_natively_supported_in_ECMAScript_6_or_higher, declarationNameToString(node)); + 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; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index c6061e3570a..a6e8f25e0a2 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -382,6 +382,7 @@ module ts { Property_0_does_not_exist_on_const_enum_1: { code: 4088, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." }, let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 4089, category: DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 4090, category: DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, + Code_in_the_loop_captures_block_scoped_variable_0_in_closure_This_is_natively_supported_in_ECMAScript_6_or_higher: { code: 4091, category: DiagnosticCategory.Error, key: "Code in the loop captures block-scoped variable '{0}' in closure. This is natively supported in ECMAScript 6 or higher." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index fdeec58a705..f3622218eef 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1521,6 +1521,10 @@ "category": "Error", "code": 4090 }, + "Code in the loop captures block-scoped variable '{0}' in closure. This is natively supported in ECMAScript 6 or higher.": { + "category": "Error", + "code": 4091 + }, "The current host does not support the '{0}' option.": { "category": "Error", "code": 5001 diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b4e848f1e52..940a4a6e5a4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1262,6 +1262,7 @@ module ts { // Values for enum members have been computed, and any errors have been reported for them. EnumValuesComputed = 0x00000080, + BlockScopedBindingCapturedInLoop = 0x00000100, } export interface NodeLinks { From c4008c3497d3f8d2a4e86bc606552f1047009b1a Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Mon, 16 Feb 2015 20:16:13 +0100 Subject: [PATCH 21/96] Update tests Fixed merge conflicts in tests --- ...gedTemplateStringsTypeArgumentInference.js | 76 +++---------------- ...dTemplateStringsWithOverloadResolution3.js | 6 -- 2 files changed, 11 insertions(+), 71 deletions(-) diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js index 8ea51853350..5b078893c6e 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js @@ -95,100 +95,46 @@ var arr: any[]; //// [taggedTemplateStringsTypeArgumentInference.js] // Generic tag with one parameter -<<<<<<< HEAD -function noParams(n) { -} +function noParams(n) { } (_a = [""], _a.raw = [""], noParams(_a)); // Generic tag with parameter which does not use type parameter -function noGenericParams(n) { -} +function noGenericParams(n) { } (_b = [""], _b.raw = [""], noGenericParams(_b)); // Generic tag with multiple type parameters and only one used in parameter type annotation -function someGenerics1a(n, m) { -} +function someGenerics1a(n, m) { } (_c = ["", ""], _c.raw = ["", ""], someGenerics1a(_c, 3)); -function someGenerics1b(n, m) { -} +function someGenerics1b(n, m) { } (_d = ["", ""], _d.raw = ["", ""], someGenerics1b(_d, 3)); // Generic tag with argument of function type whose parameter is of type parameter type -function someGenerics2a(strs, n) { -} +function someGenerics2a(strs, n) { } (_e = ["", ""], _e.raw = ["", ""], someGenerics2a(_e, function (n) { return n; })); -function someGenerics2b(strs, n) { -} +function someGenerics2b(strs, n) { } (_f = ["", ""], _f.raw = ["", ""], someGenerics2b(_f, function (n, x) { return n; })); // Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter -function someGenerics3(strs, producer) { -} +function someGenerics3(strs, producer) { } (_g = ["", ""], _g.raw = ["", ""], someGenerics3(_g, function () { return ''; })); (_h = ["", ""], _h.raw = ["", ""], someGenerics3(_h, function () { return undefined; })); (_j = ["", ""], _j.raw = ["", ""], someGenerics3(_j, function () { return 3; })); // 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type -function someGenerics4(strs, n, f) { -} +function someGenerics4(strs, n, f) { } (_k = ["", "", ""], _k.raw = ["", "", ""], someGenerics4(_k, 4, function () { return null; })); (_l = ["", "", ""], _l.raw = ["", "", ""], someGenerics4(_l, '', function () { return 3; })); (_m = ["", "", ""], _m.raw = ["", "", ""], someGenerics4(_m, null, null)); // 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type -function someGenerics5(strs, n, f) { -} +function someGenerics5(strs, n, f) { } (_n = ["", " ", ""], _n.raw = ["", " ", ""], someGenerics5(_n, 4, function () { return null; })); (_o = ["", "", ""], _o.raw = ["", "", ""], someGenerics5(_o, '', function () { return 3; })); (_p = ["", "", ""], _p.raw = ["", "", ""], someGenerics5(_p, null, null)); // Generic tag with multiple arguments of function types that each have parameters of the same generic type -function someGenerics6(strs, a, b, c) { -} +function someGenerics6(strs, a, b, c) { } (_q = ["", "", "", ""], _q.raw = ["", "", "", ""], someGenerics6(_q, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); (_r = ["", "", "", ""], _r.raw = ["", "", "", ""], someGenerics6(_r, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); (_s = ["", "", "", ""], _s.raw = ["", "", "", ""], someGenerics6(_s, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); // Generic tag with multiple arguments of function types that each have parameters of different generic type -function someGenerics7(strs, a, b, c) { -} +function someGenerics7(strs, a, b, c) { } (_t = ["", "", "", ""], _t.raw = ["", "", "", ""], someGenerics7(_t, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); (_u = ["", "", "", ""], _u.raw = ["", "", "", ""], someGenerics7(_u, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); (_v = ["", "", "", ""], _v.raw = ["", "", "", ""], someGenerics7(_v, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); -======= -function noParams(n) { } -noParams ""; -// Generic tag with parameter which does not use type parameter -function noGenericParams(n) { } -noGenericParams ""; -// Generic tag with multiple type parameters and only one used in parameter type annotation -function someGenerics1a(n, m) { } -someGenerics1a "" + 3; -function someGenerics1b(n, m) { } -someGenerics1b "" + 3; -// Generic tag with argument of function type whose parameter is of type parameter type -function someGenerics2a(strs, n) { } -someGenerics2a "" + function (n) { return n; }; -function someGenerics2b(strs, n) { } -someGenerics2b "" + function (n, x) { return n; }; -// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter -function someGenerics3(strs, producer) { } -someGenerics3 "" + function () { return ''; }; -someGenerics3 "" + function () { return undefined; }; -someGenerics3 "" + function () { return 3; }; -// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type -function someGenerics4(strs, n, f) { } -someGenerics4 "" + 4 + function () { return null; }; -someGenerics4 "" + '' + function () { return 3; }; -someGenerics4 "" + null + null; -// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type -function someGenerics5(strs, n, f) { } -someGenerics5 4 + " " + function () { return null; }; -someGenerics5 "" + '' + function () { return 3; }; -someGenerics5 "" + null + null; -// Generic tag with multiple arguments of function types that each have parameters of the same generic type -function someGenerics6(strs, a, b, c) { } -someGenerics6 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; -someGenerics6 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; -someGenerics6 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; -// Generic tag with multiple arguments of function types that each have parameters of different generic type -function someGenerics7(strs, a, b, c) { } -someGenerics7 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; -someGenerics7 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; -someGenerics7 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; ->>>>>>> master // Generic tag with argument of generic function type function someGenerics8(strs, n) { return n; diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js index 3ef61d2c66b..dfb4bf43b35 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js @@ -103,14 +103,8 @@ var s = (_k = ["", ""], _k.raw = ["", ""], fn3(_k, 4)); var s = (_l = ["", "", "", ""], _l.raw = ["", "", "", ""], fn3(_l, '', '', '')); var n = (_m = ["", "", "", ""], _m.raw = ["", "", "", ""], fn3(_m, '', '', 3)); // Generic overloads with differing arity tagging with argument count that doesn't match any overload -<<<<<<< HEAD (_n = [""], _n.raw = [""], fn3(_n)); // Error -function fn4() { -} -======= -fn3 ""; // Error function fn4() { } ->>>>>>> master // Generic overloads with constraints tagged with types that satisfy the constraints (_o = ["", "", ""], _o.raw = ["", "", ""], fn4(_o, '', 3)); (_p = ["", "", ""], _p.raw = ["", "", ""], fn4(_p, 3, '')); From 4aff9c357d31a5b3e2efce40b313d83b93eb2b1e Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 16 Feb 2015 13:39:32 -0800 Subject: [PATCH 22/96] explicitly initialize let binding in generated code to default value --- src/compiler/emitter.ts | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index da19862e3d8..638b78812cc 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3155,6 +3155,14 @@ module ts { emitEnd(node.name); } + function createVoidZero(): Expression { + var zero = createNode(SyntaxKind.NumericLiteral); + zero.text = "0"; + var result = createNode(SyntaxKind.VoidExpression); + result.expression = zero; + return result; + } + function emitDestructuring(root: BinaryExpression | VariableDeclaration | ParameterDeclaration, value?: Expression) { var emitCount = 0; // An exported declaration is actually emitted as an assignment (to a property on the module object), so @@ -3195,14 +3203,6 @@ module ts { return expr; } - function createVoidZero(): Expression { - var zero = createNode(SyntaxKind.NumericLiteral); - zero.text = "0"; - var result = createNode(SyntaxKind.VoidExpression); - result.expression = zero; - return result; - } - function createDefaultValueCheck(value: Expression, defaultValue: Expression): Expression { // The value expression will be evaluated twice, so for anything but a simple identifier // we need to generate a temporary variable @@ -3384,9 +3384,14 @@ module ts { } } else { - renameNonTopLevelLetAndConst(node.name); + var initializeToDefault = renameNonTopLevelLetAndConst(node.name); emitModuleMemberName(node); - emitOptional(" = ", node.initializer); + + var initializer = + node.initializer || + (initializeToDefault && createVoidZero()); + + emitOptional(" = ", initializer); } } @@ -3417,7 +3422,7 @@ module ts { } } - function renameNonTopLevelLetAndConst(node: Node): void { + function renameNonTopLevelLetAndConst(node: Node): boolean { // do not rename if // - language version is ES6+ // - node is synthesized (does not have a parent) @@ -3426,20 +3431,20 @@ module ts { if (languageVersion >= ScriptTarget.ES6 || !node.parent || (node.parent.kind !== SyntaxKind.VariableDeclaration && node.parent.kind !== SyntaxKind.BindingElement)) { - return; + return false; } var combinedFlags = getCombinedNodeFlags(node.parent); if (((combinedFlags & NodeFlags.BlockScoped) === 0) || combinedFlags & NodeFlags.Export) { // do not rename exported or non-block scoped variables - return; + return false; } // 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; + return false; } var generatedName = makeUniqueName(getEnclosingBlockScopeContainer(node), (node).text); @@ -3448,6 +3453,8 @@ module ts { generatedBlockScopeNames = []; } generatedBlockScopeNames[symbolId] = generatedName; + + return (combinedFlags & NodeFlags.Let) !== 0; } function emitVariableStatement(node: VariableStatement) { From 40bcad994c68675b619fb6fe69c243686817a648 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 17 Feb 2015 15:14:16 -0800 Subject: [PATCH 23/96] accepted baselines --- .../baselines/reference/APISample_compile.js | 2 + .../reference/APISample_compile.types | 8 ++++ tests/baselines/reference/APISample_linter.js | 2 + .../reference/APISample_linter.types | 8 ++++ .../reference/APISample_transform.js | 2 + .../reference/APISample_transform.types | 8 ++++ .../baselines/reference/APISample_watcher.js | 2 + .../reference/APISample_watcher.types | 8 ++++ .../VariableDeclaration10_es6.errors.txt | 7 ---- .../reference/VariableDeclaration10_es6.js | 2 +- .../reference/VariableDeclaration10_es6.types | 4 ++ .../reference/VariableDeclaration11_es6.js | 2 +- .../reference/VariableDeclaration1_es6.js | 2 +- .../VariableDeclaration2_es6.errors.txt | 5 +-- .../reference/VariableDeclaration2_es6.js | 2 +- .../VariableDeclaration3_es6.errors.txt | 7 ---- .../reference/VariableDeclaration3_es6.js | 2 +- .../reference/VariableDeclaration3_es6.types | 4 ++ .../VariableDeclaration4_es6.errors.txt | 5 +-- .../reference/VariableDeclaration4_es6.js | 2 +- .../VariableDeclaration5_es6.errors.txt | 7 ---- .../reference/VariableDeclaration5_es6.js | 2 +- .../reference/VariableDeclaration5_es6.types | 4 ++ .../VariableDeclaration7_es6.errors.txt | 7 ---- .../reference/VariableDeclaration7_es6.js | 2 +- .../reference/VariableDeclaration7_es6.types | 4 ++ .../VariableDeclaration8_es6.errors.txt | 7 ---- .../reference/VariableDeclaration8_es6.js | 2 +- .../reference/VariableDeclaration8_es6.types | 4 ++ .../VariableDeclaration9_es6.errors.txt | 7 ---- .../reference/VariableDeclaration9_es6.js | 2 +- .../reference/VariableDeclaration9_es6.types | 4 ++ .../reference/constDeclarations-errors.js | 2 +- .../constDeclarations-es5.errors.txt | 17 -------- .../reference/constDeclarations-es5.js | 6 +-- .../reference/constDeclarations-es5.types | 13 ++++++ ...mitOutputWithEarlySyntacticErrors.baseline | 2 +- .../reference/letAsIdentifierInStrictMode.js | 6 +-- .../letDeclarations-es5-1.errors.txt | 27 ------------- .../reference/letDeclarations-es5-1.js | 12 +++--- .../reference/letDeclarations-es5-1.types | 24 +++++++++++ .../reference/letDeclarations-es5.errors.txt | 40 ------------------- .../reference/letDeclarations-es5.js | 16 ++++---- .../reference/letDeclarations-es5.types | 36 +++++++++++++++++ .../reference/restElementWithInitializer2.js | 2 +- .../shadowingViaLocalValue.errors.txt | 8 +--- .../reference/shadowingViaLocalValue.js | 4 +- 47 files changed, 175 insertions(+), 176 deletions(-) delete mode 100644 tests/baselines/reference/VariableDeclaration10_es6.errors.txt create mode 100644 tests/baselines/reference/VariableDeclaration10_es6.types delete mode 100644 tests/baselines/reference/VariableDeclaration3_es6.errors.txt create mode 100644 tests/baselines/reference/VariableDeclaration3_es6.types delete mode 100644 tests/baselines/reference/VariableDeclaration5_es6.errors.txt create mode 100644 tests/baselines/reference/VariableDeclaration5_es6.types delete mode 100644 tests/baselines/reference/VariableDeclaration7_es6.errors.txt create mode 100644 tests/baselines/reference/VariableDeclaration7_es6.types delete mode 100644 tests/baselines/reference/VariableDeclaration8_es6.errors.txt create mode 100644 tests/baselines/reference/VariableDeclaration8_es6.types delete mode 100644 tests/baselines/reference/VariableDeclaration9_es6.errors.txt create mode 100644 tests/baselines/reference/VariableDeclaration9_es6.types delete mode 100644 tests/baselines/reference/constDeclarations-es5.errors.txt create mode 100644 tests/baselines/reference/constDeclarations-es5.types delete mode 100644 tests/baselines/reference/letDeclarations-es5-1.errors.txt create mode 100644 tests/baselines/reference/letDeclarations-es5-1.types delete mode 100644 tests/baselines/reference/letDeclarations-es5.errors.txt create mode 100644 tests/baselines/reference/letDeclarations-es5.types diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index b91a706aa45..1dbf40e48fa 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -894,6 +894,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, @@ -996,6 +997,7 @@ declare module "typescript" { SuperStatic = 32, ContextChecked = 64, EnumValuesComputed = 128, + BlockScopedBindingCapturedInLoop = 256, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index ae53c666807..09344976ba6 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -2908,6 +2908,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 @@ -3212,6 +3217,9 @@ declare module "typescript" { EnumValuesComputed = 128, >EnumValuesComputed : NodeCheckFlags + + BlockScopedBindingCapturedInLoop = 256, +>BlockScopedBindingCapturedInLoop : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 68c13edb7db..fd097517f27 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -925,6 +925,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, @@ -1027,6 +1028,7 @@ declare module "typescript" { SuperStatic = 32, ContextChecked = 64, EnumValuesComputed = 128, + BlockScopedBindingCapturedInLoop = 256, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 0c153e7b1dc..f68e06fdde7 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -3052,6 +3052,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 @@ -3356,6 +3361,9 @@ declare module "typescript" { EnumValuesComputed = 128, >EnumValuesComputed : NodeCheckFlags + + BlockScopedBindingCapturedInLoop = 256, +>BlockScopedBindingCapturedInLoop : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 0e80f6b55b9..d523f2920ed 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -926,6 +926,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, @@ -1028,6 +1029,7 @@ declare module "typescript" { SuperStatic = 32, ContextChecked = 64, EnumValuesComputed = 128, + BlockScopedBindingCapturedInLoop = 256, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index 0c201b0a5fd..a51cfb586db 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -3004,6 +3004,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 @@ -3308,6 +3313,9 @@ declare module "typescript" { EnumValuesComputed = 128, >EnumValuesComputed : NodeCheckFlags + + BlockScopedBindingCapturedInLoop = 256, +>BlockScopedBindingCapturedInLoop : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 27a2ce5e415..58b6dfbbe5d 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -963,6 +963,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, @@ -1065,6 +1066,7 @@ declare module "typescript" { SuperStatic = 32, ContextChecked = 64, EnumValuesComputed = 128, + BlockScopedBindingCapturedInLoop = 256, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 4e137cae59d..5ec5d51f99d 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -3177,6 +3177,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 @@ -3481,6 +3486,9 @@ declare module "typescript" { EnumValuesComputed = 128, >EnumValuesComputed : NodeCheckFlags + + BlockScopedBindingCapturedInLoop = 256, +>BlockScopedBindingCapturedInLoop : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/VariableDeclaration10_es6.errors.txt b/tests/baselines/reference/VariableDeclaration10_es6.errors.txt deleted file mode 100644 index b7d4bf2f1c3..00000000000 --- a/tests/baselines/reference/VariableDeclaration10_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts(1,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts (1 errors) ==== - let a: number = 1 - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration10_es6.js b/tests/baselines/reference/VariableDeclaration10_es6.js index 14f47cea04d..6edba42ab0d 100644 --- a/tests/baselines/reference/VariableDeclaration10_es6.js +++ b/tests/baselines/reference/VariableDeclaration10_es6.js @@ -2,4 +2,4 @@ let a: number = 1 //// [VariableDeclaration10_es6.js] -let a = 1; +var a = 1; diff --git a/tests/baselines/reference/VariableDeclaration10_es6.types b/tests/baselines/reference/VariableDeclaration10_es6.types new file mode 100644 index 00000000000..47238fdd5a8 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration10_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts === +let a: number = 1 +>a : number + diff --git a/tests/baselines/reference/VariableDeclaration11_es6.js b/tests/baselines/reference/VariableDeclaration11_es6.js index 83eec6d9a13..0000d5cb5ab 100644 --- a/tests/baselines/reference/VariableDeclaration11_es6.js +++ b/tests/baselines/reference/VariableDeclaration11_es6.js @@ -4,4 +4,4 @@ let //// [VariableDeclaration11_es6.js] "use strict"; -let ; +var ; diff --git a/tests/baselines/reference/VariableDeclaration1_es6.js b/tests/baselines/reference/VariableDeclaration1_es6.js index 26433bd88c3..a867d74726c 100644 --- a/tests/baselines/reference/VariableDeclaration1_es6.js +++ b/tests/baselines/reference/VariableDeclaration1_es6.js @@ -2,4 +2,4 @@ const //// [VariableDeclaration1_es6.js] -const ; +var ; diff --git a/tests/baselines/reference/VariableDeclaration2_es6.errors.txt b/tests/baselines/reference/VariableDeclaration2_es6.errors.txt index 0d8214f5420..35e0ad2821c 100644 --- a/tests/baselines/reference/VariableDeclaration2_es6.errors.txt +++ b/tests/baselines/reference/VariableDeclaration2_es6.errors.txt @@ -1,10 +1,7 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts(1,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts(1,7): error TS1155: 'const' declarations must be initialized -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts (1 errors) ==== const a - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. ~ !!! error TS1155: 'const' declarations must be initialized \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration2_es6.js b/tests/baselines/reference/VariableDeclaration2_es6.js index a955315a2f0..d835435a0a6 100644 --- a/tests/baselines/reference/VariableDeclaration2_es6.js +++ b/tests/baselines/reference/VariableDeclaration2_es6.js @@ -2,4 +2,4 @@ const a //// [VariableDeclaration2_es6.js] -const a; +var a; diff --git a/tests/baselines/reference/VariableDeclaration3_es6.errors.txt b/tests/baselines/reference/VariableDeclaration3_es6.errors.txt deleted file mode 100644 index a3b09f70d2d..00000000000 --- a/tests/baselines/reference/VariableDeclaration3_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts(1,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts (1 errors) ==== - const a = 1 - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration3_es6.js b/tests/baselines/reference/VariableDeclaration3_es6.js index 4be8a3daf38..08513b8bdbc 100644 --- a/tests/baselines/reference/VariableDeclaration3_es6.js +++ b/tests/baselines/reference/VariableDeclaration3_es6.js @@ -2,4 +2,4 @@ const a = 1 //// [VariableDeclaration3_es6.js] -const a = 1; +var a = 1; diff --git a/tests/baselines/reference/VariableDeclaration3_es6.types b/tests/baselines/reference/VariableDeclaration3_es6.types new file mode 100644 index 00000000000..a172c8114cb --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration3_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts === +const a = 1 +>a : number + diff --git a/tests/baselines/reference/VariableDeclaration4_es6.errors.txt b/tests/baselines/reference/VariableDeclaration4_es6.errors.txt index b4bb75b5658..33d956ee1e5 100644 --- a/tests/baselines/reference/VariableDeclaration4_es6.errors.txt +++ b/tests/baselines/reference/VariableDeclaration4_es6.errors.txt @@ -1,10 +1,7 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts(1,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts(1,7): error TS1155: 'const' declarations must be initialized -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts (1 errors) ==== const a: number - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. ~ !!! error TS1155: 'const' declarations must be initialized \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration4_es6.js b/tests/baselines/reference/VariableDeclaration4_es6.js index 7a9934e052b..f0a8331acfe 100644 --- a/tests/baselines/reference/VariableDeclaration4_es6.js +++ b/tests/baselines/reference/VariableDeclaration4_es6.js @@ -2,4 +2,4 @@ const a: number //// [VariableDeclaration4_es6.js] -const a; +var a; diff --git a/tests/baselines/reference/VariableDeclaration5_es6.errors.txt b/tests/baselines/reference/VariableDeclaration5_es6.errors.txt deleted file mode 100644 index c72d423e460..00000000000 --- a/tests/baselines/reference/VariableDeclaration5_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts(1,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts (1 errors) ==== - const a: number = 1 - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration5_es6.js b/tests/baselines/reference/VariableDeclaration5_es6.js index e6a3c175651..98ae1af002e 100644 --- a/tests/baselines/reference/VariableDeclaration5_es6.js +++ b/tests/baselines/reference/VariableDeclaration5_es6.js @@ -2,4 +2,4 @@ const a: number = 1 //// [VariableDeclaration5_es6.js] -const a = 1; +var a = 1; diff --git a/tests/baselines/reference/VariableDeclaration5_es6.types b/tests/baselines/reference/VariableDeclaration5_es6.types new file mode 100644 index 00000000000..a07894d533d --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration5_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts === +const a: number = 1 +>a : number + diff --git a/tests/baselines/reference/VariableDeclaration7_es6.errors.txt b/tests/baselines/reference/VariableDeclaration7_es6.errors.txt deleted file mode 100644 index 83d12d463e6..00000000000 --- a/tests/baselines/reference/VariableDeclaration7_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts(1,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts (1 errors) ==== - let a - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration7_es6.js b/tests/baselines/reference/VariableDeclaration7_es6.js index 00ab95503a6..4287d79a7e4 100644 --- a/tests/baselines/reference/VariableDeclaration7_es6.js +++ b/tests/baselines/reference/VariableDeclaration7_es6.js @@ -2,4 +2,4 @@ let a //// [VariableDeclaration7_es6.js] -let a; +var a; diff --git a/tests/baselines/reference/VariableDeclaration7_es6.types b/tests/baselines/reference/VariableDeclaration7_es6.types new file mode 100644 index 00000000000..321c1b07bbc --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration7_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts === +let a +>a : any + diff --git a/tests/baselines/reference/VariableDeclaration8_es6.errors.txt b/tests/baselines/reference/VariableDeclaration8_es6.errors.txt deleted file mode 100644 index e371c64c9a6..00000000000 --- a/tests/baselines/reference/VariableDeclaration8_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts(1,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts (1 errors) ==== - let a = 1 - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration8_es6.js b/tests/baselines/reference/VariableDeclaration8_es6.js index 9178871ef65..4b4dd061bff 100644 --- a/tests/baselines/reference/VariableDeclaration8_es6.js +++ b/tests/baselines/reference/VariableDeclaration8_es6.js @@ -2,4 +2,4 @@ let a = 1 //// [VariableDeclaration8_es6.js] -let a = 1; +var a = 1; diff --git a/tests/baselines/reference/VariableDeclaration8_es6.types b/tests/baselines/reference/VariableDeclaration8_es6.types new file mode 100644 index 00000000000..530b147136d --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration8_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts === +let a = 1 +>a : number + diff --git a/tests/baselines/reference/VariableDeclaration9_es6.errors.txt b/tests/baselines/reference/VariableDeclaration9_es6.errors.txt deleted file mode 100644 index 4a1890d4694..00000000000 --- a/tests/baselines/reference/VariableDeclaration9_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts(1,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts (1 errors) ==== - let a: number - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration9_es6.js b/tests/baselines/reference/VariableDeclaration9_es6.js index b22c5691eb2..9ecfc40edff 100644 --- a/tests/baselines/reference/VariableDeclaration9_es6.js +++ b/tests/baselines/reference/VariableDeclaration9_es6.js @@ -2,4 +2,4 @@ let a: number //// [VariableDeclaration9_es6.js] -let a; +var a; diff --git a/tests/baselines/reference/VariableDeclaration9_es6.types b/tests/baselines/reference/VariableDeclaration9_es6.types new file mode 100644 index 00000000000..6b29a04281b --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration9_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts === +let a: number +>a : number + diff --git a/tests/baselines/reference/constDeclarations-errors.js b/tests/baselines/reference/constDeclarations-errors.js index 2947593b01d..a9564e266a0 100644 --- a/tests/baselines/reference/constDeclarations-errors.js +++ b/tests/baselines/reference/constDeclarations-errors.js @@ -23,7 +23,7 @@ const c1; const c2; const c3, c4, c5, c6; // error, missing initialicer // error, can not be unintalized -for (var c in {}) { } +for (const c in {}) { } // error, assigning to a const for (const c8 = 0; c8 < 1; c8++) { } // error, can not be unintalized diff --git a/tests/baselines/reference/constDeclarations-es5.errors.txt b/tests/baselines/reference/constDeclarations-es5.errors.txt deleted file mode 100644 index d15535349ac..00000000000 --- a/tests/baselines/reference/constDeclarations-es5.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -tests/cases/compiler/constDeclarations-es5.ts(2,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/constDeclarations-es5.ts(3,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/constDeclarations-es5.ts(4,1): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/compiler/constDeclarations-es5.ts (3 errors) ==== - - const z7 = false; - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. - const z8: number = 23; - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. - const z9 = 0, z10 :string = "", z11 = null; - ~~~~~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. - \ No newline at end of file diff --git a/tests/baselines/reference/constDeclarations-es5.js b/tests/baselines/reference/constDeclarations-es5.js index 20deb9dca37..736260ad102 100644 --- a/tests/baselines/reference/constDeclarations-es5.js +++ b/tests/baselines/reference/constDeclarations-es5.js @@ -6,6 +6,6 @@ const z9 = 0, z10 :string = "", z11 = null; //// [constDeclarations-es5.js] -const z7 = false; -const z8 = 23; -const z9 = 0, z10 = "", z11 = null; +var z7 = false; +var z8 = 23; +var z9 = 0, z10 = "", z11 = null; diff --git a/tests/baselines/reference/constDeclarations-es5.types b/tests/baselines/reference/constDeclarations-es5.types new file mode 100644 index 00000000000..be55dc0febc --- /dev/null +++ b/tests/baselines/reference/constDeclarations-es5.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/constDeclarations-es5.ts === + +const z7 = false; +>z7 : boolean + +const z8: number = 23; +>z8 : number + +const z9 = 0, z10 :string = "", z11 = null; +>z9 : number +>z10 : string +>z11 : any + diff --git a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline index 8dc9355bca2..9e2e9978f46 100644 --- a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline @@ -1,5 +1,5 @@ EmitSkipped: false FileName : tests/cases/fourslash/inputFile1.js // File contains early errors. All outputs should be skipped. -const uninitialized_const_error; +var uninitialized_const_error; diff --git a/tests/baselines/reference/letAsIdentifierInStrictMode.js b/tests/baselines/reference/letAsIdentifierInStrictMode.js index e844bc1d1dc..ccf099bcfc4 100644 --- a/tests/baselines/reference/letAsIdentifierInStrictMode.js +++ b/tests/baselines/reference/letAsIdentifierInStrictMode.js @@ -9,9 +9,9 @@ a; //// [letAsIdentifierInStrictMode.js] "use strict"; var ; -let ; +var ; 10; var a = 10; -let ; +var ; 30; -let a; +var a; diff --git a/tests/baselines/reference/letDeclarations-es5-1.errors.txt b/tests/baselines/reference/letDeclarations-es5-1.errors.txt deleted file mode 100644 index f8b5cf629d2..00000000000 --- a/tests/baselines/reference/letDeclarations-es5-1.errors.txt +++ /dev/null @@ -1,27 +0,0 @@ -tests/cases/compiler/letDeclarations-es5-1.ts(1,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5-1.ts(2,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5-1.ts(3,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5-1.ts(4,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5-1.ts(5,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5-1.ts(6,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/compiler/letDeclarations-es5-1.ts (6 errors) ==== - let l1; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l2: number; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l3, l4, l5 :string, l6; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l7 = false; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l8: number = 23; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l9 = 0, l10 :string = "", l11 = null; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/letDeclarations-es5-1.js b/tests/baselines/reference/letDeclarations-es5-1.js index 24c2c62e58f..35439c5966d 100644 --- a/tests/baselines/reference/letDeclarations-es5-1.js +++ b/tests/baselines/reference/letDeclarations-es5-1.js @@ -7,9 +7,9 @@ let l9 = 0, l10 :string = "", l11 = null; //// [letDeclarations-es5-1.js] -let l1; -let l2; -let l3, l4, l5, l6; -let l7 = false; -let l8 = 23; -let l9 = 0, l10 = "", l11 = null; +var l1; +var l2; +var l3, l4, l5, l6; +var l7 = false; +var l8 = 23; +var l9 = 0, l10 = "", l11 = null; diff --git a/tests/baselines/reference/letDeclarations-es5-1.types b/tests/baselines/reference/letDeclarations-es5-1.types new file mode 100644 index 00000000000..fb45d521bd3 --- /dev/null +++ b/tests/baselines/reference/letDeclarations-es5-1.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/letDeclarations-es5-1.ts === + let l1; +>l1 : any + + let l2: number; +>l2 : number + + let l3, l4, l5 :string, l6; +>l3 : any +>l4 : any +>l5 : string +>l6 : any + + let l7 = false; +>l7 : boolean + + let l8: number = 23; +>l8 : number + + let l9 = 0, l10 :string = "", l11 = null; +>l9 : number +>l10 : string +>l11 : any + diff --git a/tests/baselines/reference/letDeclarations-es5.errors.txt b/tests/baselines/reference/letDeclarations-es5.errors.txt deleted file mode 100644 index 27d526f03ea..00000000000 --- a/tests/baselines/reference/letDeclarations-es5.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -tests/cases/compiler/letDeclarations-es5.ts(2,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(3,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(4,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(6,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(7,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(8,1): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(10,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. -tests/cases/compiler/letDeclarations-es5.ts(12,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/compiler/letDeclarations-es5.ts (8 errors) ==== - - let l1; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l2: number; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l3, l4, l5 :string, l6; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - let l7 = false; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l8: number = 23; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - let l9 = 0, l10 :string = "", l11 = null; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - for(let l11 in {}) { } - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - - for(let l12 = 0; l12 < 9; l12++) { } - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. - \ No newline at end of file diff --git a/tests/baselines/reference/letDeclarations-es5.js b/tests/baselines/reference/letDeclarations-es5.js index 4d2f5423ee0..4260e8d5758 100644 --- a/tests/baselines/reference/letDeclarations-es5.js +++ b/tests/baselines/reference/letDeclarations-es5.js @@ -14,11 +14,11 @@ for(let l12 = 0; l12 < 9; l12++) { } //// [letDeclarations-es5.js] -let l1; -let l2; -let l3, l4, l5, l6; -let l7 = false; -let l8 = 23; -let l9 = 0, l10 = "", l11 = null; -for (let l11 in {}) { } -for (let l12 = 0; l12 < 9; l12++) { } +var l1; +var l2; +var l3, l4, l5, l6; +var l7 = false; +var l8 = 23; +var l9 = 0, l10 = "", l11 = null; +for (var _l11 = void 0 in {}) { } +for (var l12 = 0; l12 < 9; l12++) { } diff --git a/tests/baselines/reference/letDeclarations-es5.types b/tests/baselines/reference/letDeclarations-es5.types new file mode 100644 index 00000000000..0d6e9928868 --- /dev/null +++ b/tests/baselines/reference/letDeclarations-es5.types @@ -0,0 +1,36 @@ +=== tests/cases/compiler/letDeclarations-es5.ts === + +let l1; +>l1 : any + +let l2: number; +>l2 : number + +let l3, l4, l5 :string, l6; +>l3 : any +>l4 : any +>l5 : string +>l6 : any + +let l7 = false; +>l7 : boolean + +let l8: number = 23; +>l8 : number + +let l9 = 0, l10 :string = "", l11 = null; +>l9 : number +>l10 : string +>l11 : any + +for(let l11 in {}) { } +>l11 : any +>{} : {} + +for(let l12 = 0; l12 < 9; l12++) { } +>l12 : number +>l12 < 9 : boolean +>l12 : number +>l12++ : number +>l12 : number + diff --git a/tests/baselines/reference/restElementWithInitializer2.js b/tests/baselines/reference/restElementWithInitializer2.js index 8874f6a83d0..06f3985e3e5 100644 --- a/tests/baselines/reference/restElementWithInitializer2.js +++ b/tests/baselines/reference/restElementWithInitializer2.js @@ -7,4 +7,4 @@ var x: number[]; //// [restElementWithInitializer2.js] var a; var x; -x = a = a.slice(0); // Error, rest element cannot have initializer +; // Error, rest element cannot have initializer diff --git a/tests/baselines/reference/shadowingViaLocalValue.errors.txt b/tests/baselines/reference/shadowingViaLocalValue.errors.txt index 2a585ba8b7d..3632ac77eba 100644 --- a/tests/baselines/reference/shadowingViaLocalValue.errors.txt +++ b/tests/baselines/reference/shadowingViaLocalValue.errors.txt @@ -1,14 +1,10 @@ -tests/cases/compiler/shadowingViaLocalValue.ts(2,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. tests/cases/compiler/shadowingViaLocalValue.ts(4,13): error TS4090: 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 TS4090: 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 TS4090: Cannot init { let x1; - ~~~ -!!! error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. { for (var x1 = 0; ;); ~~ diff --git a/tests/baselines/reference/shadowingViaLocalValue.js b/tests/baselines/reference/shadowingViaLocalValue.js index f99a209f0de..389b106fdd9 100644 --- a/tests/baselines/reference/shadowingViaLocalValue.js +++ b/tests/baselines/reference/shadowingViaLocalValue.js @@ -17,13 +17,13 @@ //// [shadowingViaLocalValue.js] { - let x; + var _x = void 0; { var x = 1; } } { - let x1; + var _x1 = void 0; { for (var x1 = 0;;) ; From 393b95ed0e335f63365b6fcb00f1f962781f97da Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 17 Feb 2015 16:25:38 -0800 Subject: [PATCH 24/96] accepted baselines --- tests/baselines/reference/APISample_compile.js | 2 +- tests/baselines/reference/APISample_compile.types | 4 ++-- tests/baselines/reference/APISample_linter.js | 2 +- tests/baselines/reference/APISample_linter.types | 4 ++-- tests/baselines/reference/APISample_transform.js | 2 +- tests/baselines/reference/APISample_transform.types | 4 ++-- tests/baselines/reference/APISample_watcher.js | 2 +- tests/baselines/reference/APISample_watcher.types | 4 ++-- tests/baselines/reference/letDeclarations-es5.js | 2 +- tests/baselines/reference/restElementWithInitializer2.js | 2 +- tests/baselines/reference/shadowingViaLocalValue.js | 4 ++-- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 1dbf40e48fa..2b8be90024b 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -997,7 +997,7 @@ declare module "typescript" { SuperStatic = 32, ContextChecked = 64, EnumValuesComputed = 128, - BlockScopedBindingCapturedInLoop = 256, + BlockScopedBindingInLoop = 256, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index 09344976ba6..068d2549a7a 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -3218,8 +3218,8 @@ declare module "typescript" { EnumValuesComputed = 128, >EnumValuesComputed : NodeCheckFlags - BlockScopedBindingCapturedInLoop = 256, ->BlockScopedBindingCapturedInLoop : NodeCheckFlags + BlockScopedBindingInLoop = 256, +>BlockScopedBindingInLoop : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index fd097517f27..33cc9edfaf8 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -1028,7 +1028,7 @@ declare module "typescript" { SuperStatic = 32, ContextChecked = 64, EnumValuesComputed = 128, - BlockScopedBindingCapturedInLoop = 256, + BlockScopedBindingInLoop = 256, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index f68e06fdde7..4202e57c2a3 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -3362,8 +3362,8 @@ declare module "typescript" { EnumValuesComputed = 128, >EnumValuesComputed : NodeCheckFlags - BlockScopedBindingCapturedInLoop = 256, ->BlockScopedBindingCapturedInLoop : NodeCheckFlags + BlockScopedBindingInLoop = 256, +>BlockScopedBindingInLoop : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index d523f2920ed..16a1fb7bd20 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -1029,7 +1029,7 @@ declare module "typescript" { SuperStatic = 32, ContextChecked = 64, EnumValuesComputed = 128, - BlockScopedBindingCapturedInLoop = 256, + BlockScopedBindingInLoop = 256, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index a51cfb586db..d909293ae7e 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -3314,8 +3314,8 @@ declare module "typescript" { EnumValuesComputed = 128, >EnumValuesComputed : NodeCheckFlags - BlockScopedBindingCapturedInLoop = 256, ->BlockScopedBindingCapturedInLoop : NodeCheckFlags + BlockScopedBindingInLoop = 256, +>BlockScopedBindingInLoop : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 58b6dfbbe5d..41d5fdcbe0f 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -1066,7 +1066,7 @@ declare module "typescript" { SuperStatic = 32, ContextChecked = 64, EnumValuesComputed = 128, - BlockScopedBindingCapturedInLoop = 256, + BlockScopedBindingInLoop = 256, } interface NodeLinks { resolvedType?: Type; diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 5ec5d51f99d..f8a1c2f6ebf 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -3487,8 +3487,8 @@ declare module "typescript" { EnumValuesComputed = 128, >EnumValuesComputed : NodeCheckFlags - BlockScopedBindingCapturedInLoop = 256, ->BlockScopedBindingCapturedInLoop : NodeCheckFlags + BlockScopedBindingInLoop = 256, +>BlockScopedBindingInLoop : NodeCheckFlags } interface NodeLinks { >NodeLinks : NodeLinks diff --git a/tests/baselines/reference/letDeclarations-es5.js b/tests/baselines/reference/letDeclarations-es5.js index 4260e8d5758..4ad43d52f76 100644 --- a/tests/baselines/reference/letDeclarations-es5.js +++ b/tests/baselines/reference/letDeclarations-es5.js @@ -20,5 +20,5 @@ var l3, l4, l5, l6; var l7 = false; var l8 = 23; var l9 = 0, l10 = "", l11 = null; -for (var _l11 = void 0 in {}) { } +for (var _l11 in {}) { } for (var l12 = 0; l12 < 9; l12++) { } diff --git a/tests/baselines/reference/restElementWithInitializer2.js b/tests/baselines/reference/restElementWithInitializer2.js index 06f3985e3e5..8874f6a83d0 100644 --- a/tests/baselines/reference/restElementWithInitializer2.js +++ b/tests/baselines/reference/restElementWithInitializer2.js @@ -7,4 +7,4 @@ var x: number[]; //// [restElementWithInitializer2.js] var a; var x; -; // Error, rest element cannot have initializer +x = a = a.slice(0); // Error, rest element cannot have initializer diff --git a/tests/baselines/reference/shadowingViaLocalValue.js b/tests/baselines/reference/shadowingViaLocalValue.js index 389b106fdd9..e788caf5720 100644 --- a/tests/baselines/reference/shadowingViaLocalValue.js +++ b/tests/baselines/reference/shadowingViaLocalValue.js @@ -17,13 +17,13 @@ //// [shadowingViaLocalValue.js] { - var _x = void 0; + var _x; { var x = 1; } } { - var _x1 = void 0; + var _x1; { for (var x1 = 0;;) ; From e6cfc10acc90ccaf5072f0e0fd620ba2652190f1 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 17 Feb 2015 16:26:32 -0800 Subject: [PATCH 25/96] added missing files --- src/compiler/checker.ts | 11 +++++------ src/compiler/emitter.ts | 43 +++++++++++++++++++++++++++++------------ src/compiler/types.ts | 2 +- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 211331579cd..748be3648ec 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4939,15 +4939,14 @@ module ts { current = current.parent; } - if (!inFunction) { - return; - } - var current: Node = container; while (current && !isNameScopeBoundary(current)) { if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { - getNodeLinks(current).flags |= NodeCheckFlags.BlockScopedBindingCapturedInLoop; - grammarErrorOnFirstToken(current, Diagnostics.Code_in_the_loop_captures_block_scoped_variable_0_in_closure_This_is_natively_supported_in_ECMAScript_6_or_higher, declarationNameToString(node)); + if (inFunction) { + getNodeLinks(current).flags |= NodeCheckFlags.BlockScopedBindingInLoop; + grammarErrorOnFirstToken(current, Diagnostics.Code_in_the_loop_captures_block_scoped_variable_0_in_closure_This_is_natively_supported_in_ECMAScript_6_or_higher, declarationNameToString(node)); + } + getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.BlockScopedBindingInLoop; break; } current = current.parent; diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 638b78812cc..2808b561256 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3282,7 +3282,7 @@ module ts { emitDestructuringAssignment(e, createElementAccess(value, createNumericLiteral(i))); } else { - if (i === elements.length - 1 && (e).expression.kind === SyntaxKind.Identifier) { + if (i === elements.length - 1) { value = ensureIdentifier(value); emitAssignment((e).expression, value); write(".slice(" + i + ")"); @@ -3384,12 +3384,23 @@ module ts { } } else { - var initializeToDefault = renameNonTopLevelLetAndConst(node.name); + var isLet = renameNonTopLevelLetAndConst(node.name); emitModuleMemberName(node); - var initializer = - node.initializer || - (initializeToDefault && createVoidZero()); + var initializer = node.initializer; + if (!initializer) { + // downlevel emit for non-initialized let bindings defined in loops + // for (...) { let x; } + // should be + // for (...) { var = void 0; } + // this is necessary to preserve ES6 semantic in scenarios like + // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations + var initializer = + languageVersion < ScriptTarget.ES6 && + (resolver.getNodeCheckFlags(node) & NodeCheckFlags.BlockScopedBindingInLoop) && + (getCombinedFlagsForIdentifier(node.name) & NodeFlags.Let) && + createVoidZero(); + } emitOptional(" = ", initializer); } @@ -3422,29 +3433,39 @@ module ts { } } - function renameNonTopLevelLetAndConst(node: Node): boolean { + 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 (does not have a parent) + // - 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 || !node.parent || + node.kind !== SyntaxKind.Identifier || (node.parent.kind !== SyntaxKind.VariableDeclaration && node.parent.kind !== SyntaxKind.BindingElement)) { - return false; + return; } - var combinedFlags = getCombinedNodeFlags(node.parent); + var combinedFlags = getCombinedFlagsForIdentifier(node); if (((combinedFlags & NodeFlags.BlockScoped) === 0) || combinedFlags & NodeFlags.Export) { // do not rename exported or non-block scoped variables - return false; + 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 false; + return; } var generatedName = makeUniqueName(getEnclosingBlockScopeContainer(node), (node).text); @@ -3453,8 +3474,6 @@ module ts { generatedBlockScopeNames = []; } generatedBlockScopeNames[symbolId] = generatedName; - - return (combinedFlags & NodeFlags.Let) !== 0; } function emitVariableStatement(node: VariableStatement) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 940a4a6e5a4..9c7c794d002 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1262,7 +1262,7 @@ module ts { // Values for enum members have been computed, and any errors have been reported for them. EnumValuesComputed = 0x00000080, - BlockScopedBindingCapturedInLoop = 0x00000100, + BlockScopedBindingInLoop = 0x00000100, } export interface NodeLinks { From b4c82c940197d13fee16e3a0039d41e5892aa726 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 17 Feb 2015 17:04:31 -0800 Subject: [PATCH 26/96] added tests, accepted baselines --- src/compiler/emitter.ts | 16 ++++++++-------- .../reference/VariableDeclaration10_es6.js | 2 +- .../reference/VariableDeclaration11_es6.js | 2 +- .../reference/VariableDeclaration1_es6.js | 2 +- .../reference/VariableDeclaration2_es6.js | 2 +- .../reference/VariableDeclaration3_es6.js | 2 +- .../reference/VariableDeclaration4_es6.js | 2 +- .../reference/VariableDeclaration5_es6.js | 2 +- .../reference/VariableDeclaration7_es6.js | 2 +- .../reference/VariableDeclaration8_es6.js | 2 +- .../reference/VariableDeclaration9_es6.js | 2 +- .../reference/downlevelLetConst1.errors.txt | 7 +++++++ tests/baselines/reference/downlevelLetConst1.js | 5 +++++ tests/baselines/reference/downlevelLetConst10.js | 5 +++++ .../reference/downlevelLetConst10.types | 4 ++++ .../reference/downlevelLetConst11.errors.txt | 8 ++++++++ tests/baselines/reference/downlevelLetConst11.js | 7 +++++++ .../reference/downlevelLetConst2.errors.txt | 7 +++++++ tests/baselines/reference/downlevelLetConst2.js | 5 +++++ tests/baselines/reference/downlevelLetConst3.js | 5 +++++ .../baselines/reference/downlevelLetConst3.types | 4 ++++ .../reference/downlevelLetConst4.errors.txt | 7 +++++++ tests/baselines/reference/downlevelLetConst4.js | 5 +++++ tests/baselines/reference/downlevelLetConst5.js | 5 +++++ .../baselines/reference/downlevelLetConst5.types | 4 ++++ .../reference/downlevelLetConst6.errors.txt | 7 +++++++ tests/baselines/reference/downlevelLetConst6.js | 5 +++++ tests/baselines/reference/downlevelLetConst7.js | 5 +++++ .../baselines/reference/downlevelLetConst7.types | 4 ++++ tests/baselines/reference/downlevelLetConst8.js | 5 +++++ .../baselines/reference/downlevelLetConst8.types | 4 ++++ tests/baselines/reference/downlevelLetConst9.js | 5 +++++ .../baselines/reference/downlevelLetConst9.types | 4 ++++ tests/cases/compiler/downlevelLetConst1.ts | 1 + tests/cases/compiler/downlevelLetConst10.ts | 1 + tests/cases/compiler/downlevelLetConst11.ts | 2 ++ tests/cases/compiler/downlevelLetConst2.ts | 1 + tests/cases/compiler/downlevelLetConst3.ts | 1 + tests/cases/compiler/downlevelLetConst4.ts | 1 + tests/cases/compiler/downlevelLetConst5.ts | 1 + tests/cases/compiler/downlevelLetConst6.ts | 1 + tests/cases/compiler/downlevelLetConst7.ts | 1 + tests/cases/compiler/downlevelLetConst8.ts | 1 + tests/cases/compiler/downlevelLetConst9.ts | 1 + .../VariableDeclaration10_es6.ts | 1 + .../VariableDeclaration11_es6.ts | 1 + .../VariableDeclaration1_es6.ts | 1 + .../VariableDeclaration2_es6.ts | 1 + .../VariableDeclaration3_es6.ts | 1 + .../VariableDeclaration4_es6.ts | 1 + .../VariableDeclaration5_es6.ts | 1 + .../VariableDeclaration6_es6.ts | 1 + .../VariableDeclaration7_es6.ts | 1 + .../VariableDeclaration8_es6.ts | 1 + .../VariableDeclaration9_es6.ts | 1 + 55 files changed, 158 insertions(+), 18 deletions(-) create mode 100644 tests/baselines/reference/downlevelLetConst1.errors.txt create mode 100644 tests/baselines/reference/downlevelLetConst1.js create mode 100644 tests/baselines/reference/downlevelLetConst10.js create mode 100644 tests/baselines/reference/downlevelLetConst10.types create mode 100644 tests/baselines/reference/downlevelLetConst11.errors.txt create mode 100644 tests/baselines/reference/downlevelLetConst11.js create mode 100644 tests/baselines/reference/downlevelLetConst2.errors.txt create mode 100644 tests/baselines/reference/downlevelLetConst2.js create mode 100644 tests/baselines/reference/downlevelLetConst3.js create mode 100644 tests/baselines/reference/downlevelLetConst3.types create mode 100644 tests/baselines/reference/downlevelLetConst4.errors.txt create mode 100644 tests/baselines/reference/downlevelLetConst4.js create mode 100644 tests/baselines/reference/downlevelLetConst5.js create mode 100644 tests/baselines/reference/downlevelLetConst5.types create mode 100644 tests/baselines/reference/downlevelLetConst6.errors.txt create mode 100644 tests/baselines/reference/downlevelLetConst6.js create mode 100644 tests/baselines/reference/downlevelLetConst7.js create mode 100644 tests/baselines/reference/downlevelLetConst7.types create mode 100644 tests/baselines/reference/downlevelLetConst8.js create mode 100644 tests/baselines/reference/downlevelLetConst8.types create mode 100644 tests/baselines/reference/downlevelLetConst9.js create mode 100644 tests/baselines/reference/downlevelLetConst9.types create mode 100644 tests/cases/compiler/downlevelLetConst1.ts create mode 100644 tests/cases/compiler/downlevelLetConst10.ts create mode 100644 tests/cases/compiler/downlevelLetConst11.ts create mode 100644 tests/cases/compiler/downlevelLetConst2.ts create mode 100644 tests/cases/compiler/downlevelLetConst3.ts create mode 100644 tests/cases/compiler/downlevelLetConst4.ts create mode 100644 tests/cases/compiler/downlevelLetConst5.ts create mode 100644 tests/cases/compiler/downlevelLetConst6.ts create mode 100644 tests/cases/compiler/downlevelLetConst7.ts create mode 100644 tests/cases/compiler/downlevelLetConst8.ts create mode 100644 tests/cases/compiler/downlevelLetConst9.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 2808b561256..ad0f76621b0 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1639,7 +1639,7 @@ module ts { writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); return; - function enterScope(): boolean { + function enterNameScope(): boolean { var names = currentScopeNames; currentScopeNames = undefined; if (names) { @@ -1649,7 +1649,7 @@ module ts { return false; } - function exitScope(popFrame: boolean): void { + function exitNameScope(popFrame: boolean): void { if (popFrame) { currentScopeNames = lastFrame.names; lastFrame = lastFrame.previous; @@ -3649,7 +3649,7 @@ module ts { tempVariables = undefined; tempParameters = undefined; - var popFrame = enterScope() + var popFrame = enterNameScope() // When targeting ES6, emit arrow function natively in ES6 if (shouldEmitAsArrowFunction(node)) { @@ -3743,7 +3743,7 @@ module ts { write(";"); } - exitScope(popFrame); + exitNameScope(popFrame); tempCount = saveTempCount; tempVariables = saveTempVariables; @@ -3956,7 +3956,7 @@ module ts { tempVariables = undefined; tempParameters = undefined; - var popFrame = enterScope(); + var popFrame = enterNameScope(); // Emit the constructor overload pinned comments forEach(node.members, member => { @@ -4019,7 +4019,7 @@ module ts { emitTrailingComments(ctor); } - exitScope(popFrame); + exitNameScope(popFrame); tempCount = saveTempCount; tempVariables = saveTempVariables; @@ -4150,11 +4150,11 @@ module ts { var saveTempVariables = tempVariables; tempCount = 0; tempVariables = undefined; - var popFrame = enterScope(); + var popFrame = enterNameScope(); emit(node.body); - exitScope(popFrame); + exitNameScope(popFrame); tempCount = saveTempCount; tempVariables = saveTempVariables; } diff --git a/tests/baselines/reference/VariableDeclaration10_es6.js b/tests/baselines/reference/VariableDeclaration10_es6.js index 6edba42ab0d..14f47cea04d 100644 --- a/tests/baselines/reference/VariableDeclaration10_es6.js +++ b/tests/baselines/reference/VariableDeclaration10_es6.js @@ -2,4 +2,4 @@ let a: number = 1 //// [VariableDeclaration10_es6.js] -var a = 1; +let a = 1; diff --git a/tests/baselines/reference/VariableDeclaration11_es6.js b/tests/baselines/reference/VariableDeclaration11_es6.js index 0000d5cb5ab..83eec6d9a13 100644 --- a/tests/baselines/reference/VariableDeclaration11_es6.js +++ b/tests/baselines/reference/VariableDeclaration11_es6.js @@ -4,4 +4,4 @@ let //// [VariableDeclaration11_es6.js] "use strict"; -var ; +let ; diff --git a/tests/baselines/reference/VariableDeclaration1_es6.js b/tests/baselines/reference/VariableDeclaration1_es6.js index a867d74726c..26433bd88c3 100644 --- a/tests/baselines/reference/VariableDeclaration1_es6.js +++ b/tests/baselines/reference/VariableDeclaration1_es6.js @@ -2,4 +2,4 @@ const //// [VariableDeclaration1_es6.js] -var ; +const ; diff --git a/tests/baselines/reference/VariableDeclaration2_es6.js b/tests/baselines/reference/VariableDeclaration2_es6.js index d835435a0a6..a955315a2f0 100644 --- a/tests/baselines/reference/VariableDeclaration2_es6.js +++ b/tests/baselines/reference/VariableDeclaration2_es6.js @@ -2,4 +2,4 @@ const a //// [VariableDeclaration2_es6.js] -var a; +const a; diff --git a/tests/baselines/reference/VariableDeclaration3_es6.js b/tests/baselines/reference/VariableDeclaration3_es6.js index 08513b8bdbc..4be8a3daf38 100644 --- a/tests/baselines/reference/VariableDeclaration3_es6.js +++ b/tests/baselines/reference/VariableDeclaration3_es6.js @@ -2,4 +2,4 @@ const a = 1 //// [VariableDeclaration3_es6.js] -var a = 1; +const a = 1; diff --git a/tests/baselines/reference/VariableDeclaration4_es6.js b/tests/baselines/reference/VariableDeclaration4_es6.js index f0a8331acfe..7a9934e052b 100644 --- a/tests/baselines/reference/VariableDeclaration4_es6.js +++ b/tests/baselines/reference/VariableDeclaration4_es6.js @@ -2,4 +2,4 @@ const a: number //// [VariableDeclaration4_es6.js] -var a; +const a; diff --git a/tests/baselines/reference/VariableDeclaration5_es6.js b/tests/baselines/reference/VariableDeclaration5_es6.js index 98ae1af002e..e6a3c175651 100644 --- a/tests/baselines/reference/VariableDeclaration5_es6.js +++ b/tests/baselines/reference/VariableDeclaration5_es6.js @@ -2,4 +2,4 @@ const a: number = 1 //// [VariableDeclaration5_es6.js] -var a = 1; +const a = 1; diff --git a/tests/baselines/reference/VariableDeclaration7_es6.js b/tests/baselines/reference/VariableDeclaration7_es6.js index 4287d79a7e4..00ab95503a6 100644 --- a/tests/baselines/reference/VariableDeclaration7_es6.js +++ b/tests/baselines/reference/VariableDeclaration7_es6.js @@ -2,4 +2,4 @@ let a //// [VariableDeclaration7_es6.js] -var a; +let a; diff --git a/tests/baselines/reference/VariableDeclaration8_es6.js b/tests/baselines/reference/VariableDeclaration8_es6.js index 4b4dd061bff..9178871ef65 100644 --- a/tests/baselines/reference/VariableDeclaration8_es6.js +++ b/tests/baselines/reference/VariableDeclaration8_es6.js @@ -2,4 +2,4 @@ let a = 1 //// [VariableDeclaration8_es6.js] -var a = 1; +let a = 1; diff --git a/tests/baselines/reference/VariableDeclaration9_es6.js b/tests/baselines/reference/VariableDeclaration9_es6.js index 9ecfc40edff..b22c5691eb2 100644 --- a/tests/baselines/reference/VariableDeclaration9_es6.js +++ b/tests/baselines/reference/VariableDeclaration9_es6.js @@ -2,4 +2,4 @@ let a: number //// [VariableDeclaration9_es6.js] -var a; +let a; diff --git a/tests/baselines/reference/downlevelLetConst1.errors.txt b/tests/baselines/reference/downlevelLetConst1.errors.txt new file mode 100644 index 00000000000..a46d1973e04 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst1.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/downlevelLetConst1.ts(1,6): error TS1123: Variable declaration list cannot be empty. + + +==== tests/cases/compiler/downlevelLetConst1.ts (1 errors) ==== + const + +!!! error TS1123: Variable declaration list cannot be empty. \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst1.js b/tests/baselines/reference/downlevelLetConst1.js new file mode 100644 index 00000000000..3463c100324 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst1.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst1.ts] +const + +//// [downlevelLetConst1.js] +var ; diff --git a/tests/baselines/reference/downlevelLetConst10.js b/tests/baselines/reference/downlevelLetConst10.js new file mode 100644 index 00000000000..8beb79b04b4 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst10.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst10.ts] +let a: number = 1 + +//// [downlevelLetConst10.js] +var a = 1; diff --git a/tests/baselines/reference/downlevelLetConst10.types b/tests/baselines/reference/downlevelLetConst10.types new file mode 100644 index 00000000000..05fe3029455 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst10.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/downlevelLetConst10.ts === +let a: number = 1 +>a : number + diff --git a/tests/baselines/reference/downlevelLetConst11.errors.txt b/tests/baselines/reference/downlevelLetConst11.errors.txt new file mode 100644 index 00000000000..42449bd3c8a --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst11.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/downlevelLetConst11.ts(2,4): error TS1123: Variable declaration list cannot be empty. + + +==== tests/cases/compiler/downlevelLetConst11.ts (1 errors) ==== + "use strict"; + let + +!!! error TS1123: Variable declaration list cannot be empty. \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst11.js b/tests/baselines/reference/downlevelLetConst11.js new file mode 100644 index 00000000000..377c7e6a9ed --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst11.js @@ -0,0 +1,7 @@ +//// [downlevelLetConst11.ts] +"use strict"; +let + +//// [downlevelLetConst11.js] +"use strict"; +var ; diff --git a/tests/baselines/reference/downlevelLetConst2.errors.txt b/tests/baselines/reference/downlevelLetConst2.errors.txt new file mode 100644 index 00000000000..9da0c94a12e --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst2.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/downlevelLetConst2.ts(1,7): error TS1155: 'const' declarations must be initialized + + +==== tests/cases/compiler/downlevelLetConst2.ts (1 errors) ==== + const a + ~ +!!! error TS1155: 'const' declarations must be initialized \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst2.js b/tests/baselines/reference/downlevelLetConst2.js new file mode 100644 index 00000000000..a73688cd4af --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst2.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst2.ts] +const a + +//// [downlevelLetConst2.js] +var a; diff --git a/tests/baselines/reference/downlevelLetConst3.js b/tests/baselines/reference/downlevelLetConst3.js new file mode 100644 index 00000000000..f6ef605c261 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst3.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst3.ts] +const a = 1 + +//// [downlevelLetConst3.js] +var a = 1; diff --git a/tests/baselines/reference/downlevelLetConst3.types b/tests/baselines/reference/downlevelLetConst3.types new file mode 100644 index 00000000000..6cd3f85e074 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst3.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/downlevelLetConst3.ts === +const a = 1 +>a : number + diff --git a/tests/baselines/reference/downlevelLetConst4.errors.txt b/tests/baselines/reference/downlevelLetConst4.errors.txt new file mode 100644 index 00000000000..3bf3e58cecc --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst4.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/downlevelLetConst4.ts(1,7): error TS1155: 'const' declarations must be initialized + + +==== tests/cases/compiler/downlevelLetConst4.ts (1 errors) ==== + const a: number + ~ +!!! error TS1155: 'const' declarations must be initialized \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst4.js b/tests/baselines/reference/downlevelLetConst4.js new file mode 100644 index 00000000000..725aa5cde8f --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst4.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst4.ts] +const a: number + +//// [downlevelLetConst4.js] +var a; diff --git a/tests/baselines/reference/downlevelLetConst5.js b/tests/baselines/reference/downlevelLetConst5.js new file mode 100644 index 00000000000..271c71b6829 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst5.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst5.ts] +const a: number = 1 + +//// [downlevelLetConst5.js] +var a = 1; diff --git a/tests/baselines/reference/downlevelLetConst5.types b/tests/baselines/reference/downlevelLetConst5.types new file mode 100644 index 00000000000..dd8cdf9fcdd --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst5.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/downlevelLetConst5.ts === +const a: number = 1 +>a : number + diff --git a/tests/baselines/reference/downlevelLetConst6.errors.txt b/tests/baselines/reference/downlevelLetConst6.errors.txt new file mode 100644 index 00000000000..bad0674c5c4 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/downlevelLetConst6.ts(1,1): error TS2304: Cannot find name 'let'. + + +==== tests/cases/compiler/downlevelLetConst6.ts (1 errors) ==== + let + ~~~ +!!! error TS2304: Cannot find name 'let'. \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst6.js b/tests/baselines/reference/downlevelLetConst6.js new file mode 100644 index 00000000000..2a1aea002d9 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst6.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst6.ts] +let + +//// [downlevelLetConst6.js] +let; diff --git a/tests/baselines/reference/downlevelLetConst7.js b/tests/baselines/reference/downlevelLetConst7.js new file mode 100644 index 00000000000..6020ddf2479 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst7.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst7.ts] +let a + +//// [downlevelLetConst7.js] +var a; diff --git a/tests/baselines/reference/downlevelLetConst7.types b/tests/baselines/reference/downlevelLetConst7.types new file mode 100644 index 00000000000..9c76479ecf5 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst7.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/downlevelLetConst7.ts === +let a +>a : any + diff --git a/tests/baselines/reference/downlevelLetConst8.js b/tests/baselines/reference/downlevelLetConst8.js new file mode 100644 index 00000000000..5cc548c1361 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst8.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst8.ts] +let a = 1 + +//// [downlevelLetConst8.js] +var a = 1; diff --git a/tests/baselines/reference/downlevelLetConst8.types b/tests/baselines/reference/downlevelLetConst8.types new file mode 100644 index 00000000000..a3b9986bbc8 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst8.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/downlevelLetConst8.ts === +let a = 1 +>a : number + diff --git a/tests/baselines/reference/downlevelLetConst9.js b/tests/baselines/reference/downlevelLetConst9.js new file mode 100644 index 00000000000..c6bcfe27a8a --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst9.js @@ -0,0 +1,5 @@ +//// [downlevelLetConst9.ts] +let a: number + +//// [downlevelLetConst9.js] +var a; diff --git a/tests/baselines/reference/downlevelLetConst9.types b/tests/baselines/reference/downlevelLetConst9.types new file mode 100644 index 00000000000..cab9ac82a60 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst9.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/downlevelLetConst9.ts === +let a: number +>a : number + diff --git a/tests/cases/compiler/downlevelLetConst1.ts b/tests/cases/compiler/downlevelLetConst1.ts new file mode 100644 index 00000000000..8baacf4ea54 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst1.ts @@ -0,0 +1 @@ +const \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst10.ts b/tests/cases/compiler/downlevelLetConst10.ts new file mode 100644 index 00000000000..2b6e9657ef1 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst10.ts @@ -0,0 +1 @@ +let a: number = 1 \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst11.ts b/tests/cases/compiler/downlevelLetConst11.ts new file mode 100644 index 00000000000..aca60708232 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst11.ts @@ -0,0 +1,2 @@ +"use strict"; +let \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst2.ts b/tests/cases/compiler/downlevelLetConst2.ts new file mode 100644 index 00000000000..06871c9a45c --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst2.ts @@ -0,0 +1 @@ +const a \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst3.ts b/tests/cases/compiler/downlevelLetConst3.ts new file mode 100644 index 00000000000..6779cd775c0 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst3.ts @@ -0,0 +1 @@ +const a = 1 \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst4.ts b/tests/cases/compiler/downlevelLetConst4.ts new file mode 100644 index 00000000000..f96229b7eaf --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst4.ts @@ -0,0 +1 @@ +const a: number \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst5.ts b/tests/cases/compiler/downlevelLetConst5.ts new file mode 100644 index 00000000000..4a05e895a3c --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst5.ts @@ -0,0 +1 @@ +const a: number = 1 \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst6.ts b/tests/cases/compiler/downlevelLetConst6.ts new file mode 100644 index 00000000000..33ae002d859 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst6.ts @@ -0,0 +1 @@ +let \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst7.ts b/tests/cases/compiler/downlevelLetConst7.ts new file mode 100644 index 00000000000..7350ac02e70 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst7.ts @@ -0,0 +1 @@ +let a \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst8.ts b/tests/cases/compiler/downlevelLetConst8.ts new file mode 100644 index 00000000000..067c6699cfd --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst8.ts @@ -0,0 +1 @@ +let a = 1 \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst9.ts b/tests/cases/compiler/downlevelLetConst9.ts new file mode 100644 index 00000000000..aab3d49c18c --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst9.ts @@ -0,0 +1 @@ +let a: number \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts index 2b6e9657ef1..9e02b6de034 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts @@ -1 +1,2 @@ +// @target:es6 let a: number = 1 \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts index aca60708232..0de0f085a8a 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts @@ -1,2 +1,3 @@ +// @target:es6 "use strict"; let \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration1_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration1_es6.ts index 8baacf4ea54..27157193b24 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration1_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration1_es6.ts @@ -1 +1,2 @@ +// @target:es6 const \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts index 06871c9a45c..17986424b13 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts @@ -1 +1,2 @@ +// @target:es6 const a \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts index 6779cd775c0..cd1b75836e5 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts @@ -1 +1,2 @@ +// @target:es6 const a = 1 \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts index f96229b7eaf..e40c7b15283 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts @@ -1 +1,2 @@ +// @target:es6 const a: number \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts index 4a05e895a3c..52738ea2f07 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts @@ -1 +1,2 @@ +// @target:es6 const a: number = 1 \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration6_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration6_es6.ts index 33ae002d859..5fbd509be76 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration6_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration6_es6.ts @@ -1 +1,2 @@ +// @target:es6 let \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts index 7350ac02e70..14f4b483413 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration7_es6.ts @@ -1 +1,2 @@ +// @target:es6 let a \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts index 067c6699cfd..2bab0e1a1a4 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts @@ -1 +1,2 @@ +// @target:es6 let a = 1 \ No newline at end of file diff --git a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts index aab3d49c18c..db3cd38806a 100644 --- a/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts +++ b/tests/cases/conformance/es6/variableDeclarations/VariableDeclaration9_es6.ts @@ -1 +1,2 @@ +// @target:es6 let a: number \ No newline at end of file From f8832598b9ad094774bad6470d2661ed6abeb4cd Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Sat, 21 Feb 2015 14:48:10 +0100 Subject: [PATCH 27/96] Add tests for tagged templates --- .../taggedTemplateStringsHexadecimalEscapes.js | 15 +++++++++++++++ ...ggedTemplateStringsHexadecimalEscapes.types | 9 +++++++++ ...ggedTemplateStringsHexadecimalEscapesES6.js | 10 ++++++++++ ...dTemplateStringsHexadecimalEscapesES6.types | 9 +++++++++ ...ggedTemplateStringsWithMultilineTemplate.js | 18 ++++++++++++++++++ ...dTemplateStringsWithMultilineTemplate.types | 12 ++++++++++++ ...dTemplateStringsWithMultilineTemplateES6.js | 16 ++++++++++++++++ ...mplateStringsWithMultilineTemplateES6.types | 12 ++++++++++++ ...emplateStringsWithUnicodeEscapes.errors.txt | 10 ++++++++++ .../taggedTemplateStringsWithUnicodeEscapes.js | 15 +++++++++++++++ ...lateStringsWithUnicodeEscapesES6.errors.txt | 10 ++++++++++ ...ggedTemplateStringsWithUnicodeEscapesES6.js | 10 ++++++++++ ...ggedTemplateStringsWithWhitespaceEscapes.js | 15 +++++++++++++++ ...dTemplateStringsWithWhitespaceEscapes.types | 9 +++++++++ ...dTemplateStringsWithWhitespaceEscapesES6.js | 10 ++++++++++ ...mplateStringsWithWhitespaceEscapesES6.types | 9 +++++++++ .../taggedTemplateStringsHexadecimalEscapes.ts | 4 ++++ ...ggedTemplateStringsHexadecimalEscapesES6.ts | 5 +++++ ...ggedTemplateStringsWithMultilineTemplate.ts | 7 +++++++ ...dTemplateStringsWithMultilineTemplateES6.ts | 8 ++++++++ .../taggedTemplateStringsWithUnicodeEscapes.ts | 4 ++++ ...ggedTemplateStringsWithUnicodeEscapesES6.ts | 5 +++++ ...ggedTemplateStringsWithWhitespaceEscapes.ts | 4 ++++ ...dTemplateStringsWithWhitespaceEscapesES6.ts | 5 +++++ 24 files changed, 231 insertions(+) create mode 100644 tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.js create mode 100644 tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.types create mode 100644 tests/baselines/reference/taggedTemplateStringsHexadecimalEscapesES6.js create mode 100644 tests/baselines/reference/taggedTemplateStringsHexadecimalEscapesES6.types create mode 100644 tests/baselines/reference/taggedTemplateStringsWithMultilineTemplate.js create mode 100644 tests/baselines/reference/taggedTemplateStringsWithMultilineTemplate.types create mode 100644 tests/baselines/reference/taggedTemplateStringsWithMultilineTemplateES6.js create mode 100644 tests/baselines/reference/taggedTemplateStringsWithMultilineTemplateES6.types create mode 100644 tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.errors.txt create mode 100644 tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.js create mode 100644 tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapesES6.errors.txt create mode 100644 tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapesES6.js create mode 100644 tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapes.js create mode 100644 tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapes.types create mode 100644 tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapesES6.js create mode 100644 tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapesES6.types create mode 100644 tests/cases/compiler/taggedTemplateStringsHexadecimalEscapes.ts create mode 100644 tests/cases/compiler/taggedTemplateStringsHexadecimalEscapesES6.ts create mode 100644 tests/cases/compiler/taggedTemplateStringsWithMultilineTemplate.ts create mode 100644 tests/cases/compiler/taggedTemplateStringsWithMultilineTemplateES6.ts create mode 100644 tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapes.ts create mode 100644 tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapesES6.ts create mode 100644 tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapes.ts create mode 100644 tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapesES6.ts diff --git a/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.js b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.js new file mode 100644 index 00000000000..e4482ded0c2 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.js @@ -0,0 +1,15 @@ +//// [taggedTemplateStringsHexadecimalEscapes.ts] +function f(...args: any[]) { +} + +f `\x0D${ "Interrupted CRLF" }\x0A`; + +//// [taggedTemplateStringsHexadecimalEscapes.js] +function f() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } +} +(_a = ["\r", "\n"], _a.raw = ["\\x0D", "\\x0A"], f(_a, "Interrupted CRLF")); +var _a; diff --git a/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.types b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.types new file mode 100644 index 00000000000..37f583efd59 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/taggedTemplateStringsHexadecimalEscapes.ts === +function f(...args: any[]) { +>f : (...args: any[]) => void +>args : any[] +} + +f `\x0D${ "Interrupted CRLF" }\x0A`; +>f : (...args: any[]) => void + diff --git a/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapesES6.js b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapesES6.js new file mode 100644 index 00000000000..31a0358973f --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapesES6.js @@ -0,0 +1,10 @@ +//// [taggedTemplateStringsHexadecimalEscapesES6.ts] +function f(...args: any[]) { +} + +f `\x0D${ "Interrupted CRLF" }\x0A`; + +//// [taggedTemplateStringsHexadecimalEscapesES6.js] +function f(...args) { +} +f `\x0D${"Interrupted CRLF"}\x0A`; diff --git a/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapesES6.types b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapesES6.types new file mode 100644 index 00000000000..b96c0664e2f --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapesES6.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/taggedTemplateStringsHexadecimalEscapesES6.ts === +function f(...args: any[]) { +>f : (...args: any[]) => void +>args : any[] +} + +f `\x0D${ "Interrupted CRLF" }\x0A`; +>f : (...args: any[]) => void + diff --git a/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplate.js b/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplate.js new file mode 100644 index 00000000000..cee9d1efce4 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplate.js @@ -0,0 +1,18 @@ +//// [taggedTemplateStringsWithMultilineTemplate.ts] +function f(...args: any[]): void { +} + +f ` +\ + +`; + +//// [taggedTemplateStringsWithMultilineTemplate.js] +function f() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } +} +(_a = ["\n\n"], _a.raw = ["\n\\\n\n"], f(_a)); +var _a; diff --git a/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplate.types b/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplate.types new file mode 100644 index 00000000000..ec687ac0fae --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplate.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/taggedTemplateStringsWithMultilineTemplate.ts === +function f(...args: any[]): void { +>f : (...args: any[]) => void +>args : any[] +} + +f ` +>f : (...args: any[]) => void + +\ + +`; diff --git a/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplateES6.js b/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplateES6.js new file mode 100644 index 00000000000..f1d0fb896da --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplateES6.js @@ -0,0 +1,16 @@ +//// [taggedTemplateStringsWithMultilineTemplateES6.ts] +function f(...args: any[]): void { +} + +f ` +\ + +`; + +//// [taggedTemplateStringsWithMultilineTemplateES6.js] +function f(...args) { +} +f ` +\ + +`; diff --git a/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplateES6.types b/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplateES6.types new file mode 100644 index 00000000000..7047f7194c3 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplateES6.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/taggedTemplateStringsWithMultilineTemplateES6.ts === +function f(...args: any[]): void { +>f : (...args: any[]) => void +>args : any[] +} + +f ` +>f : (...args: any[]) => void + +\ + +`; diff --git a/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.errors.txt new file mode 100644 index 00000000000..df3def2cb22 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapes.ts(4,7): error TS1125: Hexadecimal digit expected. + + +==== tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapes.ts (1 errors) ==== + function f(...args: any[]) { + } + + f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`; + +!!! error TS1125: Hexadecimal digit expected. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.js b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.js new file mode 100644 index 00000000000..75ea6775511 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.js @@ -0,0 +1,15 @@ +//// [taggedTemplateStringsWithUnicodeEscapes.ts] +function f(...args: any[]) { +} + +f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`; + +//// [taggedTemplateStringsWithUnicodeEscapes.js] +function f() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } +} +(_a = ["'{1f4a\u0039}'", "'💩'"], _a.raw = ["'\\u{1f4a\u0039}'", "'\\uD83D\\uDCA\u0039'"], f(_a, " should be converted to ")); +var _a; diff --git a/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapesES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapesES6.errors.txt new file mode 100644 index 00000000000..c48b43dc3ff --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapesES6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapesES6.ts(4,7): error TS1125: Hexadecimal digit expected. + + +==== tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapesES6.ts (1 errors) ==== + function f(...args: any[]) { + } + + f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`; + +!!! error TS1125: Hexadecimal digit expected. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapesES6.js b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapesES6.js new file mode 100644 index 00000000000..6ca5fa5b03a --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapesES6.js @@ -0,0 +1,10 @@ +//// [taggedTemplateStringsWithUnicodeEscapesES6.ts] +function f(...args: any[]) { +} + +f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`; + +//// [taggedTemplateStringsWithUnicodeEscapesES6.js] +function f(...args) { +} +f `'\u{1f4a9}'${" should be converted to "}'\uD83D\uDCA9'`; diff --git a/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapes.js b/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapes.js new file mode 100644 index 00000000000..65af8da59f9 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapes.js @@ -0,0 +1,15 @@ +//// [taggedTemplateStringsWithWhitespaceEscapes.ts] +function f(...args: any[]) { +} + +f `\t\n\v\f\r\\`; + +//// [taggedTemplateStringsWithWhitespaceEscapes.js] +function f() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } +} +(_a = ["\t\n\v\f\r\\"], _a.raw = ["\\t\\n\\v\\f\\r\\\\"], f(_a)); +var _a; diff --git a/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapes.types b/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapes.types new file mode 100644 index 00000000000..89027983cba --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapes.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapes.ts === +function f(...args: any[]) { +>f : (...args: any[]) => void +>args : any[] +} + +f `\t\n\v\f\r\\`; +>f : (...args: any[]) => void + diff --git a/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapesES6.js b/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapesES6.js new file mode 100644 index 00000000000..09a4aa765b4 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapesES6.js @@ -0,0 +1,10 @@ +//// [taggedTemplateStringsWithWhitespaceEscapesES6.ts] +function f(...args: any[]) { +} + +f `\t\n\v\f\r\\`; + +//// [taggedTemplateStringsWithWhitespaceEscapesES6.js] +function f(...args) { +} +f `\t\n\v\f\r\\`; diff --git a/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapesES6.types b/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapesES6.types new file mode 100644 index 00000000000..5aeef9207eb --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapesES6.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapesES6.ts === +function f(...args: any[]) { +>f : (...args: any[]) => void +>args : any[] +} + +f `\t\n\v\f\r\\`; +>f : (...args: any[]) => void + diff --git a/tests/cases/compiler/taggedTemplateStringsHexadecimalEscapes.ts b/tests/cases/compiler/taggedTemplateStringsHexadecimalEscapes.ts new file mode 100644 index 00000000000..09f9200f805 --- /dev/null +++ b/tests/cases/compiler/taggedTemplateStringsHexadecimalEscapes.ts @@ -0,0 +1,4 @@ +function f(...args: any[]) { +} + +f `\x0D${ "Interrupted CRLF" }\x0A`; \ No newline at end of file diff --git a/tests/cases/compiler/taggedTemplateStringsHexadecimalEscapesES6.ts b/tests/cases/compiler/taggedTemplateStringsHexadecimalEscapesES6.ts new file mode 100644 index 00000000000..38c8e09f6cc --- /dev/null +++ b/tests/cases/compiler/taggedTemplateStringsHexadecimalEscapesES6.ts @@ -0,0 +1,5 @@ +//@target: es6 +function f(...args: any[]) { +} + +f `\x0D${ "Interrupted CRLF" }\x0A`; \ No newline at end of file diff --git a/tests/cases/compiler/taggedTemplateStringsWithMultilineTemplate.ts b/tests/cases/compiler/taggedTemplateStringsWithMultilineTemplate.ts new file mode 100644 index 00000000000..80aeabb94d4 --- /dev/null +++ b/tests/cases/compiler/taggedTemplateStringsWithMultilineTemplate.ts @@ -0,0 +1,7 @@ +function f(...args: any[]): void { +} + +f ` +\ + +`; \ No newline at end of file diff --git a/tests/cases/compiler/taggedTemplateStringsWithMultilineTemplateES6.ts b/tests/cases/compiler/taggedTemplateStringsWithMultilineTemplateES6.ts new file mode 100644 index 00000000000..7478e3dd403 --- /dev/null +++ b/tests/cases/compiler/taggedTemplateStringsWithMultilineTemplateES6.ts @@ -0,0 +1,8 @@ +//@target: es6 +function f(...args: any[]): void { +} + +f ` +\ + +`; \ No newline at end of file diff --git a/tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapes.ts b/tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapes.ts new file mode 100644 index 00000000000..f0353713328 --- /dev/null +++ b/tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapes.ts @@ -0,0 +1,4 @@ +function f(...args: any[]) { +} + +f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`; \ No newline at end of file diff --git a/tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapesES6.ts b/tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapesES6.ts new file mode 100644 index 00000000000..039f723780f --- /dev/null +++ b/tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapesES6.ts @@ -0,0 +1,5 @@ +//@target: es6 +function f(...args: any[]) { +} + +f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`; \ No newline at end of file diff --git a/tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapes.ts b/tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapes.ts new file mode 100644 index 00000000000..f2c2ba315e4 --- /dev/null +++ b/tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapes.ts @@ -0,0 +1,4 @@ +function f(...args: any[]) { +} + +f `\t\n\v\f\r\\`; \ No newline at end of file diff --git a/tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapesES6.ts b/tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapesES6.ts new file mode 100644 index 00000000000..8519d85d79b --- /dev/null +++ b/tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapesES6.ts @@ -0,0 +1,5 @@ +//@target: es6 +function f(...args: any[]) { +} + +f `\t\n\v\f\r\\`; \ No newline at end of file From 35c815ef15a4ff031d500d1efeb39d2d902d7776 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Sun, 22 Feb 2015 10:07:32 +0100 Subject: [PATCH 28/96] Respond to code review --- src/compiler/emitter.ts | 53 +++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 05969877cf1..0eb3dbd0e54 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2140,6 +2140,9 @@ module ts { } function emitDownlevelRawTemplateLiteral(node: LiteralExpression) { + // Find original source text, since we need to emit the raw strings of the tagged template. + // The raw strings contain the (escaped) strings of what the user wrote. + // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". var text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node); // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), @@ -2149,45 +2152,43 @@ module ts { var isLast = node.kind === SyntaxKind.NoSubstitutionTemplateLiteral || node.kind === SyntaxKind.TemplateTail; text = text.substring(1, text.length - (isLast ? 1 : 2)); - // Newline normalization + // Newline normalization: + // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's + // and LineTerminatorSequences are normalized to for both TV and TRV. text = text.replace(/\r\n?/g, "\n"); text = escapeString(text); write('"' + text + '"'); } + function emitDownlevelTaggedTemplateArray(node: TaggedTemplateExpression, callback: (literal: LiteralExpression) => void) { + write("["); + if (node.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral) { + callback(node.template); + } + else { + callback((node.template).head); + forEach((node.template).templateSpans, (child) => { + write(", "); + callback(child.literal); + }); + } + write("]"); + } + function emitDownlevelTaggedTemplate(node: TaggedTemplateExpression) { var tempVariable = createTempVariable(node); recordTempDeclaration(tempVariable); write("("); emit(tempVariable); - write(" = ["); - - if (node.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral) { - emit(node.template); - } - else { - emit((node.template).head); - forEach((node.template).templateSpans, (child) => { - write(", "); - emit(child.literal); - }); - } - write("], "); + write(" = "); + emitDownlevelTaggedTemplateArray(node, emit); + write(", "); emit(tempVariable); - write(".raw = ["); - if (node.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral) { - emitDownlevelRawTemplateLiteral(node.template); - } - else { - emitDownlevelRawTemplateLiteral((node.template).head); - forEach((node.template).templateSpans, (child, index) => { - write(", "); - emitDownlevelRawTemplateLiteral(child.literal); - }); - } - write("], "); + write(".raw = "); + emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); + write(", "); emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); From c291d12cae6c4810622c543de4f0737b29ae5591 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Sun, 22 Feb 2015 10:21:15 +0100 Subject: [PATCH 29/96] Use createAndRecordTempVariable --- src/compiler/emitter.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5d4fddf0df9..a3b85c362ad 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2236,8 +2236,7 @@ module ts { } function emitDownlevelTaggedTemplate(node: TaggedTemplateExpression) { - var tempVariable = createTempVariable(node); - recordTempDeclaration(tempVariable); + var tempVariable = createAndRecordTempVariable(node); write("("); emit(tempVariable); write(" = "); From acdc1770ab3035765cc58c70a0ae880cadfafa8b Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Sun, 22 Feb 2015 10:41:21 +0100 Subject: [PATCH 30/96] Update baselines after merging master --- ...gedTemplateStringsTypeArgumentInference.js | 10 +---- ...dTemplateStringsWithOverloadResolution3.js | 42 ++----------------- ...tionExpressionsInSubstitutionExpression.js | 8 +--- .../templateStringInObjectLiteral.js | 8 +--- 4 files changed, 7 insertions(+), 61 deletions(-) diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js index dd3cb161317..9d3531c2667 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js @@ -136,17 +136,9 @@ function someGenerics7(strs, a, b, c) { } (_u = ["", "", "", ""], _u.raw = ["", "", "", ""], someGenerics7(_u, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); (_v = ["", "", "", ""], _v.raw = ["", "", "", ""], someGenerics7(_v, function (n) { return n; }, function (n) { return n; }, function (n) { return n; })); // Generic tag with argument of generic function type -<<<<<<< HEAD -function someGenerics8(strs, n) { - return n; -} +function someGenerics8(strs, n) { return n; } var x = (_w = ["", ""], _w.raw = ["", ""], someGenerics8(_w, someGenerics7)); (_x = ["", "", "", ""], _x.raw = ["", "", "", ""], x(_x, null, null, null)); -======= -function someGenerics8(strs, n) { return n; } -var x = someGenerics8 "" + someGenerics7; -x "" + null + null + null; ->>>>>>> master // Generic tag with multiple parameters of generic type passed arguments with no best common type function someGenerics9(strs, a, b, c) { return null; diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js index a393ba28a6a..4b9df44d3f7 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js @@ -74,47 +74,23 @@ fn5 `${ (n) => n.substr(0) }`; //// [taggedTemplateStringsWithOverloadResolution3.js] -<<<<<<< HEAD -function fn1() { - return null; -} +function fn1() { return null; } var s = (_a = ["", ""], _a.raw = ["", ""], fn1(_a, undefined)); // No candidate overloads found (_b = ["", ""], _b.raw = ["", ""], fn1(_b, {})); // Error -function fn2() { - return undefined; -} +function fn2() { return undefined; } var d1 = (_c = ["", "", ""], _c.raw = ["", "", ""], fn2(_c, 0, undefined)); // contextually typed var d2 = (_d = ["", "", ""], _d.raw = ["", "", ""], fn2(_d, 0, undefined)); // any -======= -function fn1() { return null; } -var s = fn1 "" + undefined; -// No candidate overloads found -fn1 "" + {}; // Error -function fn2() { return undefined; } -var d1 = fn2 "" + 0 + undefined; // contextually typed -var d2 = fn2 "" + 0 + undefined; // any ->>>>>>> master d1.foo(); // error d2(); // no error (typed as any) // Generic and non-generic overload where generic overload is the only candidate (_e = ["", "", ""], _e.raw = ["", "", ""], fn2(_e, 0, '')); // OK // Generic and non-generic overload where non-generic overload is the only candidate -<<<<<<< HEAD (_f = ["", "", ""], _f.raw = ["", "", ""], fn2(_f, '', 0)); // OK -function fn3() { - return null; -} +function fn3() { return null; } var s = (_g = ["", ""], _g.raw = ["", ""], fn3(_g, 3)); var s = (_h = ["", "", "", ""], _h.raw = ["", "", "", ""], fn3(_h, '', 3, '')); var n = (_j = ["", "", "", ""], _j.raw = ["", "", "", ""], fn3(_j, 5, 5, 5)); -======= -fn2 "" + '' + 0; // OK -function fn3() { return null; } -var s = fn3 "" + 3; -var s = fn3 "" + '' + 3 + ''; -var n = fn3 "" + 5 + 5 + 5; ->>>>>>> master var n; // Generic overloads with differing arity tagging with arguments matching each overload type parameter count var s = (_k = ["", ""], _k.raw = ["", ""], fn3(_k, 4)); @@ -131,19 +107,9 @@ function fn4() { } // Generic overloads with constraints called with type arguments that do not satisfy the constraints (_s = ["", "", ""], _s.raw = ["", "", ""], fn4(_s, null, null)); // Error // Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints -<<<<<<< HEAD (_t = ["", "", ""], _t.raw = ["", "", ""], fn4(_t, true, null)); (_u = ["", "", ""], _u.raw = ["", "", ""], fn4(_u, null, true)); -function fn5() { - return undefined; -} +function fn5() { return undefined; } (_v = ["", ""], _v.raw = ["", ""], fn5(_v, function (n) { return n.toFixed(); })); // will error; 'n' should have type 'string'. (_w = ["", ""], _w.raw = ["", ""], fn5(_w, function (n) { return n.substr(0); })); var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w; -======= -fn4 "" + true + null; -fn4 "" + null + true; -function fn5() { return undefined; } -fn5 "" + function (n) { return n.toFixed(); }; // will error; 'n' should have type 'string'. -fn5 "" + function (n) { return n.substr(0); }; ->>>>>>> master diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js index 6552476a8f1..f7523eb9870 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js +++ b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js @@ -13,11 +13,5 @@ function foo() { rest[_i - 0] = arguments[_i]; } } -<<<<<<< HEAD -(_a = ["", ""], _a.raw = ["", ""], foo(_a, function (x) { - x = "bad"; -})); +(_a = ["", ""], _a.raw = ["", ""], foo(_a, function (x) { x = "bad"; })); var _a; -======= -foo "" + function (x) { x = "bad"; }; ->>>>>>> master diff --git a/tests/baselines/reference/templateStringInObjectLiteral.js b/tests/baselines/reference/templateStringInObjectLiteral.js index 92a03415d84..2e4de70f57c 100644 --- a/tests/baselines/reference/templateStringInObjectLiteral.js +++ b/tests/baselines/reference/templateStringInObjectLiteral.js @@ -5,13 +5,7 @@ var x = { } //// [templateStringInObjectLiteral.js] -<<<<<<< HEAD var x = (_a = ["b"], _a.raw = ["b"], ({ - a: "abc" + 123 + "def" -})(_a)); -======= -var x = { - a: "abc" + 123 + "def" } "b"; ->>>>>>> master + a: "abc" + 123 + "def" })(_a)); 321; var _a; From 964ed7f0fd1b6c1eaee47780c59c9086facf7746 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Tue, 24 Feb 2015 06:29:21 +0100 Subject: [PATCH 31/96] Rename callback to literalEmitter --- src/compiler/emitter.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a3b85c362ad..04c32385d32 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2220,16 +2220,16 @@ module ts { write('"' + text + '"'); } - function emitDownlevelTaggedTemplateArray(node: TaggedTemplateExpression, callback: (literal: LiteralExpression) => void) { + function emitDownlevelTaggedTemplateArray(node: TaggedTemplateExpression, literalEmitter: (literal: LiteralExpression) => void) { write("["); if (node.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral) { - callback(node.template); + literalEmitter(node.template); } else { - callback((node.template).head); + literalEmitter((node.template).head); forEach((node.template).templateSpans, (child) => { write(", "); - callback(child.literal); + literalEmitter(child.literal); }); } write("]"); From 904b5204c83dfa87b776fa690c4ddc55fc9c5d5d Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Tue, 24 Feb 2015 07:13:38 +0100 Subject: [PATCH 32/96] operator -> operatorToken.kind --- src/compiler/emitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 04c32385d32..d4f3cd59615 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2257,7 +2257,7 @@ module ts { forEach((node.template).templateSpans, templateSpan => { write(", "); var needsParens = templateSpan.expression.kind === SyntaxKind.BinaryExpression - && (templateSpan.expression).operator === SyntaxKind.CommaToken; + && (templateSpan.expression).operatorToken.kind === SyntaxKind.CommaToken; emitParenthesizedIf(templateSpan.expression, needsParens); }); } From 88911284269b7d7e3eb269b3a61f0a67197e35ed Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 24 Feb 2015 23:36:02 -0800 Subject: [PATCH 33/96] moved name generation logic to utilities --- src/compiler/checker.ts | 21 ++---------- src/compiler/emitter.ts | 68 +++++++++++++++++++++++---------------- src/compiler/utilities.ts | 23 +++++++++++++ 3 files changed, 65 insertions(+), 47 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a9891eb0bde..68e88437647 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10515,25 +10515,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) { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 43422b4bb30..9bfc14caaa0 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -38,6 +38,11 @@ module ts { previous: ScopeFrame; } + interface NameLookup { + setLocation(location: Node): void; + isExistingName(name: string): boolean; + } + type GetSymbolAccessibilityDiagnostic = (symbolAccesibilityResult: SymbolAccessiblityResult) => SymbolAccessibilityDiagnostic; interface EmitTextWriterWithSymbolWriter extends EmitTextWriter, SymbolWriter { @@ -1535,6 +1540,7 @@ module ts { var sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap ? [] : undefined; var diagnostics: Diagnostic[] = []; var newLine = host.getNewLine(); + var nameLookup: NameLookup; if (targetSourceFile === undefined) { forEach(host.getSourceFiles(), sourceFile => { @@ -1677,34 +1683,37 @@ module ts { } } - function makeUniqueName(location: Node, baseName: string): string { - if (!isExistingName(location, baseName)) { - // use current name as is - return setGeneratedName(baseName); + function createNameLookup(): NameLookup { + var location: Node; + return { + setLocation, + isExistingName: checkName } - // First try '_name' - if (baseName.charCodeAt(0) !== CharacterCodes._) { - var baseName = "_" + baseName; - if (!isExistingName(location, baseName)) { - return setGeneratedName(baseName); - } + function setLocation(l: Node): void { + location = l; } - // 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(location, name)) { - return setGeneratedName(name); - } - i++; + + function checkName(name: string): boolean { + Debug.assert(location !== undefined); + return isExistingName(location, name); } } - function setGeneratedName(name: string): string { + function makeUniqueName(location: Node, baseName: string): string { + var name: string + if (!isExistingName(location, baseName)) { + name = baseName; + } + else { + if (!nameLookup) { + nameLookup = createNameLookup(); + } + nameLookup.setLocation(location); + name = generateUniqueName(baseName, nameLookup.isExistingName); + nameLookup.setLocation(undefined); + } + if (!currentScopeNames) { currentScopeNames = {}; } @@ -1712,9 +1721,12 @@ module ts { return currentScopeNames[name] = name; } + function isGeneratedName(name: string): boolean { + return currentScopeNames && hasProperty(currentScopeNames, name); + } function isExistingName(location: Node, name: string) { - return !resolver.isUnknownIdentifier(location, name) || (currentScopeNames && hasProperty(currentScopeNames, name)); + return !resolver.isUnknownIdentifier(location, name) || isGeneratedName(name); } function initializeEmitterWithSourceMaps() { @@ -2484,9 +2496,9 @@ module ts { } function emitIdentifier(node: Identifier) { - var symbolId = getBlockScopedVariableId(node); - if (symbolId !== undefined && generatedBlockScopeNames) { - var text = generatedBlockScopeNames[symbolId]; + var variableId = getBlockScopedVariableId(node); + if (variableId !== undefined && generatedBlockScopeNames) { + var text = generatedBlockScopeNames[variableId]; if (text) { write(text); return; @@ -3882,11 +3894,11 @@ module ts { } var generatedName = makeUniqueName(getEnclosingBlockScopeContainer(node), (node).text); - var symbolId = resolver.getBlockScopedVariableId(node); + var variableId = resolver.getBlockScopedVariableId(node); if (!generatedBlockScopeNames) { generatedBlockScopeNames = []; } - generatedBlockScopeNames[symbolId] = generatedName; + generatedBlockScopeNames[variableId] = generatedName; } function emitVariableStatement(node: VariableStatement) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index c5bb46aa962..437894d9cfc 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1117,6 +1117,29 @@ module ts { return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength: */newEndN - oldStartN); } + // @internal + 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) { + name = baseName + i; + if (!isExistingName(name)) { + return name; + } + i++; + } + } + // @internal export function createDiagnosticCollection(): DiagnosticCollection { var nonFileDiagnostics: Diagnostic[] = []; From 65431a963beb14529d3b8ba705cbdd1f706f0c07 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 25 Feb 2015 13:54:09 -0800 Subject: [PATCH 34/96] Check if the module exist before extracting exports from it --- src/compiler/checker.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c807406d534..dc9f5d07b2d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -751,7 +751,10 @@ module ts { forEach(symbol.declarations, node => { if (node.kind === SyntaxKind.SourceFile || node.kind === SyntaxKind.ModuleDeclaration) { forEach((node).exportStars, exportStar => { - visit(resolveExternalModuleName(exportStar, exportStar.moduleSpecifier)); + var moduleSymbol = resolveExternalModuleName(exportStar, exportStar.moduleSpecifier); + if (moduleSymbol) { + visit(moduleSymbol); + } }); } }); From 30cc1cc47859f1d639373b05fb3761e4694d33a5 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 25 Feb 2015 14:00:44 -0800 Subject: [PATCH 35/96] Add support for new import syntax in preprocessFile --- src/services/services.ts | 137 ++++++++++++++++-- .../unittests/services/preProcessFile.ts | 46 +++++- 2 files changed, 167 insertions(+), 16 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 0b23b134bc5..a2400369aa2 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1752,33 +1752,142 @@ 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.OpenBraceToken && 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.OpenBraceToken && 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(); + } } } } diff --git a/tests/cases/unittests/services/preProcessFile.ts b/tests/cases/unittests/services/preProcessFile.ts index e0d397838e0..c504f444f18 100644 --- a/tests/cases/unittests/services/preProcessFile.ts +++ b/tests/cases/unittests/services/preProcessFile.ts @@ -26,7 +26,7 @@ describe('PreProcessFile:', function () { var expectedImportedFile = expectedImportedFiles[i]; assert.equal(resultImportedFile.fileName, expectedImportedFile.fileName, "Imported file path does not match expected. Expected: " + expectedImportedFile.fileName + ". Actual: " + resultImportedFile.fileName + "."); - + assert.equal(resultImportedFile.pos, expectedImportedFile.pos, "Imported file position does not match expected. Expected: " + expectedImportedFile.pos + ". Actual: " + resultImportedFile.pos + "."); assert.equal(resultImportedFile.end, expectedImportedFile.end, "Imported file length does not match expected. Expected: " + expectedImportedFile.end + ". Actual: " + resultImportedFile.end + "."); @@ -37,7 +37,7 @@ describe('PreProcessFile:', function () { var expectedReferencedFile = expectedReferencedFiles[i]; assert.equal(resultReferencedFile.fileName, expectedReferencedFile.fileName, "Referenced file path does not match expected. Expected: " + expectedReferencedFile.fileName + ". Actual: " + resultReferencedFile.fileName + "."); - + assert.equal(resultReferencedFile.pos, expectedReferencedFile.pos, "Referenced file position does not match expected. Expected: " + expectedReferencedFile.pos + ". Actual: " + resultReferencedFile.pos + "."); assert.equal(resultReferencedFile.end, expectedReferencedFile.end, "Referenced file length does not match expected. Expected: " + expectedReferencedFile.end + ". Actual: " + resultReferencedFile.end + "."); @@ -108,6 +108,48 @@ describe('PreProcessFile:', function () { isLibFile: false }) }); + + it("Correctly return ES6 imports", function () { + test("import * as ns from \"m1\";" + "\n" + + "import def, * as ns from \"m2\";" + "\n" + + "import def from \"m3\";" + "\n" + + "import {a} from \"m4\";" + "\n" + + "import {a as A} from \"m5\";" + "\n" + + "import {a as A, b, c as C} from \"m6\";" + "\n" + + "import def , {a, b, c as C} from \"m7\";" + "\n", + true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "m1", pos: 20, end: 22 }, + { fileName: "m2", pos: 51, end: 53 }, + { fileName: "m3", pos: 73, end: 75 }, + { fileName: "m4", pos: 95, end: 97 }, + { fileName: "m5", pos: 122, end: 124 }, + { fileName: "m6", pos: 160, end: 162 }, + { fileName: "m7", pos: 199, end: 201 } + ], + isLibFile: false + }) + }); + + it("Correctly return ES6 exports", function () { + test("export * from \"m1\";" + "\n" + + "export {a} from \"m2\";" + "\n" + + "export {a as A} from \"m3\";" + "\n" + + "export {a as A, b, c as C} from \"m4\";" + "\n", + true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "m1", pos: 14, end: 16 }, + { fileName: "m2", pos: 36, end: 38 }, + { fileName: "m3", pos: 63, end: 65 }, + { fileName: "m4", pos: 101, end: 103 }, + ], + isLibFile: false + }) + }); }); }); From 33dfe5068a2ee2f5880fd604fadb7d40a2597fd3 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 25 Feb 2015 17:44:09 -0800 Subject: [PATCH 36/96] do not emit default initializer for let\const in for-in\for-of statements --- src/compiler/checker.ts | 2 +- src/compiler/emitter.ts | 40 ++++++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 68e88437647..7918d393c0b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5119,9 +5119,9 @@ module ts { while (current && !isNameScopeBoundary(current)) { if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { if (inFunction) { - getNodeLinks(current).flags |= NodeCheckFlags.BlockScopedBindingInLoop; grammarErrorOnFirstToken(current, Diagnostics.Code_in_the_loop_captures_block_scoped_variable_0_in_closure_This_is_natively_supported_in_ECMAScript_6_or_higher, declarationNameToString(node)); } + // mark value declaration so during emit they can have a special handling getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.BlockScopedBindingInLoop; break; } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 9bfc14caaa0..1cec38872af 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1702,6 +1702,7 @@ module ts { function makeUniqueName(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; } @@ -1721,12 +1722,9 @@ module ts { return currentScopeNames[name] = name; } - function isGeneratedName(name: string): boolean { - return currentScopeNames && hasProperty(currentScopeNames, name); - } - function isExistingName(location: Node, name: string) { - return !resolver.isUnknownIdentifier(location, name) || isGeneratedName(name); + return !resolver.isUnknownIdentifier(location, name) || + (currentScopeNames && hasProperty(currentScopeNames, name)); } function initializeEmitterWithSourceMaps() { @@ -3559,7 +3557,6 @@ module ts { result.expression = zero; return result; } - function emitExportMemberAssignments(name: Identifier) { if (exportSpecifiers && hasProperty(exportSpecifiers, name.text)) { @@ -3802,18 +3799,24 @@ module ts { emitModuleMemberName(node); var initializer = node.initializer; - if (!initializer) { + if (!initializer && languageVersion < ScriptTarget.ES6) { + // downlevel emit for non-initialized let bindings defined in loops // for (...) { let x; } // should be // for (...) { var = void 0; } // this is necessary to preserve ES6 semantic in scenarios like // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations - var initializer = - languageVersion < ScriptTarget.ES6 && + var isUninitializedLet = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.BlockScopedBindingInLoop) && - (getCombinedFlagsForIdentifier(node.name) & NodeFlags.Let) && - createVoidZero(); + (getCombinedFlagsForIdentifier(node.name) & NodeFlags.Let); + + // NOTE: default initialization should not be added to let bindings in for-in\for-of statements + if (isUninitializedLet && + node.parent.parent.kind !== SyntaxKind.ForInStatement && + node.parent.parent.kind !== SyntaxKind.ForOfStatement) { + initializer = createVoidZero(); + } } emitOptional(" = ", initializer); @@ -3834,20 +3837,20 @@ module ts { var current = node; while (current) { if (isAnyFunction(current)) { - return current.parent; + return current; } switch (current.kind) { case SyntaxKind.CatchClause: case SyntaxKind.ForStatement: case SyntaxKind.ForInStatement: case SyntaxKind.SwitchKeyword: - return current.parent; + return current; case SyntaxKind.Block: if (isAnyFunction(current.parent)) { - return current.parent.parent; + return current.parent; } else { - return current.parent; + return current; } case SyntaxKind.SourceFile: return current; @@ -3893,7 +3896,12 @@ module ts { return; } - var generatedName = makeUniqueName(getEnclosingBlockScopeContainer(node), (node).text); + var blockScopeContainer = getEnclosingBlockScopeContainer(node); + var parent = blockScopeContainer.kind === SyntaxKind.SourceFile + ? blockScopeContainer + : blockScopeContainer.parent; + + var generatedName = makeUniqueName(parent, (node).text); var variableId = resolver.getBlockScopedVariableId(node); if (!generatedBlockScopeNames) { generatedBlockScopeNames = []; From 32aef1a031b0386f2968a8b2636822cd417d730a Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 25 Feb 2015 18:01:40 -0800 Subject: [PATCH 37/96] do not report error on non-initialized const bindings in for-in\for-of statements --- src/compiler/checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7918d393c0b..7094f9e7ea8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11498,7 +11498,8 @@ module ts { if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) { return grammarErrorOnNode(node, Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (isConst(node)) { + // const declarations should not be initialized in for-in for-of statements + if (isConst(node) && node.parent.parent.kind !== SyntaxKind.ForInStatement && node.parent.parent.kind !== SyntaxKind.ForOfStatement) { return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized); } } From 3a3af530d464659065920fecfb4453f7b7157209 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Wed, 25 Feb 2015 21:46:55 -0800 Subject: [PATCH 38/96] 'from' is a contextual keyword, and should only be recognized as by the parser as such. --- src/compiler/types.ts | 7 +-- .../baselines/reference/APISample_compile.js | 48 ++++++++--------- .../reference/APISample_compile.types | 52 +++++++++---------- tests/baselines/reference/APISample_linter.js | 48 ++++++++--------- .../reference/APISample_linter.types | 52 +++++++++---------- .../reference/APISample_transform.js | 48 ++++++++--------- .../reference/APISample_transform.types | 52 +++++++++---------- .../baselines/reference/APISample_watcher.js | 48 ++++++++--------- .../reference/APISample_watcher.types | 52 +++++++++---------- .../baselines/reference/fromAsIdentifier1.js | 5 ++ .../reference/fromAsIdentifier1.types | 4 ++ .../baselines/reference/fromAsIdentifier2.js | 7 +++ .../reference/fromAsIdentifier2.types | 5 ++ tests/cases/compiler/fromAsIdentifier1.ts | 1 + tests/cases/compiler/fromAsIdentifier2.ts | 2 + 15 files changed, 228 insertions(+), 203 deletions(-) create mode 100644 tests/baselines/reference/fromAsIdentifier1.js create mode 100644 tests/baselines/reference/fromAsIdentifier1.types create mode 100644 tests/baselines/reference/fromAsIdentifier2.js create mode 100644 tests/baselines/reference/fromAsIdentifier2.types create mode 100644 tests/cases/compiler/fromAsIdentifier1.ts create mode 100644 tests/cases/compiler/fromAsIdentifier2.ts diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a81da0eaf74..d1730ce1f1b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -121,7 +121,6 @@ module ts { WithKeyword, // Strict mode reserved words AsKeyword, - FromKeyword, ImplementsKeyword, InterfaceKeyword, LetKeyword, @@ -131,7 +130,7 @@ module ts { PublicKeyword, StaticKeyword, YieldKeyword, - // TypeScript keywords + // Contextual keywords AnyKeyword, BooleanKeyword, ConstructorKeyword, @@ -144,7 +143,9 @@ module ts { StringKeyword, SymbolKeyword, TypeKeyword, + FromKeyword, OfKeyword, // LastKeyword and LastToken + // Parse tree nodes // Names @@ -279,7 +280,7 @@ module ts { FirstPunctuation = OpenBraceToken, LastPunctuation = CaretEqualsToken, FirstToken = Unknown, - LastToken = OfKeyword, + LastToken = LastKeyword, FirstTriviaToken = SingleLineCommentTrivia, LastTriviaToken = ConflictMarkerTrivia, FirstLiteralToken = NumericLiteral, diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index ba9aced3b24..5381b327504 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -161,28 +161,28 @@ declare module "typescript" { WhileKeyword = 99, WithKeyword = 100, AsKeyword = 101, - FromKeyword = 102, - ImplementsKeyword = 103, - InterfaceKeyword = 104, - LetKeyword = 105, - PackageKeyword = 106, - PrivateKeyword = 107, - ProtectedKeyword = 108, - PublicKeyword = 109, - StaticKeyword = 110, - YieldKeyword = 111, - AnyKeyword = 112, - BooleanKeyword = 113, - ConstructorKeyword = 114, - DeclareKeyword = 115, - GetKeyword = 116, - ModuleKeyword = 117, - RequireKeyword = 118, - NumberKeyword = 119, - SetKeyword = 120, - StringKeyword = 121, - SymbolKeyword = 122, - TypeKeyword = 123, + ImplementsKeyword = 102, + InterfaceKeyword = 103, + LetKeyword = 104, + PackageKeyword = 105, + PrivateKeyword = 106, + ProtectedKeyword = 107, + PublicKeyword = 108, + StaticKeyword = 109, + YieldKeyword = 110, + AnyKeyword = 111, + BooleanKeyword = 112, + ConstructorKeyword = 113, + DeclareKeyword = 114, + GetKeyword = 115, + ModuleKeyword = 116, + RequireKeyword = 117, + NumberKeyword = 118, + SetKeyword = 119, + StringKeyword = 120, + SymbolKeyword = 121, + TypeKeyword = 122, + FromKeyword = 123, OfKeyword = 124, QualifiedName = 125, ComputedPropertyName = 126, @@ -288,8 +288,8 @@ declare module "typescript" { LastReservedWord = 100, FirstKeyword = 65, LastKeyword = 124, - FirstFutureReservedWord = 103, - LastFutureReservedWord = 111, + FirstFutureReservedWord = 102, + LastFutureReservedWord = 110, FirstTypeNode = 139, LastTypeNode = 147, FirstPunctuation = 14, diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index 3ad078773da..106fa45e424 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -501,72 +501,72 @@ declare module "typescript" { AsKeyword = 101, >AsKeyword : SyntaxKind - FromKeyword = 102, ->FromKeyword : SyntaxKind - - ImplementsKeyword = 103, + ImplementsKeyword = 102, >ImplementsKeyword : SyntaxKind - InterfaceKeyword = 104, + InterfaceKeyword = 103, >InterfaceKeyword : SyntaxKind - LetKeyword = 105, + LetKeyword = 104, >LetKeyword : SyntaxKind - PackageKeyword = 106, + PackageKeyword = 105, >PackageKeyword : SyntaxKind - PrivateKeyword = 107, + PrivateKeyword = 106, >PrivateKeyword : SyntaxKind - ProtectedKeyword = 108, + ProtectedKeyword = 107, >ProtectedKeyword : SyntaxKind - PublicKeyword = 109, + PublicKeyword = 108, >PublicKeyword : SyntaxKind - StaticKeyword = 110, + StaticKeyword = 109, >StaticKeyword : SyntaxKind - YieldKeyword = 111, + YieldKeyword = 110, >YieldKeyword : SyntaxKind - AnyKeyword = 112, + AnyKeyword = 111, >AnyKeyword : SyntaxKind - BooleanKeyword = 113, + BooleanKeyword = 112, >BooleanKeyword : SyntaxKind - ConstructorKeyword = 114, + ConstructorKeyword = 113, >ConstructorKeyword : SyntaxKind - DeclareKeyword = 115, + DeclareKeyword = 114, >DeclareKeyword : SyntaxKind - GetKeyword = 116, + GetKeyword = 115, >GetKeyword : SyntaxKind - ModuleKeyword = 117, + ModuleKeyword = 116, >ModuleKeyword : SyntaxKind - RequireKeyword = 118, + RequireKeyword = 117, >RequireKeyword : SyntaxKind - NumberKeyword = 119, + NumberKeyword = 118, >NumberKeyword : SyntaxKind - SetKeyword = 120, + SetKeyword = 119, >SetKeyword : SyntaxKind - StringKeyword = 121, + StringKeyword = 120, >StringKeyword : SyntaxKind - SymbolKeyword = 122, + SymbolKeyword = 121, >SymbolKeyword : SyntaxKind - TypeKeyword = 123, + TypeKeyword = 122, >TypeKeyword : SyntaxKind + FromKeyword = 123, +>FromKeyword : SyntaxKind + OfKeyword = 124, >OfKeyword : SyntaxKind @@ -882,10 +882,10 @@ declare module "typescript" { LastKeyword = 124, >LastKeyword : SyntaxKind - FirstFutureReservedWord = 103, + FirstFutureReservedWord = 102, >FirstFutureReservedWord : SyntaxKind - LastFutureReservedWord = 111, + LastFutureReservedWord = 110, >LastFutureReservedWord : SyntaxKind FirstTypeNode = 139, diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 54bb4a0dd80..47183c920b4 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -192,28 +192,28 @@ declare module "typescript" { WhileKeyword = 99, WithKeyword = 100, AsKeyword = 101, - FromKeyword = 102, - ImplementsKeyword = 103, - InterfaceKeyword = 104, - LetKeyword = 105, - PackageKeyword = 106, - PrivateKeyword = 107, - ProtectedKeyword = 108, - PublicKeyword = 109, - StaticKeyword = 110, - YieldKeyword = 111, - AnyKeyword = 112, - BooleanKeyword = 113, - ConstructorKeyword = 114, - DeclareKeyword = 115, - GetKeyword = 116, - ModuleKeyword = 117, - RequireKeyword = 118, - NumberKeyword = 119, - SetKeyword = 120, - StringKeyword = 121, - SymbolKeyword = 122, - TypeKeyword = 123, + ImplementsKeyword = 102, + InterfaceKeyword = 103, + LetKeyword = 104, + PackageKeyword = 105, + PrivateKeyword = 106, + ProtectedKeyword = 107, + PublicKeyword = 108, + StaticKeyword = 109, + YieldKeyword = 110, + AnyKeyword = 111, + BooleanKeyword = 112, + ConstructorKeyword = 113, + DeclareKeyword = 114, + GetKeyword = 115, + ModuleKeyword = 116, + RequireKeyword = 117, + NumberKeyword = 118, + SetKeyword = 119, + StringKeyword = 120, + SymbolKeyword = 121, + TypeKeyword = 122, + FromKeyword = 123, OfKeyword = 124, QualifiedName = 125, ComputedPropertyName = 126, @@ -319,8 +319,8 @@ declare module "typescript" { LastReservedWord = 100, FirstKeyword = 65, LastKeyword = 124, - FirstFutureReservedWord = 103, - LastFutureReservedWord = 111, + FirstFutureReservedWord = 102, + LastFutureReservedWord = 110, FirstTypeNode = 139, LastTypeNode = 147, FirstPunctuation = 14, diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 59bb6cc3b8c..776e7c0bbc1 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -647,72 +647,72 @@ declare module "typescript" { AsKeyword = 101, >AsKeyword : SyntaxKind - FromKeyword = 102, ->FromKeyword : SyntaxKind - - ImplementsKeyword = 103, + ImplementsKeyword = 102, >ImplementsKeyword : SyntaxKind - InterfaceKeyword = 104, + InterfaceKeyword = 103, >InterfaceKeyword : SyntaxKind - LetKeyword = 105, + LetKeyword = 104, >LetKeyword : SyntaxKind - PackageKeyword = 106, + PackageKeyword = 105, >PackageKeyword : SyntaxKind - PrivateKeyword = 107, + PrivateKeyword = 106, >PrivateKeyword : SyntaxKind - ProtectedKeyword = 108, + ProtectedKeyword = 107, >ProtectedKeyword : SyntaxKind - PublicKeyword = 109, + PublicKeyword = 108, >PublicKeyword : SyntaxKind - StaticKeyword = 110, + StaticKeyword = 109, >StaticKeyword : SyntaxKind - YieldKeyword = 111, + YieldKeyword = 110, >YieldKeyword : SyntaxKind - AnyKeyword = 112, + AnyKeyword = 111, >AnyKeyword : SyntaxKind - BooleanKeyword = 113, + BooleanKeyword = 112, >BooleanKeyword : SyntaxKind - ConstructorKeyword = 114, + ConstructorKeyword = 113, >ConstructorKeyword : SyntaxKind - DeclareKeyword = 115, + DeclareKeyword = 114, >DeclareKeyword : SyntaxKind - GetKeyword = 116, + GetKeyword = 115, >GetKeyword : SyntaxKind - ModuleKeyword = 117, + ModuleKeyword = 116, >ModuleKeyword : SyntaxKind - RequireKeyword = 118, + RequireKeyword = 117, >RequireKeyword : SyntaxKind - NumberKeyword = 119, + NumberKeyword = 118, >NumberKeyword : SyntaxKind - SetKeyword = 120, + SetKeyword = 119, >SetKeyword : SyntaxKind - StringKeyword = 121, + StringKeyword = 120, >StringKeyword : SyntaxKind - SymbolKeyword = 122, + SymbolKeyword = 121, >SymbolKeyword : SyntaxKind - TypeKeyword = 123, + TypeKeyword = 122, >TypeKeyword : SyntaxKind + FromKeyword = 123, +>FromKeyword : SyntaxKind + OfKeyword = 124, >OfKeyword : SyntaxKind @@ -1028,10 +1028,10 @@ declare module "typescript" { LastKeyword = 124, >LastKeyword : SyntaxKind - FirstFutureReservedWord = 103, + FirstFutureReservedWord = 102, >FirstFutureReservedWord : SyntaxKind - LastFutureReservedWord = 111, + LastFutureReservedWord = 110, >LastFutureReservedWord : SyntaxKind FirstTypeNode = 139, diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 42bb19f5b68..ea323ba927f 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -193,28 +193,28 @@ declare module "typescript" { WhileKeyword = 99, WithKeyword = 100, AsKeyword = 101, - FromKeyword = 102, - ImplementsKeyword = 103, - InterfaceKeyword = 104, - LetKeyword = 105, - PackageKeyword = 106, - PrivateKeyword = 107, - ProtectedKeyword = 108, - PublicKeyword = 109, - StaticKeyword = 110, - YieldKeyword = 111, - AnyKeyword = 112, - BooleanKeyword = 113, - ConstructorKeyword = 114, - DeclareKeyword = 115, - GetKeyword = 116, - ModuleKeyword = 117, - RequireKeyword = 118, - NumberKeyword = 119, - SetKeyword = 120, - StringKeyword = 121, - SymbolKeyword = 122, - TypeKeyword = 123, + ImplementsKeyword = 102, + InterfaceKeyword = 103, + LetKeyword = 104, + PackageKeyword = 105, + PrivateKeyword = 106, + ProtectedKeyword = 107, + PublicKeyword = 108, + StaticKeyword = 109, + YieldKeyword = 110, + AnyKeyword = 111, + BooleanKeyword = 112, + ConstructorKeyword = 113, + DeclareKeyword = 114, + GetKeyword = 115, + ModuleKeyword = 116, + RequireKeyword = 117, + NumberKeyword = 118, + SetKeyword = 119, + StringKeyword = 120, + SymbolKeyword = 121, + TypeKeyword = 122, + FromKeyword = 123, OfKeyword = 124, QualifiedName = 125, ComputedPropertyName = 126, @@ -320,8 +320,8 @@ declare module "typescript" { LastReservedWord = 100, FirstKeyword = 65, LastKeyword = 124, - FirstFutureReservedWord = 103, - LastFutureReservedWord = 111, + FirstFutureReservedWord = 102, + LastFutureReservedWord = 110, FirstTypeNode = 139, LastTypeNode = 147, FirstPunctuation = 14, diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index b3aca495547..9abc0385d07 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -597,72 +597,72 @@ declare module "typescript" { AsKeyword = 101, >AsKeyword : SyntaxKind - FromKeyword = 102, ->FromKeyword : SyntaxKind - - ImplementsKeyword = 103, + ImplementsKeyword = 102, >ImplementsKeyword : SyntaxKind - InterfaceKeyword = 104, + InterfaceKeyword = 103, >InterfaceKeyword : SyntaxKind - LetKeyword = 105, + LetKeyword = 104, >LetKeyword : SyntaxKind - PackageKeyword = 106, + PackageKeyword = 105, >PackageKeyword : SyntaxKind - PrivateKeyword = 107, + PrivateKeyword = 106, >PrivateKeyword : SyntaxKind - ProtectedKeyword = 108, + ProtectedKeyword = 107, >ProtectedKeyword : SyntaxKind - PublicKeyword = 109, + PublicKeyword = 108, >PublicKeyword : SyntaxKind - StaticKeyword = 110, + StaticKeyword = 109, >StaticKeyword : SyntaxKind - YieldKeyword = 111, + YieldKeyword = 110, >YieldKeyword : SyntaxKind - AnyKeyword = 112, + AnyKeyword = 111, >AnyKeyword : SyntaxKind - BooleanKeyword = 113, + BooleanKeyword = 112, >BooleanKeyword : SyntaxKind - ConstructorKeyword = 114, + ConstructorKeyword = 113, >ConstructorKeyword : SyntaxKind - DeclareKeyword = 115, + DeclareKeyword = 114, >DeclareKeyword : SyntaxKind - GetKeyword = 116, + GetKeyword = 115, >GetKeyword : SyntaxKind - ModuleKeyword = 117, + ModuleKeyword = 116, >ModuleKeyword : SyntaxKind - RequireKeyword = 118, + RequireKeyword = 117, >RequireKeyword : SyntaxKind - NumberKeyword = 119, + NumberKeyword = 118, >NumberKeyword : SyntaxKind - SetKeyword = 120, + SetKeyword = 119, >SetKeyword : SyntaxKind - StringKeyword = 121, + StringKeyword = 120, >StringKeyword : SyntaxKind - SymbolKeyword = 122, + SymbolKeyword = 121, >SymbolKeyword : SyntaxKind - TypeKeyword = 123, + TypeKeyword = 122, >TypeKeyword : SyntaxKind + FromKeyword = 123, +>FromKeyword : SyntaxKind + OfKeyword = 124, >OfKeyword : SyntaxKind @@ -978,10 +978,10 @@ declare module "typescript" { LastKeyword = 124, >LastKeyword : SyntaxKind - FirstFutureReservedWord = 103, + FirstFutureReservedWord = 102, >FirstFutureReservedWord : SyntaxKind - LastFutureReservedWord = 111, + LastFutureReservedWord = 110, >LastFutureReservedWord : SyntaxKind FirstTypeNode = 139, diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index cafb7f94ce1..3e80b34ba0e 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -230,28 +230,28 @@ declare module "typescript" { WhileKeyword = 99, WithKeyword = 100, AsKeyword = 101, - FromKeyword = 102, - ImplementsKeyword = 103, - InterfaceKeyword = 104, - LetKeyword = 105, - PackageKeyword = 106, - PrivateKeyword = 107, - ProtectedKeyword = 108, - PublicKeyword = 109, - StaticKeyword = 110, - YieldKeyword = 111, - AnyKeyword = 112, - BooleanKeyword = 113, - ConstructorKeyword = 114, - DeclareKeyword = 115, - GetKeyword = 116, - ModuleKeyword = 117, - RequireKeyword = 118, - NumberKeyword = 119, - SetKeyword = 120, - StringKeyword = 121, - SymbolKeyword = 122, - TypeKeyword = 123, + ImplementsKeyword = 102, + InterfaceKeyword = 103, + LetKeyword = 104, + PackageKeyword = 105, + PrivateKeyword = 106, + ProtectedKeyword = 107, + PublicKeyword = 108, + StaticKeyword = 109, + YieldKeyword = 110, + AnyKeyword = 111, + BooleanKeyword = 112, + ConstructorKeyword = 113, + DeclareKeyword = 114, + GetKeyword = 115, + ModuleKeyword = 116, + RequireKeyword = 117, + NumberKeyword = 118, + SetKeyword = 119, + StringKeyword = 120, + SymbolKeyword = 121, + TypeKeyword = 122, + FromKeyword = 123, OfKeyword = 124, QualifiedName = 125, ComputedPropertyName = 126, @@ -357,8 +357,8 @@ declare module "typescript" { LastReservedWord = 100, FirstKeyword = 65, LastKeyword = 124, - FirstFutureReservedWord = 103, - LastFutureReservedWord = 111, + FirstFutureReservedWord = 102, + LastFutureReservedWord = 110, FirstTypeNode = 139, LastTypeNode = 147, FirstPunctuation = 14, diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 3a987c0296f..79c2177ce79 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -770,72 +770,72 @@ declare module "typescript" { AsKeyword = 101, >AsKeyword : SyntaxKind - FromKeyword = 102, ->FromKeyword : SyntaxKind - - ImplementsKeyword = 103, + ImplementsKeyword = 102, >ImplementsKeyword : SyntaxKind - InterfaceKeyword = 104, + InterfaceKeyword = 103, >InterfaceKeyword : SyntaxKind - LetKeyword = 105, + LetKeyword = 104, >LetKeyword : SyntaxKind - PackageKeyword = 106, + PackageKeyword = 105, >PackageKeyword : SyntaxKind - PrivateKeyword = 107, + PrivateKeyword = 106, >PrivateKeyword : SyntaxKind - ProtectedKeyword = 108, + ProtectedKeyword = 107, >ProtectedKeyword : SyntaxKind - PublicKeyword = 109, + PublicKeyword = 108, >PublicKeyword : SyntaxKind - StaticKeyword = 110, + StaticKeyword = 109, >StaticKeyword : SyntaxKind - YieldKeyword = 111, + YieldKeyword = 110, >YieldKeyword : SyntaxKind - AnyKeyword = 112, + AnyKeyword = 111, >AnyKeyword : SyntaxKind - BooleanKeyword = 113, + BooleanKeyword = 112, >BooleanKeyword : SyntaxKind - ConstructorKeyword = 114, + ConstructorKeyword = 113, >ConstructorKeyword : SyntaxKind - DeclareKeyword = 115, + DeclareKeyword = 114, >DeclareKeyword : SyntaxKind - GetKeyword = 116, + GetKeyword = 115, >GetKeyword : SyntaxKind - ModuleKeyword = 117, + ModuleKeyword = 116, >ModuleKeyword : SyntaxKind - RequireKeyword = 118, + RequireKeyword = 117, >RequireKeyword : SyntaxKind - NumberKeyword = 119, + NumberKeyword = 118, >NumberKeyword : SyntaxKind - SetKeyword = 120, + SetKeyword = 119, >SetKeyword : SyntaxKind - StringKeyword = 121, + StringKeyword = 120, >StringKeyword : SyntaxKind - SymbolKeyword = 122, + SymbolKeyword = 121, >SymbolKeyword : SyntaxKind - TypeKeyword = 123, + TypeKeyword = 122, >TypeKeyword : SyntaxKind + FromKeyword = 123, +>FromKeyword : SyntaxKind + OfKeyword = 124, >OfKeyword : SyntaxKind @@ -1151,10 +1151,10 @@ declare module "typescript" { LastKeyword = 124, >LastKeyword : SyntaxKind - FirstFutureReservedWord = 103, + FirstFutureReservedWord = 102, >FirstFutureReservedWord : SyntaxKind - LastFutureReservedWord = 111, + LastFutureReservedWord = 110, >LastFutureReservedWord : SyntaxKind FirstTypeNode = 139, diff --git a/tests/baselines/reference/fromAsIdentifier1.js b/tests/baselines/reference/fromAsIdentifier1.js new file mode 100644 index 00000000000..54054e9f3e8 --- /dev/null +++ b/tests/baselines/reference/fromAsIdentifier1.js @@ -0,0 +1,5 @@ +//// [fromAsIdentifier1.ts] +var from; + +//// [fromAsIdentifier1.js] +var from; diff --git a/tests/baselines/reference/fromAsIdentifier1.types b/tests/baselines/reference/fromAsIdentifier1.types new file mode 100644 index 00000000000..988a80f3337 --- /dev/null +++ b/tests/baselines/reference/fromAsIdentifier1.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/fromAsIdentifier1.ts === +var from; +>from : any + diff --git a/tests/baselines/reference/fromAsIdentifier2.js b/tests/baselines/reference/fromAsIdentifier2.js new file mode 100644 index 00000000000..efdbdb3c57d --- /dev/null +++ b/tests/baselines/reference/fromAsIdentifier2.js @@ -0,0 +1,7 @@ +//// [fromAsIdentifier2.ts] +"use strict"; +var from; + +//// [fromAsIdentifier2.js] +"use strict"; +var from; diff --git a/tests/baselines/reference/fromAsIdentifier2.types b/tests/baselines/reference/fromAsIdentifier2.types new file mode 100644 index 00000000000..5faf9ec6f6c --- /dev/null +++ b/tests/baselines/reference/fromAsIdentifier2.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/fromAsIdentifier2.ts === +"use strict"; +var from; +>from : any + diff --git a/tests/cases/compiler/fromAsIdentifier1.ts b/tests/cases/compiler/fromAsIdentifier1.ts new file mode 100644 index 00000000000..91497ab477e --- /dev/null +++ b/tests/cases/compiler/fromAsIdentifier1.ts @@ -0,0 +1 @@ +var from; \ No newline at end of file diff --git a/tests/cases/compiler/fromAsIdentifier2.ts b/tests/cases/compiler/fromAsIdentifier2.ts new file mode 100644 index 00000000000..037e2128ce9 --- /dev/null +++ b/tests/cases/compiler/fromAsIdentifier2.ts @@ -0,0 +1,2 @@ +"use strict"; +var from; \ No newline at end of file From 2b10d394d4b9bee0c670f84fedf48735c167680f Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Thu, 26 Feb 2015 12:01:19 +0100 Subject: [PATCH 39/96] Update baselines --- .../taggedTemplateStringsHexadecimalEscapes.js | 4 ++++ ...lainCharactersThatArePartsOfEscapes01.errors.txt | 13 ------------- ...StringsPlainCharactersThatArePartsOfEscapes01.js | 3 ++- ...ingsPlainCharactersThatArePartsOfEscapes01.types | 12 ++++++++++++ .../taggedTemplateStringsWithMultilineTemplate.js | 4 ++++ .../taggedTemplateStringsWithUnicodeEscapes.js | 6 +++++- .../taggedTemplateStringsWithWhitespaceEscapes.js | 4 ++++ 7 files changed, 31 insertions(+), 15 deletions(-) delete mode 100644 tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.errors.txt create mode 100644 tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.types diff --git a/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.js b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.js index f07c364d660..e4482ded0c2 100644 --- a/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.js +++ b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.js @@ -6,6 +6,10 @@ f `\x0D${ "Interrupted CRLF" }\x0A`; //// [taggedTemplateStringsHexadecimalEscapes.js] function f() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } } (_a = ["\r", "\n"], _a.raw = ["\\x0D", "\\x0A"], f(_a, "Interrupted CRLF")); var _a; diff --git a/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.errors.txt b/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.errors.txt deleted file mode 100644 index 93b22614b95..00000000000 --- a/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.ts(7,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.ts (1 errors) ==== - - - function f(...x: any[]) { - - } - - f `0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n` - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.js b/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.js index 5e5feac077b..9450e939f2f 100644 --- a/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.js +++ b/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.js @@ -14,4 +14,5 @@ function f() { x[_i - 0] = arguments[_i]; } } -f "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n"; +(_a = ["0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n"], _a.raw = ["0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n"], f(_a)); +var _a; diff --git a/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.types b/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.types new file mode 100644 index 00000000000..db793591222 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.ts === + + +function f(...x: any[]) { +>f : (...x: any[]) => void +>x : any[] + +} + +f `0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n` +>f : (...x: any[]) => void + diff --git a/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplate.js b/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplate.js index d65b43c05a8..cee9d1efce4 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplate.js +++ b/tests/baselines/reference/taggedTemplateStringsWithMultilineTemplate.js @@ -9,6 +9,10 @@ f ` //// [taggedTemplateStringsWithMultilineTemplate.js] function f() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } } (_a = ["\n\n"], _a.raw = ["\n\\\n\n"], f(_a)); var _a; diff --git a/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.js b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.js index a046e687877..bcf0732218a 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.js +++ b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.js @@ -6,6 +6,10 @@ f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`; //// [taggedTemplateStringsWithUnicodeEscapes.js] function f() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } } -(_a = ["'{1f4a\u0039}'", "'💩'"], _a.raw = ["'\\u{1f4a\u0039}'", "'\\uD83D\\uDCA\u0039'"], f(_a, " should be converted to ")); +(_a = ["'{1f4a9}'", "'💩'"], _a.raw = ["'\\u{1f4a9}'", "'\\uD83D\\uDCA9'"], f(_a, " should be converted to ")); var _a; diff --git a/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapes.js b/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapes.js index 34bbe4e2105..65af8da59f9 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapes.js +++ b/tests/baselines/reference/taggedTemplateStringsWithWhitespaceEscapes.js @@ -6,6 +6,10 @@ f `\t\n\v\f\r\\`; //// [taggedTemplateStringsWithWhitespaceEscapes.js] function f() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } } (_a = ["\t\n\v\f\r\\"], _a.raw = ["\\t\\n\\v\\f\\r\\\\"], f(_a)); var _a; From b183f8dca672d439f739d78e808d5bb5909fd624 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 26 Feb 2015 00:04:44 -0800 Subject: [PATCH 40/96] added 'nodeIsSynthesized' function, use createSynthesizedNode in emitter to build synthetic nodes --- src/compiler/checker.ts | 12 +++++++++--- src/compiler/emitter.ts | 35 ++++++++++++++--------------------- src/compiler/utilities.ts | 14 ++++++++++++++ 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7094f9e7ea8..9dabafb0cde 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10718,7 +10718,7 @@ module ts { } function getBlockScopedVariableId(n: Identifier): number { - Debug.assert(n.parent !== undefined); + Debug.assert(!nodeIsSynthesized(n)); // ignore name parts of property access expressions if (n.parent.kind === SyntaxKind.PropertyAccessExpression && @@ -10736,8 +10736,14 @@ module ts { var symbol = declarationSymbol || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, SymbolFlags.BlockScopedVariable | SymbolFlags.Import, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); - - return symbol && symbol.flags & SymbolFlags.BlockScopedVariable ? symbol.id : undefined; + + if (symbol && (symbol.flags & SymbolFlags.BlockScopedVariable)) { + // 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 { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 1cec38872af..fbe341ccd28 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -32,7 +32,7 @@ module ts { leadingCommentRanges?: CommentRange[]; trailingCommentRanges?: CommentRange[]; } - + interface ScopeFrame { names: Map; previous: ScopeFrame; @@ -2100,7 +2100,7 @@ module ts { name = "_" + (tempCount < 25 ? String.fromCharCode(tempCount + (tempCount < 8 ? 0 : 1) + CharacterCodes.a) : tempCount - 25); tempCount++; } - var result = createNode(SyntaxKind.Identifier); + var result = createSynthesizedNode(SyntaxKind.Identifier); result.text = name; return result; } @@ -2647,14 +2647,6 @@ module ts { } } - function createSynthesizedNode(kind: SyntaxKind): Node { - var node = createNode(kind); - node.pos = -1; - node.end = -1; - - return node; - } - function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number): void { var parenthesizedObjectLiteral = createDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex); return emit(parenthesizedObjectLiteral); @@ -3551,9 +3543,9 @@ module ts { } function createVoidZero(): Expression { - var zero = createNode(SyntaxKind.NumericLiteral); + var zero = createSynthesizedNode(SyntaxKind.NumericLiteral); zero.text = "0"; - var result = createNode(SyntaxKind.VoidExpression); + var result = createSynthesizedNode(SyntaxKind.VoidExpression); result.expression = zero; return result; } @@ -3619,11 +3611,11 @@ module ts { // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = createNode(SyntaxKind.BinaryExpression); + var equals = createSynthesizedNode(SyntaxKind.BinaryExpression); equals.left = value; - equals.operatorToken = createNode(SyntaxKind.EqualsEqualsEqualsToken); + equals.operatorToken = createSynthesizedNode(SyntaxKind.EqualsEqualsEqualsToken); equals.right = createVoidZero(); - var cond = createNode(SyntaxKind.ConditionalExpression); + var cond = createSynthesizedNode(SyntaxKind.ConditionalExpression); cond.condition = equals; cond.whenTrue = defaultValue; cond.whenFalse = value; @@ -3631,7 +3623,7 @@ module ts { } function createNumericLiteral(value: number) { - var node = createNode(SyntaxKind.NumericLiteral); + var node = createSynthesizedNode(SyntaxKind.NumericLiteral); node.text = "" + value; return node; } @@ -3640,7 +3632,7 @@ module ts { if (expr.kind === SyntaxKind.Identifier || expr.kind === SyntaxKind.PropertyAccessExpression || expr.kind === SyntaxKind.ElementAccessExpression) { return expr; } - var node = createNode(SyntaxKind.ParenthesizedExpression); + var node = createSynthesizedNode(SyntaxKind.ParenthesizedExpression); node.expression = expr; return node; } @@ -3649,14 +3641,14 @@ module ts { if (propName.kind !== SyntaxKind.Identifier) { return createElementAccess(object, propName); } - var node = createNode(SyntaxKind.PropertyAccessExpression); + var node = createSynthesizedNode(SyntaxKind.PropertyAccessExpression); node.expression = parenthesizeForAccess(object); node.name = propName; return node; } function createElementAccess(object: Expression, index: Expression): Expression { - var node = createNode(SyntaxKind.ElementAccessExpression); + var node = createSynthesizedNode(SyntaxKind.ElementAccessExpression); node.expression = parenthesizeForAccess(object); node.argumentExpression = index; return node; @@ -3843,6 +3835,7 @@ module ts { case SyntaxKind.CatchClause: case SyntaxKind.ForStatement: case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: case SyntaxKind.SwitchKeyword: return current; case SyntaxKind.Block: @@ -3872,12 +3865,12 @@ module ts { function renameNonTopLevelLetAndConst(node: Node): void { // do not rename if // - language version is ES6+ - // - node is synthesized (does not have a parent) + // - 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 || - !node.parent || + nodeIsSynthesized(node) || node.kind !== SyntaxKind.Identifier || (node.parent.kind !== SyntaxKind.VariableDeclaration && node.parent.kind !== SyntaxKind.BindingElement)) { return; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 437894d9cfc..50a8de9671d 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1117,6 +1117,20 @@ module ts { return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength: */newEndN - oldStartN); } + // @internal + export function nodeIsSynthesized(node: Node): boolean { + return node.pos === -1 && node.end === -1; + } + + // @internal + export function createSynthesizedNode(kind: SyntaxKind): Node { + var node = createNode(kind); + node.pos = -1; + node.end = -1; + + return node; + } + // @internal export function generateUniqueName(baseName: string, isExistingName: (name: string) => boolean): string { // First try '_name' From 4ff22a0886f3cecc17b10e0c0f1b0ad2259e4da4 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 26 Feb 2015 11:58:40 -0800 Subject: [PATCH 41/96] added SyntaxKind.ModuleDeclaration to list of block scope containers --- src/compiler/checker.ts | 6 +----- src/compiler/emitter.ts | 13 ++++++------- src/compiler/utilities.ts | 5 +++++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9dabafb0cde..6888a6fc25d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5086,10 +5086,6 @@ module ts { return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); } - function isNameScopeBoundary(n: Node): boolean { - return isAnyFunction(n) || n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.SourceFile; - } - function checkBlockScopedBindingCapturedInLoop(node: Identifier, symbol: Symbol): void { if (languageVersion >= ScriptTarget.ES6 || (symbol.flags & SymbolFlags.BlockScopedVariable) === 0) { return; @@ -5116,7 +5112,7 @@ module ts { } var current: Node = container; - while (current && !isNameScopeBoundary(current)) { + while (current && !nodeStartsNewLexicalEnvironment(current)) { if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { if (inFunction) { grammarErrorOnFirstToken(current, Diagnostics.Code_in_the_loop_captures_block_scoped_variable_0_in_closure_This_is_natively_supported_in_ECMAScript_6_or_higher, declarationNameToString(node)); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index fbe341ccd28..1cfbbd20096 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3832,21 +3832,20 @@ module ts { 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: - case SyntaxKind.SwitchKeyword: return current; case SyntaxKind.Block: - if (isAnyFunction(current.parent)) { - return current.parent; - } - else { + // function block is not considered block-scope container + // see comment in binder.ts: bind(...), case for SyntaxKind.Block + if (!isAnyFunction(current.parent)) { return current; } - case SyntaxKind.SourceFile: - return current; } current = current.parent; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 50a8de9671d..bf8a9dd1097 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1117,6 +1117,11 @@ 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; + } + // @internal export function nodeIsSynthesized(node: Node): boolean { return node.pos === -1 && node.end === -1; From 21fb559b534e9c7c32a83693d3323ae18a7a5276 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 26 Feb 2015 12:22:01 -0800 Subject: [PATCH 42/96] Make the vsDevMode script more explicit and support lib file override --- scripts/VSDevMode.ps1 | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/scripts/VSDevMode.ps1 b/scripts/VSDevMode.ps1 index 21cc1f48ac1..df34c9e7787 100644 --- a/scripts/VSDevMode.ps1 +++ b/scripts/VSDevMode.ps1 @@ -37,12 +37,38 @@ if(!(Test-Path $tsRegKey)){ } if($tsScript -ne ""){ - if(!(Test-Path $tsScript)){ - Throw "Could not locate the TypeScript language service script at ${tsScript}" + $tsScriptServices = "${tsScript}\typescriptServices.js" + $tsScriptlib = "${tsScript}\lib.d.ts" + $tsES6Scriptlib = "${tsScript}\lib.es6.d.ts" + + if(!(Test-Path $tsScriptServices)){ + Throw "Could not locate the TypeScript language service script at ${tsScriptServices}" + } + else { + $path = resolve-path ${tsScriptServices} + Set-ItemProperty -path $tsRegKey -name CustomTypeScriptServicesFileLocation -value "${path}" + Write-Host "Enabled custom TypeScript language service at ${path} for Dev${vsVersion}" + } + + if(!(Test-Path $tsScriptlib)){ + Throw "Could not locate the TypeScript default library at ${tsScriptlib}" + } + else { + $path = resolve-path ${tsScriptlib} + Set-ItemProperty -path $tsRegKey -name CustomDefaultLibraryLocation -value "${path}" + Write-Host "Enabled custom TypeScript default library at ${path} for Dev${vsVersion}" + } + + if(!(Test-Path $tsES6Scriptlib)){ + Throw "Could not locate the TypeScript default ES6 library at ${tsES6Scriptlib}" + } + else { + $path = resolve-path ${tsES6Scriptlib} + Set-ItemProperty -path $tsRegKey -name CustomDefaultES6LibraryLocation -value "${path}" + Write-Host "Enabled custom TypeScript default ES6 library at ${path} for Dev${vsVersion}" } - Set-ItemProperty -path $tsRegKey -name CustomTypeScriptServicesFileLocation -value "${tsScript}" - Write-Host "Enabled custom TypeScript language service at ${tsScript} for Dev${vsVersion}" } + if($enableDevMode){ Set-ItemProperty -path $tsRegKey -name EnableDevMode -value 1 Write-Host "Enabled developer mode for Dev${vsVersion}" From 0be645943ae46254fc06fd30b3646f21dc35b30d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 26 Feb 2015 14:51:04 -0800 Subject: [PATCH 43/96] Print times in a manner more consistent with the 1.3 compiler. This allows us to more accurately compare and constrast times between that compiler and the current one. --- src/compiler/program.ts | 3 +++ src/compiler/tsc.ts | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a8e5b0b3a74..88ab2825fd2 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3,6 +3,7 @@ module ts { /* @internal */ export var emitTime = 0; + /* @internal */ export var ioReadTime = 0; export function createCompilerHost(options: CompilerOptions): CompilerHost { var currentDirectory: string; @@ -19,7 +20,9 @@ module ts { function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile { try { + var start = new Date().getTime(); var text = sys.readFile(fileName, options.charset); + ioReadTime += new Date().getTime() - start; } catch (e) { if (onError) { diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index a3755650aed..57c2298d3d3 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -322,6 +322,7 @@ module ts { } function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) { + ts.ioReadTime = 0; ts.parseTime = 0; ts.bindTime = 0; ts.checkTime = 0; @@ -330,9 +331,12 @@ module ts { var start = new Date().getTime(); var program = createProgram(fileNames, compilerOptions, compilerHost); + var programTime = new Date().getTime() - start; + var exitStatus = compileProgram(); var end = new Date().getTime() - start; + var compileTime = end - programTime; if (compilerOptions.listFiles) { forEach(program.getSourceFiles(), file => { @@ -353,10 +357,19 @@ module ts { reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K"); } - reportTimeStatistic("Parse time", ts.parseTime); + // Individual component times. + // Note: we output 'programTime' as parseTime to match the tsc 1.3 behavior. tsc 1.3 + // measured parse time along with read IO as a single counter. We preserve that + // behavior so we can accurately compare times. For actual parse times (in isolation) + // is reported below. + reportTimeStatistic("Parse time", programTime); reportTimeStatistic("Bind time", ts.bindTime); reportTimeStatistic("Check time", ts.checkTime); reportTimeStatistic("Emit time", ts.emitTime); + + reportTimeStatistic("Parse time w/o IO", ts.parseTime); + reportTimeStatistic("IO read", ts.ioReadTime); + reportTimeStatistic("Compile time", compileTime); reportTimeStatistic("Total time", end); } From 71c3bccef4d6492ee3bdcd170d551376fcb5ef42 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 26 Feb 2015 15:35:17 -0800 Subject: [PATCH 44/96] Produce better wrapping for object literal emit with computed property names. --- src/compiler/emitter.ts | 33 +++- .../baselines/reference/ES5SymbolProperty1.js | 4 +- .../reference/FunctionDeclaration8_es6.js | 4 +- .../reference/FunctionDeclaration9_es6.js | 4 +- .../FunctionPropertyAssignments5_es6.js | 3 +- .../reference/computedPropertyNames10_ES5.js | 13 +- .../reference/computedPropertyNames11_ES5.js | 13 +- .../reference/computedPropertyNames18_ES5.js | 4 +- .../reference/computedPropertyNames19_ES5.js | 4 +- .../reference/computedPropertyNames1_ES5.js | 4 +- .../reference/computedPropertyNames20_ES5.js | 4 +- .../reference/computedPropertyNames22_ES5.js | 3 +- .../reference/computedPropertyNames23_ES5.js | 4 +- .../reference/computedPropertyNames25_ES5.js | 3 +- .../reference/computedPropertyNames26_ES5.js | 4 +- .../reference/computedPropertyNames28_ES5.js | 3 +- .../reference/computedPropertyNames29_ES5.js | 3 +- .../reference/computedPropertyNames30_ES5.js | 3 +- .../reference/computedPropertyNames31_ES5.js | 3 +- .../reference/computedPropertyNames33_ES5.js | 3 +- .../reference/computedPropertyNames34_ES5.js | 3 +- .../reference/computedPropertyNames46_ES5.js | 4 +- .../reference/computedPropertyNames47_ES5.js | 4 +- .../reference/computedPropertyNames48_ES5.js | 12 +- .../reference/computedPropertyNames49_ES5.js | 30 ++-- .../reference/computedPropertyNames4_ES5.js | 24 +-- .../reference/computedPropertyNames50_ES5.js | 30 ++-- .../reference/computedPropertyNames5_ES5.js | 14 +- .../reference/computedPropertyNames6_ES5.js | 8 +- .../reference/computedPropertyNames7_ES5.js | 4 +- .../reference/computedPropertyNames8_ES5.js | 6 +- .../reference/computedPropertyNames9_ES5.js | 8 +- ...mputedPropertyNamesContextualType10_ES5.js | 6 +- ...omputedPropertyNamesContextualType1_ES5.js | 5 +- ...omputedPropertyNamesContextualType2_ES5.js | 5 +- ...omputedPropertyNamesContextualType3_ES5.js | 5 +- ...omputedPropertyNamesContextualType4_ES5.js | 6 +- ...omputedPropertyNamesContextualType5_ES5.js | 6 +- ...omputedPropertyNamesContextualType6_ES5.js | 12 +- ...omputedPropertyNamesContextualType7_ES5.js | 12 +- ...omputedPropertyNamesContextualType8_ES5.js | 6 +- ...omputedPropertyNamesContextualType9_ES5.js | 6 +- ...mputedPropertyNamesDeclarationEmit5_ES5.js | 7 +- .../computedPropertyNamesSourceMap2_ES5.js | 7 +- ...computedPropertyNamesSourceMap2_ES5.js.map | 2 +- ...dPropertyNamesSourceMap2_ES5.sourcemap.txt | 168 +++++++++--------- .../parserES5ComputedPropertyName2.js | 4 +- .../parserES5ComputedPropertyName3.js | 3 +- .../parserES5ComputedPropertyName4.js | 3 +- tests/baselines/reference/privateIndexer2.js | 6 +- 50 files changed, 299 insertions(+), 236 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index e57255a776b..0ded941b54c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1523,6 +1523,10 @@ 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 { @@ -2622,14 +2626,19 @@ module ts { } } - function createSynthesizedNode(kind: SyntaxKind): Node { - var node = createNode(kind); + function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node { + var node = createNode(kind); node.pos = -1; node.end = -1; + node.startsOnNewLine = startsOnNewLine; return node; } + function isSynthesized(node: Node) { + return node.pos === -1 && node.end === -1; + } + function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number): void { var parenthesizedObjectLiteral = createDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex); return emit(parenthesizedObjectLiteral); @@ -2663,7 +2672,7 @@ module ts { }); // Finally, return the temp variable. - propertyPatches = createBinaryExpression(propertyPatches, SyntaxKind.CommaToken, tempVar); + propertyPatches = createBinaryExpression(propertyPatches, SyntaxKind.CommaToken, createIdentifier(tempVar.text, /*startsOnNewLine:*/ true)); var result = createParenthesizedExpression(propertyPatches); @@ -2686,7 +2695,7 @@ module ts { var leftHandSide = createMemberAccessForPropertyName(tempVar, property.name); var maybeRightHandSide = tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral, property); - return maybeRightHandSide && createBinaryExpression(leftHandSide, SyntaxKind.EqualsToken, maybeRightHandSide); + return maybeRightHandSide && createBinaryExpression(leftHandSide, SyntaxKind.EqualsToken, maybeRightHandSide, /*startsOnNewLine:*/ true); } function tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral: ObjectLiteralExpression, property: ObjectLiteralElement) { @@ -2759,8 +2768,8 @@ module ts { return result; } - function createBinaryExpression(left: Expression, operator: SyntaxKind, right: Expression): BinaryExpression { - var result = createSynthesizedNode(SyntaxKind.BinaryExpression); + function createBinaryExpression(left: Expression, operator: SyntaxKind, right: Expression, startsOnNewLine?: boolean): BinaryExpression { + var result = createSynthesizedNode(SyntaxKind.BinaryExpression, startsOnNewLine); result.operatorToken = createSynthesizedNode(operator); result.left = left; result.right = right; @@ -2815,8 +2824,8 @@ module ts { return result; } - function createIdentifier(name: string) { - var result = createSynthesizedNode(SyntaxKind.Identifier); + function createIdentifier(name: string, startsOnNewLine?: boolean) { + var result = createSynthesizedNode(SyntaxKind.Identifier, startsOnNewLine); result.text = name; return result; @@ -3160,9 +3169,11 @@ module ts { write(tokenToString(node.operatorToken.kind)); + var shouldPlaceOnNewLine = !isSynthesized(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. - if (!nodeEndIsOnSameLineAsNodeStart(node.operatorToken, node.right)) { + if (shouldPlaceOnNewLine || synthesizedNodeStartsOnNewLine(node.right)) { increaseIndent(); writeLine(); emit(node.right); @@ -3175,6 +3186,10 @@ module ts { } } + function synthesizedNodeStartsOnNewLine(node: Node) { + return isSynthesized(node) && (node).startsOnNewLine; + } + function emitConditionalExpression(node: ConditionalExpression) { emit(node.condition); write(" ? "); diff --git a/tests/baselines/reference/ES5SymbolProperty1.js b/tests/baselines/reference/ES5SymbolProperty1.js index 7d29658e286..ab3f420c95c 100644 --- a/tests/baselines/reference/ES5SymbolProperty1.js +++ b/tests/baselines/reference/ES5SymbolProperty1.js @@ -12,8 +12,8 @@ obj[Symbol.foo]; //// [ES5SymbolProperty1.js] var Symbol; -var obj = (_a = {}, _a[Symbol.foo] = - 0, +var obj = (_a = {}, + _a[Symbol.foo] = 0, _a); obj[Symbol.foo]; var _a; diff --git a/tests/baselines/reference/FunctionDeclaration8_es6.js b/tests/baselines/reference/FunctionDeclaration8_es6.js index acb336b6418..62692997a91 100644 --- a/tests/baselines/reference/FunctionDeclaration8_es6.js +++ b/tests/baselines/reference/FunctionDeclaration8_es6.js @@ -2,7 +2,7 @@ var v = { [yield]: foo } //// [FunctionDeclaration8_es6.js] -var v = (_a = {}, _a[yield] = - foo, +var v = (_a = {}, + _a[yield] = foo, _a); var _a; diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.js b/tests/baselines/reference/FunctionDeclaration9_es6.js index 9ecc0eb6d65..c63cf5bb458 100644 --- a/tests/baselines/reference/FunctionDeclaration9_es6.js +++ b/tests/baselines/reference/FunctionDeclaration9_es6.js @@ -5,8 +5,8 @@ function * foo() { //// [FunctionDeclaration9_es6.js] function foo() { - var v = (_a = {}, _a[] = - foo, + var v = (_a = {}, + _a[] = foo, _a); var _a; } diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.js b/tests/baselines/reference/FunctionPropertyAssignments5_es6.js index 6a20d4aff03..51e5d0000e4 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments5_es6.js +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.js @@ -2,6 +2,7 @@ var v = { *[foo()]() { } } //// [FunctionPropertyAssignments5_es6.js] -var v = (_a = {}, _a[foo()] = function () { }, +var v = (_a = {}, + _a[foo()] = function () { }, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames10_ES5.js b/tests/baselines/reference/computedPropertyNames10_ES5.js index 00b43fb551d..302f9355be8 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES5.js +++ b/tests/baselines/reference/computedPropertyNames10_ES5.js @@ -20,6 +20,17 @@ var v = { var s; var n; var a; -var v = (_a = {}, _a[s] = function () { }, _a[n] = function () { }, _a[s + s] = function () { }, _a[s + n] = function () { }, _a[+s] = function () { }, _a[""] = function () { }, _a[0] = function () { }, _a[a] = function () { }, _a[true] = function () { }, _a["hello bye"] = function () { }, _a["hello " + a + " bye"] = function () { }, +var v = (_a = {}, + _a[s] = function () { }, + _a[n] = function () { }, + _a[s + s] = function () { }, + _a[s + n] = function () { }, + _a[+s] = function () { }, + _a[""] = function () { }, + _a[0] = function () { }, + _a[a] = function () { }, + _a[true] = function () { }, + _a["hello bye"] = function () { }, + _a["hello " + a + " bye"] = function () { }, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames11_ES5.js b/tests/baselines/reference/computedPropertyNames11_ES5.js index db3b12cbf32..69902003342 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES5.js +++ b/tests/baselines/reference/computedPropertyNames11_ES5.js @@ -20,6 +20,17 @@ var v = { var s; var n; var a; -var v = (_a = {}, _a[s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[s + s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[s + n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[+s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[""] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[0] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[a] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[true] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a["hello bye"] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a["hello " + a + " bye"] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), +var v = (_a = {}, + _a[s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), + _a[n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), + _a[s + s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), + _a[s + n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), + _a[+s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), + _a[""] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), + _a[0] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), + _a[a] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), + _a[true] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), + _a["hello bye"] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), + _a["hello " + a + " bye"] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames18_ES5.js b/tests/baselines/reference/computedPropertyNames18_ES5.js index 47950473370..a62af506531 100644 --- a/tests/baselines/reference/computedPropertyNames18_ES5.js +++ b/tests/baselines/reference/computedPropertyNames18_ES5.js @@ -7,8 +7,8 @@ function foo() { //// [computedPropertyNames18_ES5.js] function foo() { - var obj = (_a = {}, _a[this.bar] = - 0, + var obj = (_a = {}, + _a[this.bar] = 0, _a); var _a; } diff --git a/tests/baselines/reference/computedPropertyNames19_ES5.js b/tests/baselines/reference/computedPropertyNames19_ES5.js index fcc46aeff2f..bda3e01bbed 100644 --- a/tests/baselines/reference/computedPropertyNames19_ES5.js +++ b/tests/baselines/reference/computedPropertyNames19_ES5.js @@ -8,8 +8,8 @@ module M { //// [computedPropertyNames19_ES5.js] var M; (function (M) { - var obj = (_a = {}, _a[this.bar] = - 0, + var obj = (_a = {}, + _a[this.bar] = 0, _a); var _a; })(M || (M = {})); diff --git a/tests/baselines/reference/computedPropertyNames1_ES5.js b/tests/baselines/reference/computedPropertyNames1_ES5.js index 115daa53ace..37e06616c2f 100644 --- a/tests/baselines/reference/computedPropertyNames1_ES5.js +++ b/tests/baselines/reference/computedPropertyNames1_ES5.js @@ -5,6 +5,8 @@ var v = { } //// [computedPropertyNames1_ES5.js] -var v = (_a = {}, _a[0 + 1] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[0 + 1] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), +var v = (_a = {}, + _a[0 + 1] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), + _a[0 + 1] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames20_ES5.js b/tests/baselines/reference/computedPropertyNames20_ES5.js index 06a08c6b730..1eec0a7bcdb 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES5.js +++ b/tests/baselines/reference/computedPropertyNames20_ES5.js @@ -4,7 +4,7 @@ var obj = { } //// [computedPropertyNames20_ES5.js] -var obj = (_a = {}, _a[this.bar] = - 0, +var obj = (_a = {}, + _a[this.bar] = 0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames22_ES5.js b/tests/baselines/reference/computedPropertyNames22_ES5.js index 12ec32d7e93..df12193250b 100644 --- a/tests/baselines/reference/computedPropertyNames22_ES5.js +++ b/tests/baselines/reference/computedPropertyNames22_ES5.js @@ -13,7 +13,8 @@ var C = (function () { function C() { } C.prototype.bar = function () { - var obj = (_a = {}, _a[this.bar()] = function () { }, + var obj = (_a = {}, + _a[this.bar()] = function () { }, _a); return 0; var _a; diff --git a/tests/baselines/reference/computedPropertyNames23_ES5.js b/tests/baselines/reference/computedPropertyNames23_ES5.js index f0eebd119e8..9e02999738c 100644 --- a/tests/baselines/reference/computedPropertyNames23_ES5.js +++ b/tests/baselines/reference/computedPropertyNames23_ES5.js @@ -15,8 +15,8 @@ var C = (function () { C.prototype.bar = function () { return 0; }; - C.prototype[(_a = {}, _a[this.bar()] = - 1, + C.prototype[(_a = {}, + _a[this.bar()] = 1, _a)[0]] = function () { }; return C; })(); diff --git a/tests/baselines/reference/computedPropertyNames25_ES5.js b/tests/baselines/reference/computedPropertyNames25_ES5.js index 07673dded76..f8196dd1307 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES5.js +++ b/tests/baselines/reference/computedPropertyNames25_ES5.js @@ -34,7 +34,8 @@ var C = (function (_super) { _super.apply(this, arguments); } C.prototype.foo = function () { - var obj = (_a = {}, _a[_super.prototype.bar.call(this)] = function () { }, + var obj = (_a = {}, + _a[_super.prototype.bar.call(this)] = function () { }, _a); return 0; var _a; diff --git a/tests/baselines/reference/computedPropertyNames26_ES5.js b/tests/baselines/reference/computedPropertyNames26_ES5.js index 50a14294c53..037bd8786e6 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES5.js +++ b/tests/baselines/reference/computedPropertyNames26_ES5.js @@ -34,8 +34,8 @@ var C = (function (_super) { } // Gets emitted as super, not _super, which is consistent with // use of super in static properties initializers. - C.prototype[(_a = {}, _a[super.bar.call(this)] = - 1, + C.prototype[(_a = {}, + _a[super.bar.call(this)] = 1, _a)[0]] = function () { }; return C; })(Base); diff --git a/tests/baselines/reference/computedPropertyNames28_ES5.js b/tests/baselines/reference/computedPropertyNames28_ES5.js index 0ee4c6fcb39..b88cb0dfaf9 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES5.js +++ b/tests/baselines/reference/computedPropertyNames28_ES5.js @@ -26,7 +26,8 @@ var C = (function (_super) { __extends(C, _super); function C() { _super.call(this); - var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { }, + var obj = (_a = {}, + _a[(_super.call(this), "prop")] = function () { }, _a); var _a; } diff --git a/tests/baselines/reference/computedPropertyNames29_ES5.js b/tests/baselines/reference/computedPropertyNames29_ES5.js index 6c571ffc48d..022c930ab67 100644 --- a/tests/baselines/reference/computedPropertyNames29_ES5.js +++ b/tests/baselines/reference/computedPropertyNames29_ES5.js @@ -17,7 +17,8 @@ var C = (function () { C.prototype.bar = function () { var _this = this; (function () { - var obj = (_a = {}, _a[_this.bar()] = function () { }, + var obj = (_a = {}, + _a[_this.bar()] = function () { }, _a); var _a; }); diff --git a/tests/baselines/reference/computedPropertyNames30_ES5.js b/tests/baselines/reference/computedPropertyNames30_ES5.js index be54ac9f390..fd63a192d07 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES5.js +++ b/tests/baselines/reference/computedPropertyNames30_ES5.js @@ -32,7 +32,8 @@ var C = (function (_super) { function C() { _super.call(this); (function () { - var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { }, + var obj = (_a = {}, + _a[(_super.call(this), "prop")] = function () { }, _a); var _a; }); diff --git a/tests/baselines/reference/computedPropertyNames31_ES5.js b/tests/baselines/reference/computedPropertyNames31_ES5.js index c195af3eb5a..8a3c1a3f6c5 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES5.js +++ b/tests/baselines/reference/computedPropertyNames31_ES5.js @@ -38,7 +38,8 @@ var C = (function (_super) { C.prototype.foo = function () { var _this = this; (function () { - var obj = (_a = {}, _a[_super.prototype.bar.call(_this)] = function () { }, + var obj = (_a = {}, + _a[_super.prototype.bar.call(_this)] = function () { }, _a); var _a; }); diff --git a/tests/baselines/reference/computedPropertyNames33_ES5.js b/tests/baselines/reference/computedPropertyNames33_ES5.js index 805531eb6b3..3d7c70a9256 100644 --- a/tests/baselines/reference/computedPropertyNames33_ES5.js +++ b/tests/baselines/reference/computedPropertyNames33_ES5.js @@ -15,7 +15,8 @@ var C = (function () { function C() { } C.prototype.bar = function () { - var obj = (_a = {}, _a[foo()] = function () { }, + var obj = (_a = {}, + _a[foo()] = function () { }, _a); return 0; var _a; diff --git a/tests/baselines/reference/computedPropertyNames34_ES5.js b/tests/baselines/reference/computedPropertyNames34_ES5.js index 8e5fbe96f67..fd46b144fa5 100644 --- a/tests/baselines/reference/computedPropertyNames34_ES5.js +++ b/tests/baselines/reference/computedPropertyNames34_ES5.js @@ -15,7 +15,8 @@ var C = (function () { function C() { } C.bar = function () { - var obj = (_a = {}, _a[foo()] = function () { }, + var obj = (_a = {}, + _a[foo()] = function () { }, _a); return 0; var _a; diff --git a/tests/baselines/reference/computedPropertyNames46_ES5.js b/tests/baselines/reference/computedPropertyNames46_ES5.js index 0cd5bd9beab..815f5769f3b 100644 --- a/tests/baselines/reference/computedPropertyNames46_ES5.js +++ b/tests/baselines/reference/computedPropertyNames46_ES5.js @@ -4,7 +4,7 @@ var o = { }; //// [computedPropertyNames46_ES5.js] -var o = (_a = {}, _a["" || 0] = - 0, +var o = (_a = {}, + _a["" || 0] = 0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames47_ES5.js b/tests/baselines/reference/computedPropertyNames47_ES5.js index 2ec3fa5d668..7d839e16ffb 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES5.js +++ b/tests/baselines/reference/computedPropertyNames47_ES5.js @@ -14,7 +14,7 @@ var E2; (function (E2) { E2[E2["x"] = 0] = "x"; })(E2 || (E2 = {})); -var o = (_a = {}, _a[0 /* x */ || 0 /* x */] = - 0, +var o = (_a = {}, + _a[0 /* x */ || 0 /* x */] = 0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames48_ES5.js b/tests/baselines/reference/computedPropertyNames48_ES5.js index 4a397507680..c5ca0d5b241 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES5.js +++ b/tests/baselines/reference/computedPropertyNames48_ES5.js @@ -23,13 +23,13 @@ var E; E[E["x"] = 0] = "x"; })(E || (E = {})); var a; -extractIndexer((_a = {}, _a[a] = - "", +extractIndexer((_a = {}, + _a[a] = "", _a)); // Should return string -extractIndexer((_b = {}, _b[0 /* x */] = - "", +extractIndexer((_b = {}, + _b[0 /* x */] = "", _b)); // Should return string -extractIndexer((_c = {}, _c["" || 0] = - "", +extractIndexer((_c = {}, + _c["" || 0] = "", _c)); // Should return any (widened form of undefined) var _a, _b, _c; diff --git a/tests/baselines/reference/computedPropertyNames49_ES5.js b/tests/baselines/reference/computedPropertyNames49_ES5.js index 79c09624f4f..5f952c6f3f1 100644 --- a/tests/baselines/reference/computedPropertyNames49_ES5.js +++ b/tests/baselines/reference/computedPropertyNames49_ES5.js @@ -28,19 +28,23 @@ var x = { //// [computedPropertyNames49_ES5.js] var x = (_a = { p1: 10 -}, _a.p1 = - 10, _a[1 + 1] = Object.defineProperty({ get: function () { - throw 10; - }, enumerable: true, configurable: true }), _a[1 + 1] = Object.defineProperty({ get: function () { - return 10; - }, enumerable: true, configurable: true }), _a[1 + 1] = Object.defineProperty({ set: function () { - // just throw - throw 10; - }, enumerable: true, configurable: true }), _a.foo = Object.defineProperty({ get: function () { - if (1 == 1) { +}, + _a.p1 = 10, + _a[1 + 1] = Object.defineProperty({ get: function () { + throw 10; + }, enumerable: true, configurable: true }), + _a[1 + 1] = Object.defineProperty({ get: function () { return 10; - } - }, enumerable: true, configurable: true }), _a.p2 = - 20, + }, enumerable: true, configurable: true }), + _a[1 + 1] = Object.defineProperty({ set: function () { + // just throw + throw 10; + }, enumerable: true, configurable: true }), + _a.foo = Object.defineProperty({ get: function () { + if (1 == 1) { + return 10; + } + }, enumerable: true, configurable: true }), + _a.p2 = 20, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames4_ES5.js b/tests/baselines/reference/computedPropertyNames4_ES5.js index 22e23f14905..ac0fa8ec937 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES5.js +++ b/tests/baselines/reference/computedPropertyNames4_ES5.js @@ -20,17 +20,17 @@ var v = { var s; var n; var a; -var v = (_a = {}, _a[s] = - 0, _a[n] = - n, _a[s + s] = - 1, _a[s + n] = - 2, _a[+s] = - s, _a[""] = - 0, _a[0] = - 0, _a[a] = - 1, _a[true] = - 0, _a["hello bye"] = - 0, _a["hello " + a + " bye"] = - 0, +var v = (_a = {}, + _a[s] = 0, + _a[n] = n, + _a[s + s] = 1, + _a[s + n] = 2, + _a[+s] = s, + _a[""] = 0, + _a[0] = 0, + _a[a] = 1, + _a[true] = 0, + _a["hello bye"] = 0, + _a["hello " + a + " bye"] = 0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames50_ES5.js b/tests/baselines/reference/computedPropertyNames50_ES5.js index 36ca71707cc..32502d80e0a 100644 --- a/tests/baselines/reference/computedPropertyNames50_ES5.js +++ b/tests/baselines/reference/computedPropertyNames50_ES5.js @@ -33,19 +33,23 @@ var x = (_a = { return 10; } } -}, _a.p1 = - 10, _a.foo = Object.defineProperty({ get: function () { - if (1 == 1) { +}, + _a.p1 = 10, + _a.foo = Object.defineProperty({ get: function () { + if (1 == 1) { + return 10; + } + }, enumerable: true, configurable: true }), + _a[1 + 1] = Object.defineProperty({ get: function () { + throw 10; + }, enumerable: true, configurable: true }), + _a[1 + 1] = Object.defineProperty({ set: function () { + // just throw + throw 10; + }, enumerable: true, configurable: true }), + _a[1 + 1] = Object.defineProperty({ get: function () { return 10; - } - }, enumerable: true, configurable: true }), _a[1 + 1] = Object.defineProperty({ get: function () { - throw 10; - }, enumerable: true, configurable: true }), _a[1 + 1] = Object.defineProperty({ set: function () { - // just throw - throw 10; - }, enumerable: true, configurable: true }), _a[1 + 1] = Object.defineProperty({ get: function () { - return 10; - }, enumerable: true, configurable: true }), _a.p2 = - 20, + }, enumerable: true, configurable: true }), + _a.p2 = 20, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames5_ES5.js b/tests/baselines/reference/computedPropertyNames5_ES5.js index e99c4ed73b7..3367faa2c20 100644 --- a/tests/baselines/reference/computedPropertyNames5_ES5.js +++ b/tests/baselines/reference/computedPropertyNames5_ES5.js @@ -11,12 +11,12 @@ var v = { //// [computedPropertyNames5_ES5.js] var b; -var v = (_a = {}, _a[b] = - 0, _a[true] = - 1, _a[[]] = - 0, _a[{}] = - 0, _a[undefined] = - undefined, _a[null] = - null, +var v = (_a = {}, + _a[b] = 0, + _a[true] = 1, + _a[[]] = 0, + _a[{}] = 0, + _a[undefined] = undefined, + _a[null] = null, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames6_ES5.js b/tests/baselines/reference/computedPropertyNames6_ES5.js index a4b9f2131e2..29d035bfcbf 100644 --- a/tests/baselines/reference/computedPropertyNames6_ES5.js +++ b/tests/baselines/reference/computedPropertyNames6_ES5.js @@ -12,9 +12,9 @@ var v = { var p1; var p2; var p3; -var v = (_a = {}, _a[p1] = - 0, _a[p2] = - 1, _a[p3] = - 2, +var v = (_a = {}, + _a[p1] = 0, + _a[p2] = 1, + _a[p3] = 2, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames7_ES5.js b/tests/baselines/reference/computedPropertyNames7_ES5.js index bd19f0cc5e4..9c23dcab20d 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES5.js +++ b/tests/baselines/reference/computedPropertyNames7_ES5.js @@ -11,7 +11,7 @@ var E; (function (E) { E[E["member"] = 0] = "member"; })(E || (E = {})); -var v = (_a = {}, _a[0 /* member */] = - 0, +var v = (_a = {}, + _a[0 /* member */] = 0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames8_ES5.js b/tests/baselines/reference/computedPropertyNames8_ES5.js index 9035777bcba..82d262c7e4e 100644 --- a/tests/baselines/reference/computedPropertyNames8_ES5.js +++ b/tests/baselines/reference/computedPropertyNames8_ES5.js @@ -12,9 +12,9 @@ function f() { function f() { var t; var u; - var v = (_a = {}, _a[t] = - 0, _a[u] = - 1, + var v = (_a = {}, + _a[t] = 0, + _a[u] = 1, _a); var _a; } diff --git a/tests/baselines/reference/computedPropertyNames9_ES5.js b/tests/baselines/reference/computedPropertyNames9_ES5.js index 1c5198da767..b1ac6c9e3b6 100644 --- a/tests/baselines/reference/computedPropertyNames9_ES5.js +++ b/tests/baselines/reference/computedPropertyNames9_ES5.js @@ -12,9 +12,9 @@ var v = { //// [computedPropertyNames9_ES5.js] function f(x) { } -var v = (_a = {}, _a[f("")] = - 0, _a[f(0)] = - 0, _a[f(true)] = - 0, +var v = (_a = {}, + _a[f("")] = 0, + _a[f(0)] = 0, + _a[f(true)] = 0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js index c29260da041..d8a33951d4a 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js @@ -9,8 +9,8 @@ var o: I = { } //// [computedPropertyNamesContextualType10_ES5.js] -var o = (_a = {}, _a[+"foo"] = - "", _a[+"bar"] = - 0, +var o = (_a = {}, + _a[+"foo"] = "", + _a[+"bar"] = 0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js index 60d5706e3f4..1ee88351154 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js @@ -10,7 +10,8 @@ var o: I = { } //// [computedPropertyNamesContextualType1_ES5.js] -var o = (_a = {}, _a["" + 0] = function (y) { return y.length; }, _a["" + 1] = - function (y) { return y.length; }, +var o = (_a = {}, + _a["" + 0] = function (y) { return y.length; }, + _a["" + 1] = function (y) { return y.length; }, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js index aba28acdd24..6be09e4bef3 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js @@ -10,7 +10,8 @@ var o: I = { } //// [computedPropertyNamesContextualType2_ES5.js] -var o = (_a = {}, _a[+"foo"] = function (y) { return y.length; }, _a[+"bar"] = - function (y) { return y.length; }, +var o = (_a = {}, + _a[+"foo"] = function (y) { return y.length; }, + _a[+"bar"] = function (y) { return y.length; }, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js index 6752bf590dc..b510cda2916 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js @@ -9,7 +9,8 @@ var o: I = { } //// [computedPropertyNamesContextualType3_ES5.js] -var o = (_a = {}, _a[+"foo"] = function (y) { return y.length; }, _a[+"bar"] = - function (y) { return y.length; }, +var o = (_a = {}, + _a[+"foo"] = function (y) { return y.length; }, + _a[+"bar"] = function (y) { return y.length; }, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js index 6e9dbab4b53..0c319a526f4 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js @@ -10,8 +10,8 @@ var o: I = { } //// [computedPropertyNamesContextualType4_ES5.js] -var o = (_a = {}, _a["" + "foo"] = - "", _a["" + "bar"] = - 0, +var o = (_a = {}, + _a["" + "foo"] = "", + _a["" + "bar"] = 0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js index 1d7d456195e..51d78be59d4 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js @@ -10,8 +10,8 @@ var o: I = { } //// [computedPropertyNamesContextualType5_ES5.js] -var o = (_a = {}, _a[+"foo"] = - "", _a[+"bar"] = - 0, +var o = (_a = {}, + _a[+"foo"] = "", + _a[+"bar"] = 0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js index 82229dc92e2..f50231e3f0f 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js @@ -17,11 +17,11 @@ foo({ foo((_a = { p: "", 0: function () { } -}, _a.p = - "", _a[0] = - function () { }, _a["hi" + "bye"] = - true, _a[0 + 1] = - 0, _a[+"hi"] = - [0], +}, + _a.p = "", + _a[0] = function () { }, + _a["hi" + "bye"] = true, + _a[0 + 1] = 0, + _a[+"hi"] = [0], _a)); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js index ca335566d7e..e1c567c62d9 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js @@ -17,11 +17,11 @@ foo({ foo((_a = { p: "", 0: function () { } -}, _a.p = - "", _a[0] = - function () { }, _a["hi" + "bye"] = - true, _a[0 + 1] = - 0, _a[+"hi"] = - [0], +}, + _a.p = "", + _a[0] = function () { }, + _a["hi" + "bye"] = true, + _a[0 + 1] = 0, + _a[+"hi"] = [0], _a)); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js index 89ea38eaa74..24f6218864c 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js @@ -10,8 +10,8 @@ var o: I = { } //// [computedPropertyNamesContextualType8_ES5.js] -var o = (_a = {}, _a["" + "foo"] = - "", _a["" + "bar"] = - 0, +var o = (_a = {}, + _a["" + "foo"] = "", + _a["" + "bar"] = 0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js index b4f94dcadbe..340802da2af 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js @@ -10,8 +10,8 @@ var o: I = { } //// [computedPropertyNamesContextualType9_ES5.js] -var o = (_a = {}, _a[+"foo"] = - "", _a[+"bar"] = - 0, +var o = (_a = {}, + _a[+"foo"] = "", + _a[+"bar"] = 0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js index bb495c0f532..58c3133e6ee 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js @@ -7,8 +7,11 @@ var v = { } //// [computedPropertyNamesDeclarationEmit5_ES5.js] -var v = (_a = {}, _a["" + ""] = - 0, _a["" + ""] = function () { }, _a["" + ""] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a["" + ""] = Object.defineProperty({ set: function (x) { }, enumerable: true, configurable: true }), +var v = (_a = {}, + _a["" + ""] = 0, + _a["" + ""] = function () { }, + _a["" + ""] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), + _a["" + ""] = Object.defineProperty({ set: function (x) { }, enumerable: true, configurable: true }), _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js index 299c5994424..972aaf9b52f 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js @@ -6,9 +6,10 @@ var v = { } //// [computedPropertyNamesSourceMap2_ES5.js] -var v = (_a = {}, _a["hello"] = function () { - debugger; -}, +var v = (_a = {}, + _a["hello"] = function () { + debugger; + }, _a); var _a; //# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map index 2ea24d441ea..c450a844d5a 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map @@ -1,2 +1,2 @@ //// [computedPropertyNamesSourceMap2_ES5.js.map] -{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,AADA,CACA,EAAA,GADA,EAAA,EACA,EAAA,CACK,OAAO,CAFA,GAAA;IAGA,QAAQ,CAAC;AACb,CAAC,AAJA;IACA,EAAA,AADA,CAKA,CAAA;IAJD,EAAA"} \ No newline at end of file +{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,AADA,CACA,EAAA,GADA,EAAA;IACA,EAAA,CACK,OAAO,CAFA,GAAA;QAGA,QAAQ,CAAC;IACb,CAAC,AAJA;IAAA,EAAA,CAKA,CAAA;IAJD,EAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt index bc6d862eb93..8e5b2aac877 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt @@ -8,7 +8,7 @@ sources: computedPropertyNamesSourceMap2_ES5.ts emittedFile:tests/cases/conformance/es6/computedProperties/computedPropertyNamesSourceMap2_ES5.js sourceFile:computedPropertyNamesSourceMap2_ES5.ts ------------------------------------------------------------------- ->>>var v = (_a = {}, _a["hello"] = function () { +>>>var v = (_a = {}, 1 > 2 >^^^^ 3 > ^ @@ -18,12 +18,7 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 7 > ^^ 8 > ^^^ 9 > ^^ -10> ^^ -11> ^^ -12> ^ -13> ^^^^^^^ -14> ^ -15> ^^^ +10> ^^^^^^^^^^^^^^^^-> 1 > 2 >var 3 > v @@ -43,25 +38,6 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 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 > -10> !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column -10> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 15) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 19) Source(1, 1) + SourceIndex(0) nameIndex (-1) -10> -11> !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found -11> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 17) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 21) Source(1, 1) + SourceIndex(0) nameIndex (-1) -11> -12> !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column -12> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 17) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 22) Source(2, 6) + SourceIndex(0) nameIndex (-1) -12> var v = { - > [ -13> !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -13> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 19) Source(1, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 29) Source(2, 13) + SourceIndex(0) nameIndex (-1) -13> "hello" -14> !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -14> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 21) Source(1, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 30) Source(0, NaN) + SourceIndex(0) nameIndex (-1) -14> -15> !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -15> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 22) Source(2, 14) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 33) Source(0, NaN) + SourceIndex(0) nameIndex (-1) -15> 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) @@ -71,89 +47,111 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 7 >Emitted(1, 12) Source(1, 1) + SourceIndex(0) 8 >Emitted(1, 15) Source(0, NaN) + SourceIndex(0) 9 >Emitted(1, 17) Source(0, NaN) + SourceIndex(0) -10>Emitted(1, 19) Source(1, 1) + SourceIndex(0) -11>Emitted(1, 21) Source(1, 1) + SourceIndex(0) -12>Emitted(1, 22) Source(2, 6) + SourceIndex(0) -13>Emitted(1, 29) Source(2, 13) + SourceIndex(0) -14>Emitted(1, 30) Source(0, NaN) + SourceIndex(0) -15>Emitted(1, 33) Source(0, NaN) + SourceIndex(0) --- ->>> debugger; -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(1, 29) Source(2, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 5) Source(3, 9) + SourceIndex(0) nameIndex (-1) -1 > +>>> _a["hello"] = function () { +1->^^^^ +2 > ^^ +3 > ^ +4 > ^^^^^^^ +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-> 2 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found -2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 30) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 13) 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(1, 30) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 14) Source(3, 18) + SourceIndex(0) nameIndex (-1) -3 > ; -1 >Emitted(2, 5) Source(3, 9) + SourceIndex(0) -2 >Emitted(2, 13) Source(3, 17) + SourceIndex(0) -3 >Emitted(2, 14) Source(3, 18) + SourceIndex(0) +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 > +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) +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 > +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 > +1->Emitted(2, 5) Source(1, 1) + SourceIndex(0) +2 >Emitted(2, 7) Source(1, 1) + 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) +6 >Emitted(2, 19) Source(0, NaN) + SourceIndex(0) --- ->>>}, +>>> debugger; +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 > -2 >^ -3 > -4 > ^^^^^^^^-> +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 > 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 > ; +1 >Emitted(3, 9) Source(3, 9) + SourceIndex(0) +2 >Emitted(3, 17) Source(3, 17) + SourceIndex(0) +3 >Emitted(3, 18) Source(3, 18) + SourceIndex(0) +--- +>>> }, +1 >^^^^ +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(1, 33) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 1) Source(4, 5) + SourceIndex(0) nameIndex (-1) +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 > > -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(1, 33) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 2) 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(2, 5) Source(3, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 2) Source(0, NaN) + SourceIndex(0) nameIndex (-1) -3 > -1 >Emitted(3, 1) Source(4, 5) + SourceIndex(0) -2 >Emitted(3, 2) Source(4, 6) + SourceIndex(0) -3 >Emitted(3, 2) Source(0, NaN) + SourceIndex(0) +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 > } +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 > +1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0) +2 >Emitted(4, 6) Source(4, 6) + SourceIndex(0) +3 >Emitted(4, 6) Source(0, NaN) + SourceIndex(0) --- >>> _a); 1->^^^^ 2 > ^^ -3 > -4 > ^ -5 > ^ +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(2, 13) Source(3, 29) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 5) Source(1, 1) + SourceIndex(0) nameIndex (-1) +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-> 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, 14) Source(3, 30) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 7) Source(1, 1) + SourceIndex(0) nameIndex (-1) +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 > 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, 1) Source(4, 17) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 7) Source(0, NaN) + SourceIndex(0) nameIndex (-1) +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 > -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(3, 2) Source(4, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 8) Source(5, 2) + SourceIndex(0) nameIndex (-1) -4 > -5 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found -5 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 2) Source(0, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 9) Source(5, 2) + SourceIndex(0) nameIndex (-1) -5 > -1->Emitted(4, 5) Source(1, 1) + SourceIndex(0) -2 >Emitted(4, 7) Source(1, 1) + SourceIndex(0) -3 >Emitted(4, 7) Source(0, NaN) + SourceIndex(0) -4 >Emitted(4, 8) Source(5, 2) + SourceIndex(0) -5 >Emitted(4, 9) Source(5, 2) + SourceIndex(0) +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 > +1->Emitted(5, 5) Source(0, NaN) + SourceIndex(0) +2 >Emitted(5, 7) Source(0, NaN) + SourceIndex(0) +3 >Emitted(5, 8) Source(5, 2) + SourceIndex(0) +4 >Emitted(5, 9) Source(5, 2) + SourceIndex(0) --- >>>var _a; 1 >^^^^ 2 > ^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -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(3, 2) Source(0, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 5) Source(1, 1) + SourceIndex(0) nameIndex (-1) +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 > -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(4, 5) Source(1, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 7) Source(1, 1) + SourceIndex(0) nameIndex (-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 > -1 >Emitted(5, 5) Source(1, 1) + SourceIndex(0) -2 >Emitted(5, 7) Source(1, 1) + SourceIndex(0) +1 >Emitted(6, 5) Source(1, 1) + SourceIndex(0) +2 >Emitted(6, 7) Source(1, 1) + SourceIndex(0) --- !!!! **** There are more source map entries in the sourceMap's mapping than what was encoded -!!!! **** Remaining decoded string: ,EAAA,AADA,CAKA,CAAA;IAJD,EAAA +!!!! **** Remaining decoded string: ;IAAA,EAAA,CAKA,CAAA;IAJD,EAAA >>>//# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName2.js b/tests/baselines/reference/parserES5ComputedPropertyName2.js index cd5b088d0ec..d8a5bb45fac 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName2.js +++ b/tests/baselines/reference/parserES5ComputedPropertyName2.js @@ -2,7 +2,7 @@ var v = { [e]: 1 }; //// [parserES5ComputedPropertyName2.js] -var v = (_a = {}, _a[e] = - 1, +var v = (_a = {}, + _a[e] = 1, _a); var _a; diff --git a/tests/baselines/reference/parserES5ComputedPropertyName3.js b/tests/baselines/reference/parserES5ComputedPropertyName3.js index 8bfed4e8228..26067467953 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName3.js +++ b/tests/baselines/reference/parserES5ComputedPropertyName3.js @@ -2,6 +2,7 @@ var v = { [e]() { } }; //// [parserES5ComputedPropertyName3.js] -var v = (_a = {}, _a[e] = function () { }, +var v = (_a = {}, + _a[e] = function () { }, _a); var _a; diff --git a/tests/baselines/reference/parserES5ComputedPropertyName4.js b/tests/baselines/reference/parserES5ComputedPropertyName4.js index bb0b389afdf..378624af08b 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName4.js +++ b/tests/baselines/reference/parserES5ComputedPropertyName4.js @@ -2,6 +2,7 @@ var v = { get [e]() { } }; //// [parserES5ComputedPropertyName4.js] -var v = (_a = {}, _a[e] = Object.defineProperty({ get: function () { }, enumerable: true, configurable: true }), +var v = (_a = {}, + _a[e] = Object.defineProperty({ get: function () { }, enumerable: true, configurable: true }), _a); var _a; diff --git a/tests/baselines/reference/privateIndexer2.js b/tests/baselines/reference/privateIndexer2.js index 40b28ce9809..a90e03a5bc2 100644 --- a/tests/baselines/reference/privateIndexer2.js +++ b/tests/baselines/reference/privateIndexer2.js @@ -11,9 +11,9 @@ var y: { //// [privateIndexer2.js] // private indexers not allowed -var x = (_a = {}, _a[x] = - string, _a.string = -, +var x = (_a = {}, + _a[x] = string, + _a.string = , _a); var y; var _a; From 81b658805916e091de27676d46a86634c1dccf01 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 26 Feb 2015 16:11:27 -0800 Subject: [PATCH 45/96] Make isDeclaration return 'true' on FunctionExpressions. --- src/compiler/checker.ts | 6 +++--- src/compiler/utilities.ts | 5 +++-- src/services/services.ts | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d666da91fe0..19a2dae2424 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10190,7 +10190,7 @@ module ts { } function getSymbolOfEntityNameOrPropertyAccessExpression(entityName: EntityName | PropertyAccessExpression): Symbol { - if (isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) { + if (isDeclarationOrCatchVariableName(entityName)) { return getSymbolOfNode(entityName.parent); } @@ -10255,7 +10255,7 @@ module ts { return undefined; } - if (isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { + if (isDeclarationOrCatchVariableName(node)) { // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } @@ -10351,7 +10351,7 @@ module ts { return getTypeOfSymbol(symbol); } - if (isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { + if (isDeclarationOrCatchVariableName(node)) { var symbol = getSymbolInfo(node); return symbol && getTypeOfSymbol(symbol); } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b53c0007248..489e985fb42 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -706,6 +706,7 @@ module ts { case SyntaxKind.ImportSpecifier: case SyntaxKind.NamespaceImport: case SyntaxKind.ExportSpecifier: + case SyntaxKind.FunctionExpression: return true; } return false; @@ -739,7 +740,7 @@ module ts { } // True if the given identifier, string literal, or number literal is the name of a declaration node - export function isDeclarationOrFunctionExpressionOrCatchVariableName(name: Node): boolean { + export function isDeclarationOrCatchVariableName(name: Node): boolean { if (name.kind !== SyntaxKind.Identifier && name.kind !== SyntaxKind.StringLiteral && name.kind !== SyntaxKind.NumericLiteral) { return false; } @@ -751,7 +752,7 @@ module ts { } } - if (isDeclaration(parent) || parent.kind === SyntaxKind.FunctionExpression) { + if (isDeclaration(parent)) { return (parent).name === name; } diff --git a/src/services/services.ts b/src/services/services.ts index 58c1d08110a..5ee623fd3fa 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4756,7 +4756,7 @@ module ts { /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node: Node): boolean { - if (node.kind === SyntaxKind.Identifier && isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { + if (node.kind === SyntaxKind.Identifier && isDeclarationOrCatchVariableName(node)) { return true; } @@ -4918,7 +4918,7 @@ module ts { else if (isInRightSideOfImport(node)) { return getMeaningFromRightHandSideOfImportEquals(node); } - else if (isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { + else if (isDeclarationOrCatchVariableName(node)) { return getMeaningFromDeclaration(node.parent); } else if (isTypeReference(node)) { From 16378e3c1cb72a922b291ebc7f0244ee343779ca Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 26 Feb 2015 16:13:52 -0800 Subject: [PATCH 46/96] do not treat property names in binding elements as block scoped variables --- src/compiler/checker.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6888a6fc25d..fd3d2141dc0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5091,13 +5091,20 @@ module ts { return; } - // - check if binding is used in some function + // - 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 - // var decl -> var decl list -> parent - var container = (symbol.valueDeclaration).parent.parent; + // 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; } @@ -10722,6 +10729,12 @@ module ts { return undefined; } + // ignore property names in object binding patterns + if (n.parent.kind === SyntaxKind.BindingElement && + (n.parent).propertyName === n) { + return undefined; + } + // for names in variable declarations and binding elements try to short circuit and fetch symbol from the node var declarationSymbol: Symbol = (n.parent.kind === SyntaxKind.VariableDeclaration && (n.parent).name === n) || From 7d6c0f0893d76f11c6d68bd92f500355eaf89f83 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 26 Feb 2015 16:16:20 -0800 Subject: [PATCH 47/96] Add ArrowFunction and sort cases. --- src/compiler/utilities.ts | 41 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 489e985fb42..a6923e1eb94 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -681,32 +681,33 @@ module ts { export function isDeclaration(node: Node): boolean { switch (node.kind) { - case SyntaxKind.TypeParameter: - case SyntaxKind.Parameter: - case SyntaxKind.VariableDeclaration: + case SyntaxKind.ArrowFunction: case SyntaxKind.BindingElement: - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.PropertyAssignment: - case SyntaxKind.ShorthandPropertyAssignment: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.Constructor: + case SyntaxKind.EnumDeclaration: case SyntaxKind.EnumMember: + case SyntaxKind.ExportSpecifier: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.GetAccessor: + case SyntaxKind.ImportClause: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ImportSpecifier: + case SyntaxKind.InterfaceDeclaration: case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.Constructor: - case SyntaxKind.ClassDeclaration: - case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.TypeAliasDeclaration: - case SyntaxKind.EnumDeclaration: case SyntaxKind.ModuleDeclaration: - case SyntaxKind.ImportEqualsDeclaration: - case SyntaxKind.ImportClause: - case SyntaxKind.ImportSpecifier: case SyntaxKind.NamespaceImport: - case SyntaxKind.ExportSpecifier: - case SyntaxKind.FunctionExpression: + case SyntaxKind.Parameter: + case SyntaxKind.PropertyAssignment: + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.SetAccessor: + case SyntaxKind.ShorthandPropertyAssignment: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.TypeParameter: + case SyntaxKind.VariableDeclaration: return true; } return false; From 904d116f9ad5a4b8f88c682cbd105a76d0f86afd Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 26 Feb 2015 16:53:25 -0800 Subject: [PATCH 48/96] added tests --- .../baselines/reference/ES5SymbolProperty1.js | 3 +- .../reference/FunctionDeclaration8_es6.js | 3 +- .../reference/FunctionDeclaration9_es6.js | 3 +- .../FunctionPropertyAssignments5_es6.js | 3 +- .../reference/computedPropertyNames10_ES5.js | 3 +- .../reference/computedPropertyNames11_ES5.js | 3 +- .../reference/computedPropertyNames18_ES5.js | 3 +- .../reference/computedPropertyNames19_ES5.js | 3 +- .../reference/computedPropertyNames1_ES5.js | 3 +- .../reference/computedPropertyNames20_ES5.js | 3 +- .../reference/computedPropertyNames22_ES5.js | 3 +- .../reference/computedPropertyNames23_ES5.js | 3 +- .../reference/computedPropertyNames25_ES5.js | 3 +- .../reference/computedPropertyNames26_ES5.js | 3 +- .../reference/computedPropertyNames28_ES5.js | 3 +- .../reference/computedPropertyNames29_ES5.js | 3 +- .../reference/computedPropertyNames30_ES5.js | 3 +- .../reference/computedPropertyNames31_ES5.js | 3 +- .../reference/computedPropertyNames33_ES5.js | 3 +- .../reference/computedPropertyNames34_ES5.js | 3 +- .../reference/computedPropertyNames46_ES5.js | 3 +- .../reference/computedPropertyNames47_ES5.js | 3 +- .../reference/computedPropertyNames48_ES5.js | 9 +- .../reference/computedPropertyNames49_ES5.js | 3 +- .../reference/computedPropertyNames4_ES5.js | 3 +- .../reference/computedPropertyNames50_ES5.js | 3 +- .../reference/computedPropertyNames5_ES5.js | 3 +- .../reference/computedPropertyNames6_ES5.js | 3 +- .../reference/computedPropertyNames7_ES5.js | 3 +- .../reference/computedPropertyNames8_ES5.js | 3 +- .../reference/computedPropertyNames9_ES5.js | 3 +- ...mputedPropertyNamesContextualType10_ES5.js | 3 +- ...omputedPropertyNamesContextualType1_ES5.js | 3 +- ...omputedPropertyNamesContextualType2_ES5.js | 3 +- ...omputedPropertyNamesContextualType3_ES5.js | 3 +- ...omputedPropertyNamesContextualType4_ES5.js | 3 +- ...omputedPropertyNamesContextualType5_ES5.js | 3 +- ...omputedPropertyNamesContextualType6_ES5.js | 3 +- ...omputedPropertyNamesContextualType7_ES5.js | 3 +- ...omputedPropertyNamesContextualType8_ES5.js | 3 +- ...omputedPropertyNamesContextualType9_ES5.js | 3 +- ...mputedPropertyNamesDeclarationEmit5_ES5.js | 3 +- .../computedPropertyNamesSourceMap2_ES5.js | 3 +- ...computedPropertyNamesSourceMap2_ES5.js.map | 2 +- ...dPropertyNamesSourceMap2_ES5.sourcemap.txt | 125 +++-- .../constDeclarations-errors.errors.txt | 12 +- .../reference/constDeclarations-errors.js | 2 - .../reference/downlevelLetConst12.js | 22 + .../reference/downlevelLetConst12.types | 30 ++ .../reference/downlevelLetConst13.js | 39 ++ .../reference/downlevelLetConst13.types | 60 +++ .../reference/downlevelLetConst14.js | 107 +++++ .../reference/downlevelLetConst14.types | 178 +++++++ .../reference/downlevelLetConst15.js | 107 +++++ .../reference/downlevelLetConst15.types | 184 ++++++++ .../reference/downlevelLetConst16.errors.txt | 249 ++++++++++ .../reference/downlevelLetConst16.js | 441 ++++++++++++++++++ .../reference/downlevelLetConst17.errors.txt | 74 +++ .../reference/downlevelLetConst17.js | 124 +++++ .../reference/downlevelLetConst18.errors.txt | 60 +++ .../reference/downlevelLetConst18.js | 57 +++ .../parserES5ComputedPropertyName2.js | 3 +- .../parserES5ComputedPropertyName3.js | 3 +- .../parserES5ComputedPropertyName4.js | 3 +- tests/baselines/reference/privateIndexer2.js | 3 +- .../compiler/constDeclarations-errors.ts | 1 - tests/cases/compiler/downlevelLetConst12.ts | 12 + tests/cases/compiler/downlevelLetConst13.ts | 21 + tests/cases/compiler/downlevelLetConst14.ts | 55 +++ tests/cases/compiler/downlevelLetConst15.ts | 55 +++ tests/cases/compiler/downlevelLetConst16.ts | 229 +++++++++ tests/cases/compiler/downlevelLetConst17.ts | 69 +++ tests/cases/compiler/downlevelLetConst18.ts | 30 ++ 73 files changed, 2315 insertions(+), 177 deletions(-) create mode 100644 tests/baselines/reference/downlevelLetConst12.js create mode 100644 tests/baselines/reference/downlevelLetConst12.types create mode 100644 tests/baselines/reference/downlevelLetConst13.js create mode 100644 tests/baselines/reference/downlevelLetConst13.types create mode 100644 tests/baselines/reference/downlevelLetConst14.js create mode 100644 tests/baselines/reference/downlevelLetConst14.types create mode 100644 tests/baselines/reference/downlevelLetConst15.js create mode 100644 tests/baselines/reference/downlevelLetConst15.types create mode 100644 tests/baselines/reference/downlevelLetConst16.errors.txt create mode 100644 tests/baselines/reference/downlevelLetConst16.js create mode 100644 tests/baselines/reference/downlevelLetConst17.errors.txt create mode 100644 tests/baselines/reference/downlevelLetConst17.js create mode 100644 tests/baselines/reference/downlevelLetConst18.errors.txt create mode 100644 tests/baselines/reference/downlevelLetConst18.js create mode 100644 tests/cases/compiler/downlevelLetConst12.ts create mode 100644 tests/cases/compiler/downlevelLetConst13.ts create mode 100644 tests/cases/compiler/downlevelLetConst14.ts create mode 100644 tests/cases/compiler/downlevelLetConst15.ts create mode 100644 tests/cases/compiler/downlevelLetConst16.ts create mode 100644 tests/cases/compiler/downlevelLetConst17.ts create mode 100644 tests/cases/compiler/downlevelLetConst18.ts diff --git a/tests/baselines/reference/ES5SymbolProperty1.js b/tests/baselines/reference/ES5SymbolProperty1.js index e977df7dc6b..21ba59abf19 100644 --- a/tests/baselines/reference/ES5SymbolProperty1.js +++ b/tests/baselines/reference/ES5SymbolProperty1.js @@ -13,7 +13,6 @@ obj[Symbol.foo]; //// [ES5SymbolProperty1.js] var Symbol; var obj = (_a = {}, _a[Symbol.foo] = -0, -_a); +0, _a); obj[Symbol.foo]; var _a; diff --git a/tests/baselines/reference/FunctionDeclaration8_es6.js b/tests/baselines/reference/FunctionDeclaration8_es6.js index 3f6d2499cef..c8cd24d8377 100644 --- a/tests/baselines/reference/FunctionDeclaration8_es6.js +++ b/tests/baselines/reference/FunctionDeclaration8_es6.js @@ -3,6 +3,5 @@ var v = { [yield]: foo } //// [FunctionDeclaration8_es6.js] var v = (_a = {}, _a[yield] = -foo, -_a); +foo, _a); var _a; diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.js b/tests/baselines/reference/FunctionDeclaration9_es6.js index 04c946a96eb..3a894126baf 100644 --- a/tests/baselines/reference/FunctionDeclaration9_es6.js +++ b/tests/baselines/reference/FunctionDeclaration9_es6.js @@ -6,7 +6,6 @@ function * foo() { //// [FunctionDeclaration9_es6.js] function foo() { var v = (_a = {}, _a[] = - foo, - _a); + foo, _a); var _a; } diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.js b/tests/baselines/reference/FunctionPropertyAssignments5_es6.js index 0b786632bdf..188a843f751 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments5_es6.js +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.js @@ -2,6 +2,5 @@ var v = { *[foo()]() { } } //// [FunctionPropertyAssignments5_es6.js] -var v = (_a = {}, _a[foo()] = function () { }, -_a); +var v = (_a = {}, _a[foo()] = function () { }, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames10_ES5.js b/tests/baselines/reference/computedPropertyNames10_ES5.js index ececb28b8cc..e330db87075 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES5.js +++ b/tests/baselines/reference/computedPropertyNames10_ES5.js @@ -20,6 +20,5 @@ var v = { var s; var n; var a; -var v = (_a = {}, _a[s] = function () { }, _a[n] = function () { }, _a[s + s] = function () { }, _a[s + n] = function () { }, _a[+s] = function () { }, _a[""] = function () { }, _a[0] = function () { }, _a[a] = function () { }, _a[true] = function () { }, _a["hello bye"] = function () { }, _a["hello " + a + " bye"] = function () { }, -_a); +var v = (_a = {}, _a[s] = function () { }, _a[n] = function () { }, _a[s + s] = function () { }, _a[s + n] = function () { }, _a[+s] = function () { }, _a[""] = function () { }, _a[0] = function () { }, _a[a] = function () { }, _a[true] = function () { }, _a["hello bye"] = function () { }, _a["hello " + a + " bye"] = function () { }, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames11_ES5.js b/tests/baselines/reference/computedPropertyNames11_ES5.js index d8450deb765..73ed6110ced 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES5.js +++ b/tests/baselines/reference/computedPropertyNames11_ES5.js @@ -20,6 +20,5 @@ var v = { var s; var n; var a; -var v = (_a = {}, _a[s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[s + s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[s + n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[+s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[""] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[0] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[a] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[true] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a["hello bye"] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a["hello " + a + " bye"] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), -_a); +var v = (_a = {}, _a[s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[s + s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[s + n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[+s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[""] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[0] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[a] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[true] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a["hello bye"] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a["hello " + a + " bye"] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames18_ES5.js b/tests/baselines/reference/computedPropertyNames18_ES5.js index 0ccc0fb4e00..0eb6cba3590 100644 --- a/tests/baselines/reference/computedPropertyNames18_ES5.js +++ b/tests/baselines/reference/computedPropertyNames18_ES5.js @@ -8,7 +8,6 @@ function foo() { //// [computedPropertyNames18_ES5.js] function foo() { var obj = (_a = {}, _a[this.bar] = - 0, - _a); + 0, _a); var _a; } diff --git a/tests/baselines/reference/computedPropertyNames19_ES5.js b/tests/baselines/reference/computedPropertyNames19_ES5.js index a18cb7b95c3..5ceaa2188e4 100644 --- a/tests/baselines/reference/computedPropertyNames19_ES5.js +++ b/tests/baselines/reference/computedPropertyNames19_ES5.js @@ -9,7 +9,6 @@ module M { var M; (function (M) { var obj = (_a = {}, _a[this.bar] = - 0, - _a); + 0, _a); var _a; })(M || (M = {})); diff --git a/tests/baselines/reference/computedPropertyNames1_ES5.js b/tests/baselines/reference/computedPropertyNames1_ES5.js index 36a7fd6052d..d8f339dc811 100644 --- a/tests/baselines/reference/computedPropertyNames1_ES5.js +++ b/tests/baselines/reference/computedPropertyNames1_ES5.js @@ -5,6 +5,5 @@ var v = { } //// [computedPropertyNames1_ES5.js] -var v = (_a = {}, _a[0 + 1] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[0 + 1] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), -_a); +var v = (_a = {}, _a[0 + 1] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[0 + 1] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames20_ES5.js b/tests/baselines/reference/computedPropertyNames20_ES5.js index 21af64d7e41..22aa44250a3 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES5.js +++ b/tests/baselines/reference/computedPropertyNames20_ES5.js @@ -5,6 +5,5 @@ var obj = { //// [computedPropertyNames20_ES5.js] var obj = (_a = {}, _a[this.bar] = -0, -_a); +0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames22_ES5.js b/tests/baselines/reference/computedPropertyNames22_ES5.js index e3e685aa54b..4dfd1286b06 100644 --- a/tests/baselines/reference/computedPropertyNames22_ES5.js +++ b/tests/baselines/reference/computedPropertyNames22_ES5.js @@ -13,8 +13,7 @@ var C = (function () { function C() { } C.prototype.bar = function () { - var obj = (_a = {}, _a[this.bar()] = function () { }, - _a); + var obj = (_a = {}, _a[this.bar()] = function () { }, _a); return 0; var _a; }; diff --git a/tests/baselines/reference/computedPropertyNames23_ES5.js b/tests/baselines/reference/computedPropertyNames23_ES5.js index 7b5a5a101a5..8ae21bc8d68 100644 --- a/tests/baselines/reference/computedPropertyNames23_ES5.js +++ b/tests/baselines/reference/computedPropertyNames23_ES5.js @@ -16,8 +16,7 @@ var C = (function () { return 0; }; C.prototype[(_a = {}, _a[this.bar()] = - 1, - _a)[0]] = function () { }; + 1, _a)[0]] = function () { }; return C; })(); var _a; diff --git a/tests/baselines/reference/computedPropertyNames25_ES5.js b/tests/baselines/reference/computedPropertyNames25_ES5.js index bd2212b72b3..97a43c7cacb 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES5.js +++ b/tests/baselines/reference/computedPropertyNames25_ES5.js @@ -34,8 +34,7 @@ var C = (function (_super) { _super.apply(this, arguments); } C.prototype.foo = function () { - var obj = (_a = {}, _a[_super.prototype.bar.call(this)] = function () { }, - _a); + var obj = (_a = {}, _a[_super.prototype.bar.call(this)] = function () { }, _a); return 0; var _a; }; diff --git a/tests/baselines/reference/computedPropertyNames26_ES5.js b/tests/baselines/reference/computedPropertyNames26_ES5.js index 5df2f6dc1b6..893541ef633 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES5.js +++ b/tests/baselines/reference/computedPropertyNames26_ES5.js @@ -35,8 +35,7 @@ var C = (function (_super) { // Gets emitted as super, not _super, which is consistent with // use of super in static properties initializers. C.prototype[(_a = {}, _a[super.bar.call(this)] = - 1, - _a)[0]] = function () { }; + 1, _a)[0]] = function () { }; return C; })(Base); var _a; diff --git a/tests/baselines/reference/computedPropertyNames28_ES5.js b/tests/baselines/reference/computedPropertyNames28_ES5.js index 7e548d4d6d3..3d9a343fcdb 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES5.js +++ b/tests/baselines/reference/computedPropertyNames28_ES5.js @@ -26,8 +26,7 @@ var C = (function (_super) { __extends(C, _super); function C() { _super.call(this); - var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { }, - _a); + var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { }, _a); var _a; } return C; diff --git a/tests/baselines/reference/computedPropertyNames29_ES5.js b/tests/baselines/reference/computedPropertyNames29_ES5.js index 27c7cd97988..ea9a9b1b635 100644 --- a/tests/baselines/reference/computedPropertyNames29_ES5.js +++ b/tests/baselines/reference/computedPropertyNames29_ES5.js @@ -17,8 +17,7 @@ var C = (function () { C.prototype.bar = function () { var _this = this; (function () { - var obj = (_a = {}, _a[_this.bar()] = function () { }, - _a); + var obj = (_a = {}, _a[_this.bar()] = function () { }, _a); var _a; }); return 0; diff --git a/tests/baselines/reference/computedPropertyNames30_ES5.js b/tests/baselines/reference/computedPropertyNames30_ES5.js index 505b149f62d..06a63dd7565 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES5.js +++ b/tests/baselines/reference/computedPropertyNames30_ES5.js @@ -32,8 +32,7 @@ var C = (function (_super) { function C() { _super.call(this); (function () { - var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { }, - _a); + var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { }, _a); var _a; }); } diff --git a/tests/baselines/reference/computedPropertyNames31_ES5.js b/tests/baselines/reference/computedPropertyNames31_ES5.js index 0c8cbac455f..a6db55259d5 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES5.js +++ b/tests/baselines/reference/computedPropertyNames31_ES5.js @@ -38,8 +38,7 @@ var C = (function (_super) { C.prototype.foo = function () { var _this = this; (function () { - var obj = (_a = {}, _a[_super.prototype.bar.call(_this)] = function () { }, - _a); + var obj = (_a = {}, _a[_super.prototype.bar.call(_this)] = function () { }, _a); var _a; }); return 0; diff --git a/tests/baselines/reference/computedPropertyNames33_ES5.js b/tests/baselines/reference/computedPropertyNames33_ES5.js index 84df68fcc10..d689d27fe5a 100644 --- a/tests/baselines/reference/computedPropertyNames33_ES5.js +++ b/tests/baselines/reference/computedPropertyNames33_ES5.js @@ -15,8 +15,7 @@ var C = (function () { function C() { } C.prototype.bar = function () { - var obj = (_a = {}, _a[foo()] = function () { }, - _a); + var obj = (_a = {}, _a[foo()] = function () { }, _a); return 0; var _a; }; diff --git a/tests/baselines/reference/computedPropertyNames34_ES5.js b/tests/baselines/reference/computedPropertyNames34_ES5.js index 9e1de33be7c..3c97971120d 100644 --- a/tests/baselines/reference/computedPropertyNames34_ES5.js +++ b/tests/baselines/reference/computedPropertyNames34_ES5.js @@ -15,8 +15,7 @@ var C = (function () { function C() { } C.bar = function () { - var obj = (_a = {}, _a[foo()] = function () { }, - _a); + var obj = (_a = {}, _a[foo()] = function () { }, _a); return 0; var _a; }; diff --git a/tests/baselines/reference/computedPropertyNames46_ES5.js b/tests/baselines/reference/computedPropertyNames46_ES5.js index 3e4329b8a20..6e999b39586 100644 --- a/tests/baselines/reference/computedPropertyNames46_ES5.js +++ b/tests/baselines/reference/computedPropertyNames46_ES5.js @@ -5,6 +5,5 @@ var o = { //// [computedPropertyNames46_ES5.js] var o = (_a = {}, _a["" || 0] = -0, -_a); +0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames47_ES5.js b/tests/baselines/reference/computedPropertyNames47_ES5.js index 7874a25976f..977f18770be 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES5.js +++ b/tests/baselines/reference/computedPropertyNames47_ES5.js @@ -15,6 +15,5 @@ var E2; E2[E2["x"] = 0] = "x"; })(E2 || (E2 = {})); var o = (_a = {}, _a[0 /* x */ || 0 /* x */] = -0, -_a); +0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames48_ES5.js b/tests/baselines/reference/computedPropertyNames48_ES5.js index f3f9941aeae..00d7db670eb 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES5.js +++ b/tests/baselines/reference/computedPropertyNames48_ES5.js @@ -24,12 +24,9 @@ var E; })(E || (E = {})); var a; extractIndexer((_a = {}, _a[a] = -"", -_a)); // Should return string +"", _a)); // Should return string extractIndexer((_b = {}, _b[0 /* x */] = -"", -_b)); // Should return string +"", _b)); // Should return string extractIndexer((_c = {}, _c["" || 0] = -"", -_c)); // Should return any (widened form of undefined) +"", _c)); // Should return any (widened form of undefined) var _a, _b, _c; diff --git a/tests/baselines/reference/computedPropertyNames49_ES5.js b/tests/baselines/reference/computedPropertyNames49_ES5.js index a64d9431a9a..ba941a49e12 100644 --- a/tests/baselines/reference/computedPropertyNames49_ES5.js +++ b/tests/baselines/reference/computedPropertyNames49_ES5.js @@ -41,6 +41,5 @@ var x = (_a = { return 10; } }, enumerable: true, configurable: true }), _a.p2 = -20, -_a); +20, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames4_ES5.js b/tests/baselines/reference/computedPropertyNames4_ES5.js index 255b14eb970..59f5e80873e 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES5.js +++ b/tests/baselines/reference/computedPropertyNames4_ES5.js @@ -31,6 +31,5 @@ s, _a[""] = 1, _a[true] = 0, _a["hello bye"] = 0, _a["hello " + a + " bye"] = -0, -_a); +0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames50_ES5.js b/tests/baselines/reference/computedPropertyNames50_ES5.js index a0703eeac05..6e7f63dd56e 100644 --- a/tests/baselines/reference/computedPropertyNames50_ES5.js +++ b/tests/baselines/reference/computedPropertyNames50_ES5.js @@ -46,6 +46,5 @@ var x = (_a = { }, enumerable: true, configurable: true }), _a[1 + 1] = Object.defineProperty({ get: function () { return 10; }, enumerable: true, configurable: true }), _a.p2 = -20, -_a); +20, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames5_ES5.js b/tests/baselines/reference/computedPropertyNames5_ES5.js index 722c0f3a74d..25c6e79a9ea 100644 --- a/tests/baselines/reference/computedPropertyNames5_ES5.js +++ b/tests/baselines/reference/computedPropertyNames5_ES5.js @@ -17,6 +17,5 @@ var v = (_a = {}, _a[b] = 0, _a[{}] = 0, _a[undefined] = undefined, _a[null] = -null, -_a); +null, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames6_ES5.js b/tests/baselines/reference/computedPropertyNames6_ES5.js index 4e3ed1b2e9f..4e4cc0ad09e 100644 --- a/tests/baselines/reference/computedPropertyNames6_ES5.js +++ b/tests/baselines/reference/computedPropertyNames6_ES5.js @@ -15,6 +15,5 @@ var p3; var v = (_a = {}, _a[p1] = 0, _a[p2] = 1, _a[p3] = -2, -_a); +2, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames7_ES5.js b/tests/baselines/reference/computedPropertyNames7_ES5.js index 3e1bcc1151c..f5939227d9d 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES5.js +++ b/tests/baselines/reference/computedPropertyNames7_ES5.js @@ -12,6 +12,5 @@ var E; E[E["member"] = 0] = "member"; })(E || (E = {})); var v = (_a = {}, _a[0 /* member */] = -0, -_a); +0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames8_ES5.js b/tests/baselines/reference/computedPropertyNames8_ES5.js index 4db9ed2ec13..23c2d6c1832 100644 --- a/tests/baselines/reference/computedPropertyNames8_ES5.js +++ b/tests/baselines/reference/computedPropertyNames8_ES5.js @@ -14,7 +14,6 @@ function f() { var u; var v = (_a = {}, _a[t] = 0, _a[u] = - 1, - _a); + 1, _a); var _a; } diff --git a/tests/baselines/reference/computedPropertyNames9_ES5.js b/tests/baselines/reference/computedPropertyNames9_ES5.js index a7c4a74d5ec..137a3e8d103 100644 --- a/tests/baselines/reference/computedPropertyNames9_ES5.js +++ b/tests/baselines/reference/computedPropertyNames9_ES5.js @@ -15,6 +15,5 @@ function f(x) { } var v = (_a = {}, _a[f("")] = 0, _a[f(0)] = 0, _a[f(true)] = -0, -_a); +0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js index 5ea05124674..00f1cec3cc4 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js @@ -11,6 +11,5 @@ var o: I = { //// [computedPropertyNamesContextualType10_ES5.js] var o = (_a = {}, _a[+"foo"] = "", _a[+"bar"] = -0, -_a); +0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js index a7994495411..2efeaa2149c 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js @@ -11,6 +11,5 @@ var o: I = { //// [computedPropertyNamesContextualType1_ES5.js] var o = (_a = {}, _a["" + 0] = function (y) { return y.length; }, _a["" + 1] = -function (y) { return y.length; }, -_a); +function (y) { return y.length; }, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js index 0c6b80bbabb..dad5e0ea0cf 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js @@ -11,6 +11,5 @@ var o: I = { //// [computedPropertyNamesContextualType2_ES5.js] var o = (_a = {}, _a[+"foo"] = function (y) { return y.length; }, _a[+"bar"] = -function (y) { return y.length; }, -_a); +function (y) { return y.length; }, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js index 4336808c558..b453460eea5 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js @@ -10,6 +10,5 @@ var o: I = { //// [computedPropertyNamesContextualType3_ES5.js] var o = (_a = {}, _a[+"foo"] = function (y) { return y.length; }, _a[+"bar"] = -function (y) { return y.length; }, -_a); +function (y) { return y.length; }, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js index b813da30496..6e9a0b49daa 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js @@ -12,6 +12,5 @@ var o: I = { //// [computedPropertyNamesContextualType4_ES5.js] var o = (_a = {}, _a["" + "foo"] = "", _a["" + "bar"] = -0, -_a); +0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js index f75389de3e9..01830f4f46b 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js @@ -12,6 +12,5 @@ var o: I = { //// [computedPropertyNamesContextualType5_ES5.js] var o = (_a = {}, _a[+"foo"] = "", _a[+"bar"] = -0, -_a); +0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js index bc724320d14..820439c1522 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js @@ -22,6 +22,5 @@ foo((_a = { function () { }, _a["hi" + "bye"] = true, _a[0 + 1] = 0, _a[+"hi"] = -[0], -_a)); +[0], _a)); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js index 8d2386a1d14..f1087c12431 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js @@ -22,6 +22,5 @@ foo((_a = { function () { }, _a["hi" + "bye"] = true, _a[0 + 1] = 0, _a[+"hi"] = -[0], -_a)); +[0], _a)); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js index 626f3d1a8e2..e47dc67e40e 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js @@ -12,6 +12,5 @@ var o: I = { //// [computedPropertyNamesContextualType8_ES5.js] var o = (_a = {}, _a["" + "foo"] = "", _a["" + "bar"] = -0, -_a); +0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js index c28db4ded97..dd21df8dd67 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js @@ -12,6 +12,5 @@ var o: I = { //// [computedPropertyNamesContextualType9_ES5.js] var o = (_a = {}, _a[+"foo"] = "", _a[+"bar"] = -0, -_a); +0, _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js index a0666f166d4..f93d26b23d6 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js @@ -8,8 +8,7 @@ var v = { //// [computedPropertyNamesDeclarationEmit5_ES5.js] var v = (_a = {}, _a["" + ""] = -0, _a["" + ""] = function () { }, _a["" + ""] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a["" + ""] = Object.defineProperty({ set: function (x) { }, enumerable: true, configurable: true }), -_a); +0, _a["" + ""] = function () { }, _a["" + ""] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a["" + ""] = Object.defineProperty({ set: function (x) { }, enumerable: true, configurable: true }), _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js index c5af22ef398..d01778ff90d 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js @@ -8,7 +8,6 @@ var v = { //// [computedPropertyNamesSourceMap2_ES5.js] var v = (_a = {}, _a["hello"] = function () { debugger; -}, -_a); +}, _a); var _a; //# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map index 82a729df957..e794b6265a3 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map @@ -1,2 +1,2 @@ //// [computedPropertyNamesSourceMap2_ES5.js.map] -{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,AADA,CACA,EAAA,GADA,EAAA,EACA,EAAA,CACK,OAAO,CAFA,GAAA;IAGA,QAAQ,CAAC;AACb,CAAC,AAJA;AACA,EAAA,AADA,CAKA,CAAA;IAJD,EAAA"} \ No newline at end of file +{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,AADA,CAAA,EAAA,GAAA,EAAA,EAAA,EAAA,CAEA,OAAO,CAFA,GAAA;IAGA,QAAQ,CAAC;AACb,CAAC,AAJA,EAAA,EAAA,CAKA,CAAA;IALA,EAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt index 33a3a2b4c2c..2ca7a367924 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt @@ -32,47 +32,46 @@ 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 > 10> !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column -10> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 15) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 19) Source(1, 1) + SourceIndex(0) nameIndex (-1) +10> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 12) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 19) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 10> 11> !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found -11> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 17) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 21) Source(1, 1) + SourceIndex(0) nameIndex (-1) +11> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 15) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 21) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 11> 12> !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column -12> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 17) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 22) Source(2, 6) + SourceIndex(0) nameIndex (-1) -12> var v = { - > [ -13> !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -13> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 19) Source(1, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 29) Source(2, 13) + SourceIndex(0) nameIndex (-1) +12> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 15) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 22) Source(2, 6) + SourceIndex(0) nameIndex (-1) +12> +13> !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found +13> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 17) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 29) Source(2, 13) + SourceIndex(0) nameIndex (-1) 13> "hello" -14> !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -14> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 21) Source(1, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 30) Source(0, NaN) + SourceIndex(0) nameIndex (-1) +14> !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column +14> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 17) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 30) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 14> -15> !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span: -15> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 22) Source(2, 14) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 33) Source(0, NaN) + SourceIndex(0) nameIndex (-1) +15> !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found +15> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 19) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 33) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 15> 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) -10>Emitted(1, 19) Source(1, 1) + SourceIndex(0) -11>Emitted(1, 21) Source(1, 1) + SourceIndex(0) +10>Emitted(1, 19) Source(0, NaN) + SourceIndex(0) +11>Emitted(1, 21) Source(0, NaN) + SourceIndex(0) 12>Emitted(1, 22) Source(2, 6) + SourceIndex(0) 13>Emitted(1, 29) Source(2, 13) + SourceIndex(0) 14>Emitted(1, 30) Source(0, NaN) + SourceIndex(0) @@ -82,79 +81,71 @@ 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(1, 29) Source(2, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 5) 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(1, 19) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 5) 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(1, 30) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 13) Source(3, 17) + SourceIndex(0) nameIndex (-1) +2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 21) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 13) 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(1, 30) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 14) Source(3, 18) + SourceIndex(0) nameIndex (-1) +3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 21) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 14) Source(3, 18) + SourceIndex(0) nameIndex (-1) 3 > ; 1 >Emitted(2, 5) Source(3, 9) + SourceIndex(0) 2 >Emitted(2, 13) Source(3, 17) + SourceIndex(0) 3 >Emitted(2, 14) Source(3, 18) + SourceIndex(0) --- ->>>}, +>>>}, _a); 1 > 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(1, 33) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 1) Source(4, 5) + SourceIndex(0) nameIndex (-1) +4 > ^^ +5 > ^^ +6 > ^ +7 > ^ +8 > ^-> +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(1, 22) Source(2, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 1) 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(1, 33) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 2) 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(1, 29) Source(2, 16) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 2) 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(2, 5) Source(3, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 2) 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(1, 30) Source(0, 16) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 2) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 3 > +4 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column +4 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 30) Source(0, 16) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 4) Source(0, NaN) + SourceIndex(0) nameIndex (-1) +4 > +5 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found +5 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 33) Source(0, 16) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 6) 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, 33) Source(0, 16) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 7) Source(5, 2) + 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(2, 5) Source(3, 16) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 8) Source(5, 2) + SourceIndex(0) nameIndex (-1) +7 > 1 >Emitted(3, 1) Source(4, 5) + SourceIndex(0) 2 >Emitted(3, 2) Source(4, 6) + SourceIndex(0) 3 >Emitted(3, 2) Source(0, NaN) + SourceIndex(0) ---- ->>>_a); -1-> -2 >^^ -3 > -4 > ^ -5 > ^ -6 > ^^^^-> -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, 13) Source(3, 29) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 1) Source(1, 1) + 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(2, 14) Source(3, 30) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 3) Source(1, 1) + 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, 1) Source(4, 17) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 3) Source(0, NaN) + 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(3, 2) Source(4, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 4) Source(5, 2) + SourceIndex(0) nameIndex (-1) -4 > -5 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found -5 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 2) Source(0, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 5) Source(5, 2) + SourceIndex(0) nameIndex (-1) -5 > -1->Emitted(4, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(4, 3) Source(1, 1) + SourceIndex(0) -3 >Emitted(4, 3) Source(0, NaN) + SourceIndex(0) -4 >Emitted(4, 4) Source(5, 2) + SourceIndex(0) -5 >Emitted(4, 5) Source(5, 2) + SourceIndex(0) +4 >Emitted(3, 4) Source(0, NaN) + SourceIndex(0) +5 >Emitted(3, 6) Source(0, NaN) + SourceIndex(0) +6 >Emitted(3, 7) Source(5, 2) + SourceIndex(0) +7 >Emitted(3, 8) Source(5, 2) + SourceIndex(0) --- >>>var _a; 1->^^^^ 2 > ^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -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(3, 2) Source(0, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 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(2, 13) Source(3, 24) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 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(4, 1) Source(1, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 7) Source(1, 1) + SourceIndex(0) nameIndex (-1) +2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 14) Source(3, 25) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 7) Source(0, NaN) + SourceIndex(0) nameIndex (-1) 2 > -1->Emitted(5, 5) Source(1, 1) + SourceIndex(0) -2 >Emitted(5, 7) Source(1, 1) + SourceIndex(0) +1->Emitted(4, 5) Source(0, NaN) + SourceIndex(0) +2 >Emitted(4, 7) Source(0, NaN) + SourceIndex(0) --- !!!! **** There are more source map entries in the sourceMap's mapping than what was encoded -!!!! **** Remaining decoded string: ,EAAA,AADA,CAKA,CAAA;IAJD,EAAA +!!!! **** Remaining decoded string: ;AACb,CAAC,AAJA,EAAA,EAAA,CAKA,CAAA;IALA,EAAA >>>//# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map \ No newline at end of file diff --git a/tests/baselines/reference/constDeclarations-errors.errors.txt b/tests/baselines/reference/constDeclarations-errors.errors.txt index c0ae6635c5e..10501beb1a5 100644 --- a/tests/baselines/reference/constDeclarations-errors.errors.txt +++ b/tests/baselines/reference/constDeclarations-errors.errors.txt @@ -4,13 +4,12 @@ tests/cases/compiler/constDeclarations-errors.ts(5,7): error TS1155: 'const' dec tests/cases/compiler/constDeclarations-errors.ts(5,11): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(5,15): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(5,27): error TS1155: 'const' declarations must be initialized -tests/cases/compiler/constDeclarations-errors.ts(8,11): error TS1155: 'const' declarations must be initialized -tests/cases/compiler/constDeclarations-errors.ts(11,27): error TS2449: The operand of an increment or decrement operator cannot be a constant. -tests/cases/compiler/constDeclarations-errors.ts(14,11): error TS1155: 'const' declarations must be initialized -tests/cases/compiler/constDeclarations-errors.ts(17,20): error TS1155: 'const' declarations must be initialized +tests/cases/compiler/constDeclarations-errors.ts(10,27): error TS2449: The operand of an increment or decrement operator cannot be a constant. +tests/cases/compiler/constDeclarations-errors.ts(13,11): error TS1155: 'const' declarations must be initialized +tests/cases/compiler/constDeclarations-errors.ts(16,20): error TS1155: 'const' declarations must be initialized -==== tests/cases/compiler/constDeclarations-errors.ts (10 errors) ==== +==== tests/cases/compiler/constDeclarations-errors.ts (9 errors) ==== // error, missing intialicer const c1; @@ -29,10 +28,7 @@ tests/cases/compiler/constDeclarations-errors.ts(17,20): error TS1155: 'const' d ~~ !!! error TS1155: 'const' declarations must be initialized - // error, can not be unintalized for(const c in {}) { } - ~ -!!! error TS1155: 'const' declarations must be initialized // error, assigning to a const for(const c8 = 0; c8 < 1; c8++) { } diff --git a/tests/baselines/reference/constDeclarations-errors.js b/tests/baselines/reference/constDeclarations-errors.js index a9564e266a0..e7143f2564a 100644 --- a/tests/baselines/reference/constDeclarations-errors.js +++ b/tests/baselines/reference/constDeclarations-errors.js @@ -5,7 +5,6 @@ const c1; const c2: number; const c3, c4, c5 :string, c6; // error, missing initialicer -// error, can not be unintalized for(const c in {}) { } // error, assigning to a const @@ -22,7 +21,6 @@ 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 (const c in {}) { } // error, assigning to a const for (const c8 = 0; c8 < 1; c8++) { } diff --git a/tests/baselines/reference/downlevelLetConst12.js b/tests/baselines/reference/downlevelLetConst12.js new file mode 100644 index 00000000000..6437d17accb --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst12.js @@ -0,0 +1,22 @@ +//// [downlevelLetConst12.ts] + +'use strict' +// top level let\const should not be renamed +let foo; +const bar = 1; + +let [baz] = []; +let {a: baz2} = { a: 1 }; + +const [baz3] = [] +const {a: baz4} = { a: 1 }; + +//// [downlevelLetConst12.js] +'use strict'; +// top level let\const should not be renamed +var foo; +var bar = 1; +var baz = ([])[0]; +var baz2 = ({ a: 1 }).a; +var baz3 = ([])[0]; +var baz4 = ({ a: 1 }).a; diff --git a/tests/baselines/reference/downlevelLetConst12.types b/tests/baselines/reference/downlevelLetConst12.types new file mode 100644 index 00000000000..90a814e0753 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst12.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/downlevelLetConst12.ts === + +'use strict' +// top level let\const should not be renamed +let foo; +>foo : any + +const bar = 1; +>bar : number + +let [baz] = []; +>baz : any +>[] : undefined[] + +let {a: baz2} = { a: 1 }; +>a : unknown +>baz2 : number +>{ a: 1 } : { a: number; } +>a : number + +const [baz3] = [] +>baz3 : any +>[] : undefined[] + +const {a: baz4} = { a: 1 }; +>a : unknown +>baz4 : number +>{ a: 1 } : { a: number; } +>a : number + diff --git a/tests/baselines/reference/downlevelLetConst13.js b/tests/baselines/reference/downlevelLetConst13.js new file mode 100644 index 00000000000..8324d697e95 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst13.js @@ -0,0 +1,39 @@ +//// [downlevelLetConst13.ts] + +'use strict' +// exported let\const bindings should not be renamed + +export let foo = 10; +export const bar = "123" +export let [bar1] = [1]; +export const [bar2] = [2]; +export let {a: bar3} = { a: 1 }; +export const {a: bar4} = { a: 1 }; + +export module M { + export let baz = 100; + export const baz2 = true; + export let [bar5] = [1]; + export const [bar6] = [2]; + export let {a: bar7} = { a: 1 }; + export const {a: bar8} = { a: 1 }; +} + +//// [downlevelLetConst13.js] +'use strict'; +// exported let\const bindings should not be renamed +exports.foo = 10; +exports.bar = "123"; +exports.bar1 = ([1])[0]; +exports.bar2 = ([2])[0]; +exports.bar3 = ({ a: 1 }).a; +exports.bar4 = ({ a: 1 }).a; +var M; +(function (M) { + M.baz = 100; + M.baz2 = true; + M.bar5 = ([1])[0]; + M.bar6 = ([2])[0]; + M.bar7 = ({ a: 1 }).a; + M.bar8 = ({ a: 1 }).a; +})(M = exports.M || (exports.M = {})); diff --git a/tests/baselines/reference/downlevelLetConst13.types b/tests/baselines/reference/downlevelLetConst13.types new file mode 100644 index 00000000000..e72e3936f43 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst13.types @@ -0,0 +1,60 @@ +=== tests/cases/compiler/downlevelLetConst13.ts === + +'use strict' +// exported let\const bindings should not be renamed + +export let foo = 10; +>foo : number + +export const bar = "123" +>bar : string + +export let [bar1] = [1]; +>bar1 : number +>[1] : [number] + +export const [bar2] = [2]; +>bar2 : number +>[2] : [number] + +export let {a: bar3} = { a: 1 }; +>a : unknown +>bar3 : number +>{ a: 1 } : { a: number; } +>a : number + +export const {a: bar4} = { a: 1 }; +>a : unknown +>bar4 : number +>{ a: 1 } : { a: number; } +>a : number + +export module M { +>M : typeof M + + export let baz = 100; +>baz : number + + export const baz2 = true; +>baz2 : boolean + + export let [bar5] = [1]; +>bar5 : number +>[1] : [number] + + export const [bar6] = [2]; +>bar6 : number +>[2] : [number] + + export let {a: bar7} = { a: 1 }; +>a : unknown +>bar7 : number +>{ a: 1 } : { a: number; } +>a : number + + export const {a: bar8} = { a: 1 }; +>a : unknown +>bar8 : number +>{ a: 1 } : { a: number; } +>a : number +} diff --git a/tests/baselines/reference/downlevelLetConst14.js b/tests/baselines/reference/downlevelLetConst14.js new file mode 100644 index 00000000000..212262dc43a --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst14.js @@ -0,0 +1,107 @@ +//// [downlevelLetConst14.ts] +'use strict' +declare function use(a: any); + +var x = 10; +var z0, z1, z2, z3; +{ + let x = 20; + use(x); + + let [z0] = [1]; + use(z0); + let [z1] = [1] + use(z1); + let {a: z2} = { a: 1 }; + use(z2); + let {a: z3} = { a: 1 }; + use(z3); +} +use(x); +use(z0); +use(z1); +use(z2); +use(z3); +var z6; +var y = true; +{ + let y = ""; + let [z6] = [true] + { + let y = 1; + let {a: z6} = {a: 1} + use(y); + use(z6); + } + use(y); + use(z6); +} +use(y); +use(z6); + +var z = false; +var z5 = 1; +{ + let z = ""; + let [z5] = [5]; + { + let _z = 1; + let {a: _z5} = { a: 1 }; + // try to step on generated name + use(_z); + } + use(z); +} +use(y); + +//// [downlevelLetConst14.js] +'use strict'; +var x = 10; +var z0, z1, z2, z3; +{ + var _x = 20; + use(_x); + var _z0 = ([1])[0]; + use(_z0); + var _z1 = ([1])[0]; + use(_z1); + var _z2 = ({ a: 1 }).a; + use(_z2); + var _z3 = ({ a: 1 }).a; + use(_z3); +} +use(x); +use(z0); +use(z1); +use(z2); +use(z3); +var z6; +var y = true; +{ + var _y = ""; + var _z6 = ([true])[0]; + { + var _y_1 = 1; + var _z6_1 = ({ a: 1 }).a; + use(_y_1); + use(_z6_1); + } + use(_y); + use(_z6); +} +use(y); +use(z6); +var z = false; +var z5 = 1; +{ + var _z = ""; + var _z5 = ([5])[0]; + { + var _z_1 = 1; + var _z5_1 = ({ a: 1 }).a; + // try to step on generated name + use(_z_1); + } + use(_z); +} +use(y); diff --git a/tests/baselines/reference/downlevelLetConst14.types b/tests/baselines/reference/downlevelLetConst14.types new file mode 100644 index 00000000000..05b66948830 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst14.types @@ -0,0 +1,178 @@ +=== tests/cases/compiler/downlevelLetConst14.ts === +'use strict' +declare function use(a: any); +>use : (a: any) => any +>a : any + +var x = 10; +>x : number + +var z0, z1, z2, z3; +>z0 : any +>z1 : any +>z2 : any +>z3 : any +{ + let x = 20; +>x : number + + use(x); +>use(x) : any +>use : (a: any) => any +>x : number + + let [z0] = [1]; +>z0 : number +>[1] : [number] + + use(z0); +>use(z0) : any +>use : (a: any) => any +>z0 : number + + let [z1] = [1] +>z1 : number +>[1] : [number] + + use(z1); +>use(z1) : any +>use : (a: any) => any +>z1 : number + + let {a: z2} = { a: 1 }; +>a : unknown +>z2 : number +>{ a: 1 } : { a: number; } +>a : number + + use(z2); +>use(z2) : any +>use : (a: any) => any +>z2 : number + + let {a: z3} = { a: 1 }; +>a : unknown +>z3 : number +>{ a: 1 } : { a: number; } +>a : number + + use(z3); +>use(z3) : any +>use : (a: any) => any +>z3 : number +} +use(x); +>use(x) : any +>use : (a: any) => any +>x : number + +use(z0); +>use(z0) : any +>use : (a: any) => any +>z0 : any + +use(z1); +>use(z1) : any +>use : (a: any) => any +>z1 : any + +use(z2); +>use(z2) : any +>use : (a: any) => any +>z2 : any + +use(z3); +>use(z3) : any +>use : (a: any) => any +>z3 : any + +var z6; +>z6 : any + +var y = true; +>y : boolean +{ + let y = ""; +>y : string + + let [z6] = [true] +>z6 : boolean +>[true] : [boolean] + { + let y = 1; +>y : number + + let {a: z6} = {a: 1} +>a : unknown +>z6 : number +>{a: 1} : { a: number; } +>a : number + + use(y); +>use(y) : any +>use : (a: any) => any +>y : number + + use(z6); +>use(z6) : any +>use : (a: any) => any +>z6 : number + } + use(y); +>use(y) : any +>use : (a: any) => any +>y : string + + use(z6); +>use(z6) : any +>use : (a: any) => any +>z6 : boolean +} +use(y); +>use(y) : any +>use : (a: any) => any +>y : boolean + +use(z6); +>use(z6) : any +>use : (a: any) => any +>z6 : any + +var z = false; +>z : boolean + +var z5 = 1; +>z5 : number +{ + let z = ""; +>z : string + + let [z5] = [5]; +>z5 : number +>[5] : [number] + { + let _z = 1; +>_z : number + + let {a: _z5} = { a: 1 }; +>a : unknown +>_z5 : number +>{ a: 1 } : { a: number; } +>a : number + + // try to step on generated name + use(_z); +>use(_z) : any +>use : (a: any) => any +>_z : number + } + use(z); +>use(z) : any +>use : (a: any) => any +>z : string +} +use(y); +>use(y) : any +>use : (a: any) => any +>y : boolean + diff --git a/tests/baselines/reference/downlevelLetConst15.js b/tests/baselines/reference/downlevelLetConst15.js new file mode 100644 index 00000000000..c9b67719197 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst15.js @@ -0,0 +1,107 @@ +//// [downlevelLetConst15.ts] +'use strict' +declare function use(a: any); + +var x = 10; +var z0, z1, z2, z3; +{ + const x = 20; + use(x); + + const [z0] = [1]; + use(z0); + const [{a: z1}] = [{a: 1}] + use(z1); + const {a: z2} = { a: 1 }; + use(z2); + const {a: {b: z3}} = { a: {b: 1} }; + use(z3); +} +use(x); +use(z0); +use(z1); +use(z2); +use(z3); +var z6; +var y = true; +{ + const y = ""; + const [z6] = [true] + { + const y = 1; + const {a: z6} = { a: 1 } + use(y); + use(z6); + } + use(y); + use(z6); +} +use(y); +use(z6); + +var z = false; +var z5 = 1; +{ + const z = ""; + const [z5] = [5]; + { + const _z = 1; + const {a: _z5} = { a: 1 }; + // try to step on generated name + use(_z); + } + use(z); +} +use(y); + +//// [downlevelLetConst15.js] +'use strict'; +var x = 10; +var z0, z1, z2, z3; +{ + var _x = 20; + use(_x); + var _z0 = ([1])[0]; + use(_z0); + var _z1 = ([{ a: 1 }])[0].a; + use(_z1); + var _z2 = ({ a: 1 }).a; + use(_z2); + var _z3 = ({ a: { b: 1 } }).a.b; + use(_z3); +} +use(x); +use(z0); +use(z1); +use(z2); +use(z3); +var z6; +var y = true; +{ + var _y = ""; + var _z6 = ([true])[0]; + { + var _y_1 = 1; + var _z6_1 = ({ a: 1 }).a; + use(_y_1); + use(_z6_1); + } + use(_y); + use(_z6); +} +use(y); +use(z6); +var z = false; +var z5 = 1; +{ + var _z = ""; + var _z5 = ([5])[0]; + { + var _z_1 = 1; + var _z5_1 = ({ a: 1 }).a; + // try to step on generated name + use(_z_1); + } + use(_z); +} +use(y); diff --git a/tests/baselines/reference/downlevelLetConst15.types b/tests/baselines/reference/downlevelLetConst15.types new file mode 100644 index 00000000000..008d132ab70 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst15.types @@ -0,0 +1,184 @@ +=== tests/cases/compiler/downlevelLetConst15.ts === +'use strict' +declare function use(a: any); +>use : (a: any) => any +>a : any + +var x = 10; +>x : number + +var z0, z1, z2, z3; +>z0 : any +>z1 : any +>z2 : any +>z3 : any +{ + const x = 20; +>x : number + + use(x); +>use(x) : any +>use : (a: any) => any +>x : number + + const [z0] = [1]; +>z0 : number +>[1] : [number] + + use(z0); +>use(z0) : any +>use : (a: any) => any +>z0 : number + + const [{a: z1}] = [{a: 1}] +>a : unknown +>z1 : number +>[{a: 1}] : [{ a: number; }] +>{a: 1} : { a: number; } +>a : number + + use(z1); +>use(z1) : any +>use : (a: any) => any +>z1 : number + + const {a: z2} = { a: 1 }; +>a : unknown +>z2 : number +>{ a: 1 } : { a: number; } +>a : number + + use(z2); +>use(z2) : any +>use : (a: any) => any +>z2 : number + + const {a: {b: z3}} = { a: {b: 1} }; +>a : unknown +>b : unknown +>z3 : number +>{ a: {b: 1} } : { a: { b: number; }; } +>a : { b: number; } +>{b: 1} : { b: number; } +>b : number + + use(z3); +>use(z3) : any +>use : (a: any) => any +>z3 : number +} +use(x); +>use(x) : any +>use : (a: any) => any +>x : number + +use(z0); +>use(z0) : any +>use : (a: any) => any +>z0 : any + +use(z1); +>use(z1) : any +>use : (a: any) => any +>z1 : any + +use(z2); +>use(z2) : any +>use : (a: any) => any +>z2 : any + +use(z3); +>use(z3) : any +>use : (a: any) => any +>z3 : any + +var z6; +>z6 : any + +var y = true; +>y : boolean +{ + const y = ""; +>y : string + + const [z6] = [true] +>z6 : boolean +>[true] : [boolean] + { + const y = 1; +>y : number + + const {a: z6} = { a: 1 } +>a : unknown +>z6 : number +>{ a: 1 } : { a: number; } +>a : number + + use(y); +>use(y) : any +>use : (a: any) => any +>y : number + + use(z6); +>use(z6) : any +>use : (a: any) => any +>z6 : number + } + use(y); +>use(y) : any +>use : (a: any) => any +>y : string + + use(z6); +>use(z6) : any +>use : (a: any) => any +>z6 : boolean +} +use(y); +>use(y) : any +>use : (a: any) => any +>y : boolean + +use(z6); +>use(z6) : any +>use : (a: any) => any +>z6 : any + +var z = false; +>z : boolean + +var z5 = 1; +>z5 : number +{ + const z = ""; +>z : string + + const [z5] = [5]; +>z5 : number +>[5] : [number] + { + const _z = 1; +>_z : number + + const {a: _z5} = { a: 1 }; +>a : unknown +>_z5 : number +>{ a: 1 } : { a: number; } +>a : number + + // try to step on generated name + use(_z); +>use(_z) : any +>use : (a: any) => any +>_z : number + } + use(z); +>use(z) : any +>use : (a: any) => any +>z : string +} +use(y); +>use(y) : any +>use : (a: any) => any +>y : boolean + diff --git a/tests/baselines/reference/downlevelLetConst16.errors.txt b/tests/baselines/reference/downlevelLetConst16.errors.txt new file mode 100644 index 00000000000..dafdd5b7b07 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst16.errors.txt @@ -0,0 +1,249 @@ +tests/cases/compiler/downlevelLetConst16.ts(189,5): error TS9003: 'for...of' statements are not currently supported. +tests/cases/compiler/downlevelLetConst16.ts(196,5): error TS9003: 'for...of' statements are not currently supported. +tests/cases/compiler/downlevelLetConst16.ts(203,5): error TS9003: 'for...of' statements are not currently supported. +tests/cases/compiler/downlevelLetConst16.ts(210,5): error TS9003: 'for...of' statements are not currently supported. +tests/cases/compiler/downlevelLetConst16.ts(217,5): error TS9003: 'for...of' statements are not currently supported. +tests/cases/compiler/downlevelLetConst16.ts(224,5): error TS9003: 'for...of' statements are not currently supported. + + +==== tests/cases/compiler/downlevelLetConst16.ts (6 errors) ==== + 'use strict' + + declare function use(a: any); + + var x = 10; + var y; + var z; + use(x); + use(y); + use(z); + function foo1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = {a: 1}; + use(z); + } + + function foo2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); + } + + class A { + m1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + m2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); + } + + } + + class B { + m1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + m2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + } + } + + function bar1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + } + + function bar2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + } + + module M1 { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + + module M2 { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); + } + + module M3 { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + + module M4 { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + use(y); + use(z); + } + + function foo3() { + for (let x; ;) { + use(x); + } + for (let [y] = []; ;) { + use(y); + } + for (let {a: z} = {a: 1}; ;) { + use(z); + } + use(x); + } + + function foo4() { + for (const x = 1; ;) { + use(x); + } + for (const [y] = []; ;) { + use(y); + } + for (const {a: z} = { a: 1 }; ;) { + use(z); + } + use(x); + } + + function foo5() { + for (let x in []) { + use(x); + } + use(x); + } + + function foo6() { + for (const x in []) { + use(x); + } + use(x); + } + + // TODO: once for-of is supported downlevel + function foo7() { + for (let x of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } + use(x); + } + + function foo8() { + for (let [x] of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } + use(x); + } + + function foo9() { + for (let {a: x} of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } + use(x); + } + + function foo10() { + for (const x of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } + use(x); + } + + function foo11() { + for (const [x] of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } + use(x); + } + + function foo12() { + for (const {a: x} of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } + use(x); + } \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst16.js b/tests/baselines/reference/downlevelLetConst16.js new file mode 100644 index 00000000000..36da8ac36fe --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst16.js @@ -0,0 +1,441 @@ +//// [downlevelLetConst16.ts] +'use strict' + +declare function use(a: any); + +var x = 10; +var y; +var z; +use(x); +use(y); +use(z); +function foo1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = {a: 1}; + use(z); +} + +function foo2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); +} + +class A { + m1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + m2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); + } + +} + +class B { + m1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + m2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + } +} + +function bar1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); +} + +function bar2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); +} + +module M1 { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); +} + +module M2 { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); +} + +module M3 { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + +} + +module M4 { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + use(y); + use(z); +} + +function foo3() { + for (let x; ;) { + use(x); + } + for (let [y] = []; ;) { + use(y); + } + for (let {a: z} = {a: 1}; ;) { + use(z); + } + use(x); +} + +function foo4() { + for (const x = 1; ;) { + use(x); + } + for (const [y] = []; ;) { + use(y); + } + for (const {a: z} = { a: 1 }; ;) { + use(z); + } + use(x); +} + +function foo5() { + for (let x in []) { + use(x); + } + use(x); +} + +function foo6() { + for (const x in []) { + use(x); + } + use(x); +} + +// TODO: once for-of is supported downlevel +function foo7() { + for (let x of []) { + use(x); + } + use(x); +} + +function foo8() { + for (let [x] of []) { + use(x); + } + use(x); +} + +function foo9() { + for (let {a: x} of []) { + use(x); + } + use(x); +} + +function foo10() { + for (const x of []) { + use(x); + } + use(x); +} + +function foo11() { + for (const [x] of []) { + use(x); + } + use(x); +} + +function foo12() { + for (const {a: x} of []) { + use(x); + } + use(x); +} + +//// [downlevelLetConst16.js] +'use strict'; +var x = 10; +var y; +var z; +use(x); +use(y); +use(z); +function foo1() { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); +} +function foo2() { + { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + } + use(x); +} +var A = (function () { + function A() { + } + A.prototype.m1 = function () { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + }; + A.prototype.m2 = function () { + { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + } + use(x); + }; + return A; +})(); +var B = (function () { + function B() { + } + B.prototype.m1 = function () { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + }; + B.prototype.m2 = function () { + { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + } + use(x); + }; + return B; +})(); +function bar1() { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); +} +function bar2() { + { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + } + use(x); +} +var M1; +(function (M1) { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); +})(M1 || (M1 = {})); +var M2; +(function (M2) { + { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + } + use(x); +})(M2 || (M2 = {})); +var M3; +(function (M3) { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); +})(M3 || (M3 = {})); +var M4; +(function (M4) { + { + var _x = 1; + use(_x); + var _y = ([1])[0]; + use(_y); + var _z = ({ a: 1 }).a; + use(_z); + } + use(x); + use(y); + use(z); +})(M4 || (M4 = {})); +function foo3() { + for (var _x = void 0;;) { + use(_x); + } + for (var _y = ([])[0];;) { + use(_y); + } + for (var _z = ({ a: 1 }).a;;) { + use(_z); + } + use(x); +} +function foo4() { + for (var _x = 1;;) { + use(_x); + } + for (var _y = ([])[0];;) { + use(_y); + } + for (var _z = ({ a: 1 }).a;;) { + use(_z); + } + use(x); +} +function foo5() { + for (var _x in []) { + use(_x); + } + use(x); +} +function foo6() { + for (var _x in []) { + use(_x); + } + use(x); +} +// TODO: once for-of is supported downlevel +function foo7() { + for (var _x of []) { + use(_x); + } + use(x); +} +function foo8() { + for (var _x = (void 0)[0] of []) { + use(_x); + } + use(x); +} +function foo9() { + for (var _x = (void 0).a of []) { + use(_x); + } + use(x); +} +function foo10() { + for (var _x of []) { + use(_x); + } + use(x); +} +function foo11() { + for (var _x = (void 0)[0] of []) { + use(_x); + } + use(x); +} +function foo12() { + for (var _x = (void 0).a of []) { + use(_x); + } + use(x); +} diff --git a/tests/baselines/reference/downlevelLetConst17.errors.txt b/tests/baselines/reference/downlevelLetConst17.errors.txt new file mode 100644 index 00000000000..a185ca4abe1 --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst17.errors.txt @@ -0,0 +1,74 @@ +tests/cases/compiler/downlevelLetConst17.ts(66,1): error TS9003: 'for...of' statements are not currently supported. + + +==== tests/cases/compiler/downlevelLetConst17.ts (1 errors) ==== + 'use strict' + + declare function use(a: any); + + var x; + for (let x = 10; ;) { + use(x); + } + use(x); + + for (const x = 10; ;) { + use(x); + } + + for (; ;) { + let x = 10; + use(x); + x = 1; + } + + for (; ;) { + const x = 10; + use(x); + } + + for (let x; ;) { + use(x); + x = 1; + } + + for (; ;) { + let x; + use(x); + x = 1; + } + + while (true) { + let x; + use(x); + } + + while (true) { + const x = true; + use(x); + } + + do { + let x; + use(x); + } while (true); + + do { + let x; + use(x); + } while (true); + + for (let x in []) { + use(x); + } + + for (const x in []) { + use(x); + } + + // TODO: update once for-of statements are supported downlevel + for (const x of []) { + ~~~ +!!! error TS9003: 'for...of' statements are not currently supported. + use(x); + } \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst17.js b/tests/baselines/reference/downlevelLetConst17.js new file mode 100644 index 00000000000..1fe9c1a01ed --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst17.js @@ -0,0 +1,124 @@ +//// [downlevelLetConst17.ts] +'use strict' + +declare function use(a: any); + +var x; +for (let x = 10; ;) { + use(x); +} +use(x); + +for (const x = 10; ;) { + use(x); +} + +for (; ;) { + let x = 10; + use(x); + x = 1; +} + +for (; ;) { + const x = 10; + use(x); +} + +for (let x; ;) { + use(x); + x = 1; +} + +for (; ;) { + let x; + use(x); + x = 1; +} + +while (true) { + let x; + use(x); +} + +while (true) { + const x = true; + use(x); +} + +do { + let x; + use(x); +} while (true); + +do { + let x; + use(x); +} while (true); + +for (let x in []) { + use(x); +} + +for (const x in []) { + use(x); +} + +// TODO: update once for-of statements are supported downlevel +for (const x of []) { + use(x); +} + +//// [downlevelLetConst17.js] +'use strict'; +var x; +for (var _x = 10;;) { + use(_x); +} +use(x); +for (var _x_1 = 10;;) { + use(_x_1); +} +for (;;) { + var _x_2 = 10; + use(_x_2); + _x_2 = 1; +} +for (;;) { + var _x_3 = 10; + use(_x_3); +} +for (var _x_4 = void 0;;) { + use(_x_4); + _x_4 = 1; +} +for (;;) { + var _x_5 = void 0; + use(_x_5); + _x_5 = 1; +} +while (true) { + var _x_6 = void 0; + use(_x_6); +} +while (true) { + var _x_7 = true; + use(_x_7); +} +do { + var _x_8 = void 0; + use(_x_8); +} while (true); +do { + var _x_9 = void 0; + use(_x_9); +} while (true); +for (var _x_10 in []) { + use(_x_10); +} +for (var _x_11 in []) { + use(_x_11); +} +// TODO: update once for-of statements are supported downlevel +for (var _x_12 of []) { + use(_x_12); +} diff --git a/tests/baselines/reference/downlevelLetConst18.errors.txt b/tests/baselines/reference/downlevelLetConst18.errors.txt new file mode 100644 index 00000000000..93a2578defa --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst18.errors.txt @@ -0,0 +1,60 @@ +tests/cases/compiler/downlevelLetConst18.ts(3,1): error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively 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: Code in the loop captures block-scoped variable 'x' in closure. This is natively 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: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(15,1): error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(19,1): error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(23,1): error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +tests/cases/compiler/downlevelLetConst18.ts(27,1): error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. + + +==== tests/cases/compiler/downlevelLetConst18.ts (9 errors) ==== + 'use strict' + + for (let x; ;) { + ~~~ +!!! error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. + function foo() { x }; + ~~~ +!!! error TS2393: Duplicate function implementation. + } + + for (let x; ;) { + ~~~ +!!! error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. + function foo() { x }; + ~~~ +!!! error TS2393: Duplicate function implementation. + } + + for (let x; ;) { + ~~~ +!!! error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. + (() => { x })(); + } + + for (const x = 1; ;) { + ~~~ +!!! error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. + (() => { x })(); + } + + for (let x; ;) { + ~~~ +!!! error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. + ({ foo() { x }}) + } + + for (let x; ;) { + ~~~ +!!! error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. + ({ get foo() { return x } }) + } + + for (let x; ;) { + ~~~ +!!! error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. + ({ set foo(v) { x } }) + } + \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst18.js b/tests/baselines/reference/downlevelLetConst18.js new file mode 100644 index 00000000000..e9993a90bce --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst18.js @@ -0,0 +1,57 @@ +//// [downlevelLetConst18.ts] +'use strict' + +for (let x; ;) { + function foo() { x }; +} + +for (let x; ;) { + function foo() { x }; +} + +for (let x; ;) { + (() => { x })(); +} + +for (const x = 1; ;) { + (() => { x })(); +} + +for (let x; ;) { + ({ foo() { x }}) +} + +for (let x; ;) { + ({ get foo() { return x } }) +} + +for (let x; ;) { + ({ set foo(v) { x } }) +} + + +//// [downlevelLetConst18.js] +'use strict'; +for (var x = void 0;;) { + function foo() { x; } + ; +} +for (var _x = void 0;;) { + function foo() { _x; } + ; +} +for (var _x_1 = void 0;;) { + (function () { _x_1; })(); +} +for (var _x_2 = 1;;) { + (function () { _x_2; })(); +} +for (var _x_3 = void 0;;) { + ({ foo: function () { _x_3; } }); +} +for (var _x_4 = void 0;;) { + ({ get foo() { return _x_4; } }); +} +for (var _x_5 = void 0;;) { + ({ set foo(v) { _x_5; } }); +} diff --git a/tests/baselines/reference/parserES5ComputedPropertyName2.js b/tests/baselines/reference/parserES5ComputedPropertyName2.js index 2b39e305e07..b7fce15bc92 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName2.js +++ b/tests/baselines/reference/parserES5ComputedPropertyName2.js @@ -3,6 +3,5 @@ var v = { [e]: 1 }; //// [parserES5ComputedPropertyName2.js] var v = (_a = {}, _a[e] = -1, -_a); +1, _a); var _a; diff --git a/tests/baselines/reference/parserES5ComputedPropertyName3.js b/tests/baselines/reference/parserES5ComputedPropertyName3.js index 3247b0251f1..1fdb5ced65d 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName3.js +++ b/tests/baselines/reference/parserES5ComputedPropertyName3.js @@ -2,6 +2,5 @@ var v = { [e]() { } }; //// [parserES5ComputedPropertyName3.js] -var v = (_a = {}, _a[e] = function () { }, -_a); +var v = (_a = {}, _a[e] = function () { }, _a); var _a; diff --git a/tests/baselines/reference/parserES5ComputedPropertyName4.js b/tests/baselines/reference/parserES5ComputedPropertyName4.js index 436f967e8de..3271fa41207 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName4.js +++ b/tests/baselines/reference/parserES5ComputedPropertyName4.js @@ -2,6 +2,5 @@ var v = { get [e]() { } }; //// [parserES5ComputedPropertyName4.js] -var v = (_a = {}, _a[e] = Object.defineProperty({ get: function () { }, enumerable: true, configurable: true }), -_a); +var v = (_a = {}, _a[e] = Object.defineProperty({ get: function () { }, enumerable: true, configurable: true }), _a); var _a; diff --git a/tests/baselines/reference/privateIndexer2.js b/tests/baselines/reference/privateIndexer2.js index 5a36a9eae18..0c9112ba280 100644 --- a/tests/baselines/reference/privateIndexer2.js +++ b/tests/baselines/reference/privateIndexer2.js @@ -13,7 +13,6 @@ var y: { // private indexers not allowed var x = (_a = {}, _a[x] = string, _a.string = -, -_a); +, _a); var y; var _a; diff --git a/tests/cases/compiler/constDeclarations-errors.ts b/tests/cases/compiler/constDeclarations-errors.ts index 09dc0e96790..1c3ef8848b0 100644 --- a/tests/cases/compiler/constDeclarations-errors.ts +++ b/tests/cases/compiler/constDeclarations-errors.ts @@ -5,7 +5,6 @@ const c1; const c2: number; const c3, c4, c5 :string, c6; // error, missing initialicer -// error, can not be unintalized for(const c in {}) { } // error, assigning to a const diff --git a/tests/cases/compiler/downlevelLetConst12.ts b/tests/cases/compiler/downlevelLetConst12.ts new file mode 100644 index 00000000000..5acefcdf7bf --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst12.ts @@ -0,0 +1,12 @@ +// @target:es5 + +'use strict' +// top level let\const should not be renamed +let foo; +const bar = 1; + +let [baz] = []; +let {a: baz2} = { a: 1 }; + +const [baz3] = [] +const {a: baz4} = { a: 1 }; \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst13.ts b/tests/cases/compiler/downlevelLetConst13.ts new file mode 100644 index 00000000000..af803e079bc --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst13.ts @@ -0,0 +1,21 @@ +// @target:es5 +// @module: commonjs + +'use strict' +// exported let\const bindings should not be renamed + +export let foo = 10; +export const bar = "123" +export let [bar1] = [1]; +export const [bar2] = [2]; +export let {a: bar3} = { a: 1 }; +export const {a: bar4} = { a: 1 }; + +export module M { + export let baz = 100; + export const baz2 = true; + export let [bar5] = [1]; + export const [bar6] = [2]; + export let {a: bar7} = { a: 1 }; + export const {a: bar8} = { a: 1 }; +} \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst14.ts b/tests/cases/compiler/downlevelLetConst14.ts new file mode 100644 index 00000000000..0a778838096 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst14.ts @@ -0,0 +1,55 @@ +// @target:es5 +'use strict' +declare function use(a: any); + +var x = 10; +var z0, z1, z2, z3; +{ + let x = 20; + use(x); + + let [z0] = [1]; + use(z0); + let [z1] = [1] + use(z1); + let {a: z2} = { a: 1 }; + use(z2); + let {a: z3} = { a: 1 }; + use(z3); +} +use(x); +use(z0); +use(z1); +use(z2); +use(z3); +var z6; +var y = true; +{ + let y = ""; + let [z6] = [true] + { + let y = 1; + let {a: z6} = {a: 1} + use(y); + use(z6); + } + use(y); + use(z6); +} +use(y); +use(z6); + +var z = false; +var z5 = 1; +{ + let z = ""; + let [z5] = [5]; + { + let _z = 1; + let {a: _z5} = { a: 1 }; + // try to step on generated name + use(_z); + } + use(z); +} +use(y); \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst15.ts b/tests/cases/compiler/downlevelLetConst15.ts new file mode 100644 index 00000000000..abe06e1709b --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst15.ts @@ -0,0 +1,55 @@ +// @target:es5 +'use strict' +declare function use(a: any); + +var x = 10; +var z0, z1, z2, z3; +{ + const x = 20; + use(x); + + const [z0] = [1]; + use(z0); + const [{a: z1}] = [{a: 1}] + use(z1); + const {a: z2} = { a: 1 }; + use(z2); + const {a: {b: z3}} = { a: {b: 1} }; + use(z3); +} +use(x); +use(z0); +use(z1); +use(z2); +use(z3); +var z6; +var y = true; +{ + const y = ""; + const [z6] = [true] + { + const y = 1; + const {a: z6} = { a: 1 } + use(y); + use(z6); + } + use(y); + use(z6); +} +use(y); +use(z6); + +var z = false; +var z5 = 1; +{ + const z = ""; + const [z5] = [5]; + { + const _z = 1; + const {a: _z5} = { a: 1 }; + // try to step on generated name + use(_z); + } + use(z); +} +use(y); \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst16.ts b/tests/cases/compiler/downlevelLetConst16.ts new file mode 100644 index 00000000000..2d592d253c9 --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst16.ts @@ -0,0 +1,229 @@ +// @target:es5 +'use strict' + +declare function use(a: any); + +var x = 10; +var y; +var z; +use(x); +use(y); +use(z); +function foo1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = {a: 1}; + use(z); +} + +function foo2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); +} + +class A { + m1() { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + m2() { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); + } + +} + +class B { + m1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + m2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + } +} + +function bar1() { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); +} + +function bar2() { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); +} + +module M1 { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); +} + +module M2 { + { + let x = 1; + use(x); + let [y] = [1]; + use(y); + let {a: z} = { a: 1 }; + use(z); + } + use(x); +} + +module M3 { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + +} + +module M4 { + { + const x = 1; + use(x); + const [y] = [1]; + use(y); + const {a: z} = { a: 1 }; + use(z); + + } + use(x); + use(y); + use(z); +} + +function foo3() { + for (let x; ;) { + use(x); + } + for (let [y] = []; ;) { + use(y); + } + for (let {a: z} = {a: 1}; ;) { + use(z); + } + use(x); +} + +function foo4() { + for (const x = 1; ;) { + use(x); + } + for (const [y] = []; ;) { + use(y); + } + for (const {a: z} = { a: 1 }; ;) { + use(z); + } + use(x); +} + +function foo5() { + for (let x in []) { + use(x); + } + use(x); +} + +function foo6() { + for (const x in []) { + use(x); + } + use(x); +} + +// TODO: once for-of is supported downlevel +function foo7() { + for (let x of []) { + use(x); + } + use(x); +} + +function foo8() { + for (let [x] of []) { + use(x); + } + use(x); +} + +function foo9() { + for (let {a: x} of []) { + use(x); + } + use(x); +} + +function foo10() { + for (const x of []) { + use(x); + } + use(x); +} + +function foo11() { + for (const [x] of []) { + use(x); + } + use(x); +} + +function foo12() { + for (const {a: x} of []) { + use(x); + } + use(x); +} \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst17.ts b/tests/cases/compiler/downlevelLetConst17.ts new file mode 100644 index 00000000000..5cbb7b605fe --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst17.ts @@ -0,0 +1,69 @@ +// @target:es5 +'use strict' + +declare function use(a: any); + +var x; +for (let x = 10; ;) { + use(x); +} +use(x); + +for (const x = 10; ;) { + use(x); +} + +for (; ;) { + let x = 10; + use(x); + x = 1; +} + +for (; ;) { + const x = 10; + use(x); +} + +for (let x; ;) { + use(x); + x = 1; +} + +for (; ;) { + let x; + use(x); + x = 1; +} + +while (true) { + let x; + use(x); +} + +while (true) { + const x = true; + use(x); +} + +do { + let x; + use(x); +} while (true); + +do { + let x; + use(x); +} while (true); + +for (let x in []) { + use(x); +} + +for (const x in []) { + use(x); +} + +// TODO: update once for-of statements are supported downlevel +for (const x of []) { + use(x); +} \ No newline at end of file diff --git a/tests/cases/compiler/downlevelLetConst18.ts b/tests/cases/compiler/downlevelLetConst18.ts new file mode 100644 index 00000000000..59f2ee7a46e --- /dev/null +++ b/tests/cases/compiler/downlevelLetConst18.ts @@ -0,0 +1,30 @@ +// @target:es5 +'use strict' + +for (let x; ;) { + function foo() { x }; +} + +for (let x; ;) { + function foo() { x }; +} + +for (let x; ;) { + (() => { x })(); +} + +for (const x = 1; ;) { + (() => { x })(); +} + +for (let x; ;) { + ({ foo() { x }}) +} + +for (let x; ;) { + ({ get foo() { return x } }) +} + +for (let x; ;) { + ({ set foo(v) { x } }) +} From 11772e75a7bc3c091ad97fd752ee56053deba58e Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 26 Feb 2015 17:19:19 -0800 Subject: [PATCH 49/96] Simplify how catch clauses are represented in our AST. --- src/compiler/binder.ts | 11 +--- src/compiler/checker.ts | 55 ++++++++++--------- .../diagnosticInformationMap.generated.ts | 4 +- src/compiler/diagnosticMessages.json | 18 ++++-- src/compiler/emitter.ts | 8 +-- src/compiler/parser.ts | 10 ++-- src/compiler/types.ts | 5 +- src/compiler/utilities.ts | 18 +++++- .../baselines/reference/APISample_compile.js | 5 +- .../reference/APISample_compile.types | 14 ++--- tests/baselines/reference/APISample_linter.js | 5 +- .../reference/APISample_linter.types | 14 ++--- .../reference/APISample_transform.js | 5 +- .../reference/APISample_transform.types | 14 ++--- .../baselines/reference/APISample_watcher.js | 5 +- .../reference/APISample_watcher.types | 14 ++--- .../baselines/reference/bpSpan_stmts.baseline | 20 ++++++- .../reference/bpSpan_tryCatchFinally.baseline | 20 ++++++- .../catchClauseWithTypeAnnotation.errors.txt | 6 +- .../reference/invalidTryStatements.errors.txt | 18 +++--- ...rCatchClauseWithTypeAnnotation1.errors.txt | 6 +- .../fourslash/quickInfoOnCatchVariable.ts | 2 +- 22 files changed, 153 insertions(+), 124 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a9d8b5f895a..9e36fc3e662 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -342,14 +342,7 @@ module ts { } function bindCatchVariableDeclaration(node: CatchClause) { - var symbol = createSymbol(SymbolFlags.FunctionScopedVariable, node.name.text || "__missing"); - addDeclarationToSymbol(symbol, node, SymbolFlags.FunctionScopedVariable); - var saveParent = parent; - var savedBlockScopeContainer = blockScopeContainer; - parent = blockScopeContainer = node; - forEachChild(node, bind); - parent = saveParent; - blockScopeContainer = savedBlockScopeContainer; + bindChildren(node, /*symbolKind:*/ 0, /*isBlockScopeContainer:*/ true); } function bindBlockScopedVariableDeclaration(node: Declaration) { @@ -390,7 +383,7 @@ module ts { if (isBindingPattern((node).name)) { bindChildren(node, 0, /*isBlockScopeContainer*/ false); } - else if (getCombinedNodeFlags(node) & NodeFlags.BlockScoped) { + else if (isBlockOrCatchScoped(node)) { bindBlockScopedVariableDeclaration(node); } else { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 19a2dae2424..196871786e5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -416,13 +416,6 @@ module ts { break loop; } break; - case SyntaxKind.CatchClause: - var id = (location).name; - if (name === id.text) { - result = location.symbol; - break loop; - } - break; } lastLocation = location; location = location.parent; @@ -451,7 +444,8 @@ module ts { } if (result.flags & SymbolFlags.BlockScopedVariable) { // Block-scoped variables cannot be used before their definition - var declaration = forEach(result.declarations, d => getCombinedNodeFlags(d) & NodeFlags.BlockScoped ? d : undefined); + var declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) ? d : undefined); + Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); if (!isDefinedBefore(declaration, errorLocation)) { error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name)); @@ -1994,7 +1988,7 @@ module ts { } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.kind === SyntaxKind.CatchClause) { + if (declaration.parent.kind === SyntaxKind.CatchClause) { return links.type = anyType; } // Handle variable, parameter or property @@ -8926,18 +8920,29 @@ module ts { var catchClause = node.catchClause; if (catchClause) { // Grammar checking - if (catchClause.type) { - var sourceFile = getSourceFileOfNode(node); - var colonStart = skipTrivia(sourceFile.text, catchClause.name.end); - grammarErrorAtPos(sourceFile, colonStart, ":".length, Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation); + if (catchClause.variableDeclaration) { + if (catchClause.variableDeclaration.name.kind !== SyntaxKind.Identifier) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.name, Diagnostics.Catch_clause_variable_name_must_be_an_identifier); + } + else if (catchClause.variableDeclaration.type) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.type, Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); + } + else if (catchClause.variableDeclaration.initializer) { + grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, Diagnostics.Catch_clause_variable_cannot_have_an_initializer); + } + else { + // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the + // Catch production is eval or arguments + checkGrammarEvalOrArgumentsInStrictMode(node, catchClause.variableDeclaration.name); + } } - // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the - // Catch production is eval or arguments - checkGrammarEvalOrArgumentsInStrictMode(node, catchClause.name); checkBlock(catchClause.block); } - if (node.finallyBlock) checkBlock(node.finallyBlock); + + if (node.finallyBlock) { + checkBlock(node.finallyBlock); + } } function checkIndexConstraints(type: Type) { @@ -10049,11 +10054,6 @@ module ts { copySymbol(location.symbol, meaning); } break; - case SyntaxKind.CatchClause: - if ((location).name.text) { - copySymbol(location.symbol, meaning); - } - break; } memberFlags = location.flags; location = location.parent; @@ -11616,10 +11616,13 @@ module ts { } } - function checkGrammarEvalOrArgumentsInStrictMode(contextNode: Node, identifier: Identifier): boolean { - if (contextNode && (contextNode.parserContextFlags & ParserContextFlags.StrictMode) && isEvalOrArgumentsIdentifier(identifier)) { - var name = declarationNameToString(identifier); - return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_in_strict_mode, name); + function checkGrammarEvalOrArgumentsInStrictMode(contextNode: Node, name: Node): boolean { + if (name && name.kind === SyntaxKind.Identifier) { + var identifier = name; + if (contextNode && (contextNode.parserContextFlags & ParserContextFlags.StrictMode) && isEvalOrArgumentsIdentifier(identifier)) { + var nameText = declarationNameToString(identifier); + return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_in_strict_mode, nameText); + } } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 7c53d70f591..88ae6eda361 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -9,7 +9,6 @@ module ts { Trailing_comma_not_allowed: { code: 1009, category: DiagnosticCategory.Error, key: "Trailing comma not allowed." }, Asterisk_Slash_expected: { code: 1010, category: DiagnosticCategory.Error, key: "'*/' expected." }, Unexpected_token: { code: 1012, category: DiagnosticCategory.Error, key: "Unexpected token." }, - Catch_clause_parameter_cannot_have_a_type_annotation: { code: 1013, category: DiagnosticCategory.Error, key: "Catch clause parameter cannot have a type annotation." }, A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list." }, Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer." }, A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter." }, @@ -153,6 +152,9 @@ module ts { External_module_0_has_no_default_export_or_export_assignment: { code: 1192, category: DiagnosticCategory.Error, key: "External module '{0}' has no default export or export assignment." }, An_export_declaration_cannot_have_modifiers: { code: 1193, category: DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: DiagnosticCategory.Error, key: "Export declarations are not permitted in an internal module." }, + Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, + Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." }, + Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 7a7efe4e43c..e78ae2dad27 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -27,10 +27,6 @@ "category": "Error", "code": 1012 }, - "Catch clause parameter cannot have a type annotation.": { - "category": "Error", - "code": 1013 - }, "A rest parameter must be last in a parameter list.": { "category": "Error", "code": 1014 @@ -603,6 +599,18 @@ "category": "Error", "code": 1194 }, + "Catch clause variable name must be an identifier.": { + "category": "Error", + "code": 1195 + }, + "Catch clause variable cannot have a type annotation.": { + "category": "Error", + "code": 1196 + }, + "Catch clause variable cannot have an initializer.": { + "category": "Error", + "code": 1197 + }, "Duplicate identifier '{0}'.": { "category": "Error", @@ -1572,7 +1580,7 @@ "Exported type alias '{0}' has or is using private name '{1}'.": { "category": "Error", "code": 4081 - }, + }, "The current host does not support the '{0}' option.": { "category": "Error", "code": 5001 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index e57255a776b..444b1dd508f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2461,8 +2461,8 @@ module ts { return false; case SyntaxKind.LabeledStatement: return (node.parent).label === node; - case SyntaxKind.CatchClause: - return (node.parent).name === node; + //case SyntaxKind.CatchClause: + // return (node.parent).name === node; } } @@ -3428,8 +3428,8 @@ module ts { var endPos = emitToken(SyntaxKind.CatchKeyword, node.pos); write(" "); emitToken(SyntaxKind.OpenParenToken, endPos); - emit(node.name); - emitToken(SyntaxKind.CloseParenToken, node.name.end); + emit(node.variableDeclaration); + emitToken(SyntaxKind.CloseParenToken, node.variableDeclaration ? node.variableDeclaration.end : endPos); write(" "); emitBlock(node.block); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 9dc8a475527..ff22f857cad 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -222,8 +222,7 @@ module ts { visitNode(cbNode, (node).catchClause) || visitNode(cbNode, (node).finallyBlock); case SyntaxKind.CatchClause: - return visitNode(cbNode, (node).name) || - visitNode(cbNode, (node).type) || + return visitNode(cbNode, (node).variableDeclaration) || visitNode(cbNode, (node).block); case SyntaxKind.ClassDeclaration: return visitNodes(cbNodes, node.modifiers) || @@ -3973,9 +3972,10 @@ module ts { function parseCatchClause(): CatchClause { var result = createNode(SyntaxKind.CatchClause); parseExpected(SyntaxKind.CatchKeyword); - parseExpected(SyntaxKind.OpenParenToken); - result.name = parseIdentifier(); - result.type = parseTypeAnnotation(); + if (parseExpected(SyntaxKind.OpenParenToken)) { + result.variableDeclaration = parseVariableDeclaration(); + } + parseExpected(SyntaxKind.CloseParenToken); result.block = parseBlock(/*ignoreMissingOpenBrace:*/ false, /*checkForStrictMode:*/ false); return finishNode(result); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d1730ce1f1b..da8e1bdbe40 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -814,9 +814,8 @@ module ts { finallyBlock?: Block; } - export interface CatchClause extends Declaration { - name: Identifier; - type?: TypeNode; + export interface CatchClause extends Node { + variableDeclaration: VariableDeclaration; block: Block; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a6923e1eb94..dde0cece723 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -192,6 +192,18 @@ module ts { return getBaseFileName(moduleName).replace(/\W/g, "_"); } + export function isBlockOrCatchScoped(declaration: Declaration) { + return (getCombinedNodeFlags(declaration) & NodeFlags.BlockScoped) !== 0 || + isCatchClauseVariableDeclaration(declaration); + } + + export function isCatchClauseVariableDeclaration(declaration: Declaration) { + return declaration && + declaration.kind === SyntaxKind.VariableDeclaration && + declaration.parent && + declaration.parent.kind === SyntaxKind.CatchClause; + } + // Return display name of an identifier // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. @@ -757,9 +769,9 @@ module ts { return (parent).name === name; } - if (parent.kind === SyntaxKind.CatchClause) { - return (parent).name === name; - } + //if (parent.kind === SyntaxKind.CatchClause) { + // return (parent).name === name; + //} return false; } diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 5381b327504..7f5bc29906a 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -673,9 +673,8 @@ declare module "typescript" { catchClause?: CatchClause; finallyBlock?: Block; } - interface CatchClause extends Declaration { - name: Identifier; - type?: TypeNode; + interface CatchClause extends Node { + variableDeclaration: VariableDeclaration; block: Block; } interface ModuleElement extends Node { diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index 106fa45e424..d93a48b7852 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -2030,17 +2030,13 @@ declare module "typescript" { >finallyBlock : Block >Block : Block } - interface CatchClause extends Declaration { + interface CatchClause extends Node { >CatchClause : CatchClause ->Declaration : Declaration +>Node : Node - name: Identifier; ->name : Identifier ->Identifier : Identifier - - type?: TypeNode; ->type : TypeNode ->TypeNode : TypeNode + variableDeclaration: VariableDeclaration; +>variableDeclaration : VariableDeclaration +>VariableDeclaration : VariableDeclaration block: Block; >block : Block diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 47183c920b4..36dd2421add 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -704,9 +704,8 @@ declare module "typescript" { catchClause?: CatchClause; finallyBlock?: Block; } - interface CatchClause extends Declaration { - name: Identifier; - type?: TypeNode; + interface CatchClause extends Node { + variableDeclaration: VariableDeclaration; block: Block; } interface ModuleElement extends Node { diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 776e7c0bbc1..7a282b61f42 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -2176,17 +2176,13 @@ declare module "typescript" { >finallyBlock : Block >Block : Block } - interface CatchClause extends Declaration { + interface CatchClause extends Node { >CatchClause : CatchClause ->Declaration : Declaration +>Node : Node - name: Identifier; ->name : Identifier ->Identifier : Identifier - - type?: TypeNode; ->type : TypeNode ->TypeNode : TypeNode + variableDeclaration: VariableDeclaration; +>variableDeclaration : VariableDeclaration +>VariableDeclaration : VariableDeclaration block: Block; >block : Block diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index ea323ba927f..2ead5140261 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -705,9 +705,8 @@ declare module "typescript" { catchClause?: CatchClause; finallyBlock?: Block; } - interface CatchClause extends Declaration { - name: Identifier; - type?: TypeNode; + interface CatchClause extends Node { + variableDeclaration: VariableDeclaration; block: Block; } interface ModuleElement extends Node { diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index 9abc0385d07..7a9d0523653 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -2126,17 +2126,13 @@ declare module "typescript" { >finallyBlock : Block >Block : Block } - interface CatchClause extends Declaration { + interface CatchClause extends Node { >CatchClause : CatchClause ->Declaration : Declaration +>Node : Node - name: Identifier; ->name : Identifier ->Identifier : Identifier - - type?: TypeNode; ->type : TypeNode ->TypeNode : TypeNode + variableDeclaration: VariableDeclaration; +>variableDeclaration : VariableDeclaration +>VariableDeclaration : VariableDeclaration block: Block; >block : Block diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 3e80b34ba0e..1d1f9f03d68 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -742,9 +742,8 @@ declare module "typescript" { catchClause?: CatchClause; finallyBlock?: Block; } - interface CatchClause extends Declaration { - name: Identifier; - type?: TypeNode; + interface CatchClause extends Node { + variableDeclaration: VariableDeclaration; block: Block; } interface ModuleElement extends Node { diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 79c2177ce79..55c48d1354b 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -2299,17 +2299,13 @@ declare module "typescript" { >finallyBlock : Block >Block : Block } - interface CatchClause extends Declaration { + interface CatchClause extends Node { >CatchClause : CatchClause ->Declaration : Declaration +>Node : Node - name: Identifier; ->name : Identifier ->Identifier : Identifier - - type?: TypeNode; ->type : TypeNode ->TypeNode : TypeNode + variableDeclaration: VariableDeclaration; +>variableDeclaration : VariableDeclaration +>VariableDeclaration : VariableDeclaration block: Block; >block : Block diff --git a/tests/baselines/reference/bpSpan_stmts.baseline b/tests/baselines/reference/bpSpan_stmts.baseline index a81559ee9a5..7f6bf21b40b 100644 --- a/tests/baselines/reference/bpSpan_stmts.baseline +++ b/tests/baselines/reference/bpSpan_stmts.baseline @@ -217,7 +217,15 @@ >:=> (line 28, col 8) to (line 28, col 22) 29 > } catch (e) { - ~~~~~~~~~~~~~ => Pos: (416 to 428) SpanInfo: {"start":437,"length":15} + ~~~~~~~~ => Pos: (416 to 423) SpanInfo: {"start":437,"length":15} + >if (obj.z < 10) + >:=> (line 30, col 8) to (line 30, col 23) +29 > } catch (e) { + + ~ => Pos: (424 to 424) SpanInfo: undefined +29 > } catch (e) { + + ~~~~ => Pos: (425 to 428) SpanInfo: {"start":437,"length":15} >if (obj.z < 10) >:=> (line 30, col 8) to (line 30, col 23) -------------------------------- @@ -286,7 +294,15 @@ >:=> (line 37, col 8) to (line 37, col 25) 38 > } catch (e1) { - ~~~~~~~~~~~~~~ => Pos: (581 to 594) SpanInfo: {"start":603,"length":10} + ~~~~~~~~ => Pos: (581 to 588) SpanInfo: {"start":603,"length":10} + >var b = e1 + >:=> (line 39, col 8) to (line 39, col 18) +38 > } catch (e1) { + + ~~ => Pos: (589 to 590) SpanInfo: undefined +38 > } catch (e1) { + + ~~~~ => Pos: (591 to 594) SpanInfo: {"start":603,"length":10} >var b = e1 >:=> (line 39, col 8) to (line 39, col 18) -------------------------------- diff --git a/tests/baselines/reference/bpSpan_tryCatchFinally.baseline b/tests/baselines/reference/bpSpan_tryCatchFinally.baseline index 5a9e569f403..e5465b8812c 100644 --- a/tests/baselines/reference/bpSpan_tryCatchFinally.baseline +++ b/tests/baselines/reference/bpSpan_tryCatchFinally.baseline @@ -24,7 +24,15 @@ >:=> (line 3, col 4) to (line 3, col 13) 4 >} catch (e) { - ~~~~~~~~~~~~~ => Pos: (34 to 46) SpanInfo: {"start":51,"length":9} + ~~~~~~~~ => Pos: (34 to 41) SpanInfo: {"start":51,"length":9} + >x = x - 1 + >:=> (line 5, col 4) to (line 5, col 13) +4 >} catch (e) { + + ~ => Pos: (42 to 42) SpanInfo: undefined +4 >} catch (e) { + + ~~~~ => Pos: (43 to 46) SpanInfo: {"start":51,"length":9} >x = x - 1 >:=> (line 5, col 4) to (line 5, col 13) -------------------------------- @@ -94,7 +102,15 @@ -------------------------------- 14 >catch (e) - ~~~~~~~~~~ => Pos: (138 to 147) SpanInfo: {"start":154,"length":9} + ~~~~~~~ => Pos: (138 to 144) SpanInfo: {"start":154,"length":9} + >x = x - 1 + >:=> (line 16, col 4) to (line 16, col 13) +14 >catch (e) + + ~ => Pos: (145 to 145) SpanInfo: undefined +14 >catch (e) + + ~~ => Pos: (146 to 147) SpanInfo: {"start":154,"length":9} >x = x - 1 >:=> (line 16, col 4) to (line 16, col 13) -------------------------------- diff --git a/tests/baselines/reference/catchClauseWithTypeAnnotation.errors.txt b/tests/baselines/reference/catchClauseWithTypeAnnotation.errors.txt index d3eea6619b6..5bc7339d2fc 100644 --- a/tests/baselines/reference/catchClauseWithTypeAnnotation.errors.txt +++ b/tests/baselines/reference/catchClauseWithTypeAnnotation.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/catchClauseWithTypeAnnotation.ts(2,11): error TS1013: Catch clause parameter cannot have a type annotation. +tests/cases/compiler/catchClauseWithTypeAnnotation.ts(2,13): error TS1196: Catch clause variable cannot have a type annotation. ==== tests/cases/compiler/catchClauseWithTypeAnnotation.ts (1 errors) ==== try { } catch (e: any) { - ~ -!!! error TS1013: Catch clause parameter cannot have a type annotation. + ~~~ +!!! error TS1196: Catch clause variable cannot have a type annotation. } \ No newline at end of file diff --git a/tests/baselines/reference/invalidTryStatements.errors.txt b/tests/baselines/reference/invalidTryStatements.errors.txt index 4dacdb8f4b6..a2f8a7bac0c 100644 --- a/tests/baselines/reference/invalidTryStatements.errors.txt +++ b/tests/baselines/reference/invalidTryStatements.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/statements/tryStatements/invalidTryStatements.ts(8,21): error TS1013: Catch clause parameter cannot have a type annotation. -tests/cases/conformance/statements/tryStatements/invalidTryStatements.ts(9,21): error TS1013: Catch clause parameter cannot have a type annotation. -tests/cases/conformance/statements/tryStatements/invalidTryStatements.ts(10,21): error TS1013: Catch clause parameter cannot have a type annotation. +tests/cases/conformance/statements/tryStatements/invalidTryStatements.ts(8,23): error TS1196: Catch clause variable cannot have a type annotation. +tests/cases/conformance/statements/tryStatements/invalidTryStatements.ts(9,23): error TS1196: Catch clause variable cannot have a type annotation. +tests/cases/conformance/statements/tryStatements/invalidTryStatements.ts(10,23): error TS1196: Catch clause variable cannot have a type annotation. ==== tests/cases/conformance/statements/tryStatements/invalidTryStatements.ts (3 errors) ==== @@ -12,14 +12,14 @@ tests/cases/conformance/statements/tryStatements/invalidTryStatements.ts(10,21): // no type annotation allowed try { } catch (z: any) { } - ~ -!!! error TS1013: Catch clause parameter cannot have a type annotation. + ~~~ +!!! error TS1196: Catch clause variable cannot have a type annotation. try { } catch (a: number) { } - ~ -!!! error TS1013: Catch clause parameter cannot have a type annotation. + ~~~~~~ +!!! error TS1196: Catch clause variable cannot have a type annotation. try { } catch (y: string) { } - ~ -!!! error TS1013: Catch clause parameter cannot have a type annotation. + ~~~~~~ +!!! error TS1196: Catch clause variable cannot have a type annotation. } \ No newline at end of file diff --git a/tests/baselines/reference/parserCatchClauseWithTypeAnnotation1.errors.txt b/tests/baselines/reference/parserCatchClauseWithTypeAnnotation1.errors.txt index 73b97ac5573..a1f1d1fd6c7 100644 --- a/tests/baselines/reference/parserCatchClauseWithTypeAnnotation1.errors.txt +++ b/tests/baselines/reference/parserCatchClauseWithTypeAnnotation1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/CatchClauses/parserCatchClauseWithTypeAnnotation1.ts(2,11): error TS1013: Catch clause parameter cannot have a type annotation. +tests/cases/conformance/parser/ecmascript5/CatchClauses/parserCatchClauseWithTypeAnnotation1.ts(2,13): error TS1196: Catch clause variable cannot have a type annotation. ==== tests/cases/conformance/parser/ecmascript5/CatchClauses/parserCatchClauseWithTypeAnnotation1.ts (1 errors) ==== try { } catch (e: Error) { - ~ -!!! error TS1013: Catch clause parameter cannot have a type annotation. + ~~~~~ +!!! error TS1196: Catch clause variable cannot have a type annotation. } \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoOnCatchVariable.ts b/tests/cases/fourslash/quickInfoOnCatchVariable.ts index d03b5d7b8b6..5d0af595e91 100644 --- a/tests/cases/fourslash/quickInfoOnCatchVariable.ts +++ b/tests/cases/fourslash/quickInfoOnCatchVariable.ts @@ -6,4 +6,4 @@ goTo.marker(); verify.quickInfoExists(); -verify.quickInfoIs("(var) e: any"); +verify.quickInfoIs("(local var) e: any"); From 4bf0bb640579000bcb5c4a531c5654ee1774bb59 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 26 Feb 2015 17:19:47 -0800 Subject: [PATCH 50/96] added comments --- src/compiler/checker.ts | 4 ++-- src/compiler/emitter.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fd3d2141dc0..46d7dc5d382 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -280,7 +280,7 @@ module ts { Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; - } + } if (symbol.flags & SymbolFlags.Import) { var target = resolveImport(symbol); @@ -10716,7 +10716,7 @@ module ts { } function isUnknownIdentifier(location: Node, name: string): boolean { - return !resolveName(location, name, SymbolFlags.Value | SymbolFlags.Import, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined) && + return !resolveName(location, name, SymbolFlags.Value, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined) && !hasProperty(getGeneratedNamesForSourceFile(getSourceFile(location)), name); } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 1cfbbd20096..a887df0dcc5 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -33,11 +33,17 @@ module ts { trailingCommentRanges?: CommentRange[]; } + // represents one LexicalEnvironment frame to store unique generated names interface ScopeFrame { names: Map; previous: ScopeFrame; } + // isExisingName function has signature string -> boolean, however check if name is unique should be performed + // in the context of some location. Instead of creating function expression and closing over location + // every time isExisingName is called we use one single instance of NameLookup that is effectively a + // handrolled closure where value of location can be swapped. This allows to avoid allocations of closures on + // every call and use one shared instance instead interface NameLookup { setLocation(location: Node): void; isExistingName(name: string): boolean; @@ -1663,6 +1669,8 @@ 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; @@ -1683,6 +1691,8 @@ module ts { } } + // creates instance of NameLookup to be used in 'isExisingName' checks. + // see comment for NameLookup for more information function createNameLookup(): NameLookup { var location: Node; return { From 9125aa5192071774172c89d29a647dd97e46eeea Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 26 Feb 2015 17:26:33 -0800 Subject: [PATCH 51/96] Rename method. --- src/compiler/checker.ts | 6 +++--- src/compiler/utilities.ts | 6 +----- src/services/services.ts | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 196871786e5..918090b3a94 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10190,7 +10190,7 @@ module ts { } function getSymbolOfEntityNameOrPropertyAccessExpression(entityName: EntityName | PropertyAccessExpression): Symbol { - if (isDeclarationOrCatchVariableName(entityName)) { + if (isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } @@ -10255,7 +10255,7 @@ module ts { return undefined; } - if (isDeclarationOrCatchVariableName(node)) { + if (isDeclarationName(node)) { // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } @@ -10351,7 +10351,7 @@ module ts { return getTypeOfSymbol(symbol); } - if (isDeclarationOrCatchVariableName(node)) { + if (isDeclarationName(node)) { var symbol = getSymbolInfo(node); return symbol && getTypeOfSymbol(symbol); } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index dde0cece723..01def791c02 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -753,7 +753,7 @@ module ts { } // True if the given identifier, string literal, or number literal is the name of a declaration node - export function isDeclarationOrCatchVariableName(name: Node): boolean { + export function isDeclarationName(name: Node): boolean { if (name.kind !== SyntaxKind.Identifier && name.kind !== SyntaxKind.StringLiteral && name.kind !== SyntaxKind.NumericLiteral) { return false; } @@ -769,10 +769,6 @@ module ts { return (parent).name === name; } - //if (parent.kind === SyntaxKind.CatchClause) { - // return (parent).name === name; - //} - return false; } diff --git a/src/services/services.ts b/src/services/services.ts index 5ee623fd3fa..c13ae22718b 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4756,7 +4756,7 @@ module ts { /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node: Node): boolean { - if (node.kind === SyntaxKind.Identifier && isDeclarationOrCatchVariableName(node)) { + if (node.kind === SyntaxKind.Identifier && isDeclarationName(node)) { return true; } @@ -4918,7 +4918,7 @@ module ts { else if (isInRightSideOfImport(node)) { return getMeaningFromRightHandSideOfImportEquals(node); } - else if (isDeclarationOrCatchVariableName(node)) { + else if (isDeclarationName(node)) { return getMeaningFromDeclaration(node.parent); } else if (isTypeReference(node)) { From e2d9ea51eb615023dcaa18f5ca250f63cf8cf737 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 26 Feb 2015 17:27:18 -0800 Subject: [PATCH 52/96] Add test for catch variables with initializers. --- .../reference/catchClauseWithInitializer1.errors.txt | 10 ++++++++++ .../reference/catchClauseWithInitializer1.js | 11 +++++++++++ tests/cases/compiler/catchClauseWithInitializer1.ts | 4 ++++ 3 files changed, 25 insertions(+) create mode 100644 tests/baselines/reference/catchClauseWithInitializer1.errors.txt create mode 100644 tests/baselines/reference/catchClauseWithInitializer1.js create mode 100644 tests/cases/compiler/catchClauseWithInitializer1.ts diff --git a/tests/baselines/reference/catchClauseWithInitializer1.errors.txt b/tests/baselines/reference/catchClauseWithInitializer1.errors.txt new file mode 100644 index 00000000000..b13644f4d83 --- /dev/null +++ b/tests/baselines/reference/catchClauseWithInitializer1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/catchClauseWithInitializer1.ts(3,12): error TS1197: Catch clause variable cannot have an initializer. + + +==== tests/cases/compiler/catchClauseWithInitializer1.ts (1 errors) ==== + try { + } + catch (e = 1) { + ~ +!!! error TS1197: Catch clause variable cannot have an initializer. + } \ No newline at end of file diff --git a/tests/baselines/reference/catchClauseWithInitializer1.js b/tests/baselines/reference/catchClauseWithInitializer1.js new file mode 100644 index 00000000000..5cb89a567f1 --- /dev/null +++ b/tests/baselines/reference/catchClauseWithInitializer1.js @@ -0,0 +1,11 @@ +//// [catchClauseWithInitializer1.ts] +try { +} +catch (e = 1) { +} + +//// [catchClauseWithInitializer1.js] +try { +} +catch (e = 1) { +} diff --git a/tests/cases/compiler/catchClauseWithInitializer1.ts b/tests/cases/compiler/catchClauseWithInitializer1.ts new file mode 100644 index 00000000000..320a2813170 --- /dev/null +++ b/tests/cases/compiler/catchClauseWithInitializer1.ts @@ -0,0 +1,4 @@ +try { +} +catch (e = 1) { +} \ No newline at end of file From 27e888284dd925a09be3a3f7c1b88b11d9bc6b8a Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 26 Feb 2015 17:37:01 -0800 Subject: [PATCH 53/96] CR feedback. --- src/compiler/emitter.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 444b1dd508f..e922803c0d4 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2461,8 +2461,6 @@ module ts { return false; case SyntaxKind.LabeledStatement: return (node.parent).label === node; - //case SyntaxKind.CatchClause: - // return (node.parent).name === node; } } From 7b7f49725d7b51bebdbb5acccc3caefc3fc7ce9d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 26 Feb 2015 17:42:46 -0800 Subject: [PATCH 54/96] Adding test. --- .../catchClauseWithBindingPattern1.errors.txt | 10 ++++++++++ .../reference/catchClauseWithBindingPattern1.js | 11 +++++++++++ .../cases/compiler/catchClauseWithBindingPattern1.ts | 4 ++++ 3 files changed, 25 insertions(+) create mode 100644 tests/baselines/reference/catchClauseWithBindingPattern1.errors.txt create mode 100644 tests/baselines/reference/catchClauseWithBindingPattern1.js create mode 100644 tests/cases/compiler/catchClauseWithBindingPattern1.ts diff --git a/tests/baselines/reference/catchClauseWithBindingPattern1.errors.txt b/tests/baselines/reference/catchClauseWithBindingPattern1.errors.txt new file mode 100644 index 00000000000..0b7482850e5 --- /dev/null +++ b/tests/baselines/reference/catchClauseWithBindingPattern1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/catchClauseWithBindingPattern1.ts(3,8): error TS1195: Catch clause variable name must be an identifier. + + +==== tests/cases/compiler/catchClauseWithBindingPattern1.ts (1 errors) ==== + try { + } + catch ({a}) { + ~ +!!! error TS1195: Catch clause variable name must be an identifier. + } \ No newline at end of file diff --git a/tests/baselines/reference/catchClauseWithBindingPattern1.js b/tests/baselines/reference/catchClauseWithBindingPattern1.js new file mode 100644 index 00000000000..bbdc259946c --- /dev/null +++ b/tests/baselines/reference/catchClauseWithBindingPattern1.js @@ -0,0 +1,11 @@ +//// [catchClauseWithBindingPattern1.ts] +try { +} +catch ({a}) { +} + +//// [catchClauseWithBindingPattern1.js] +try { +} +catch (a = (void 0).a) { +} diff --git a/tests/cases/compiler/catchClauseWithBindingPattern1.ts b/tests/cases/compiler/catchClauseWithBindingPattern1.ts new file mode 100644 index 00000000000..dbd0f81c576 --- /dev/null +++ b/tests/cases/compiler/catchClauseWithBindingPattern1.ts @@ -0,0 +1,4 @@ +try { +} +catch ({a}) { +} \ No newline at end of file From b6a4987103becb4e9cf16673ab4af8ea56fa7cd2 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 19 Feb 2015 16:36:48 -0800 Subject: [PATCH 55/96] Remove error disallowing for...of loops --- src/compiler/checker.ts | 2 -- src/compiler/diagnosticInformationMap.generated.ts | 1 - src/compiler/diagnosticMessages.json | 4 ---- .../reference/parserES5ForOfStatement1.d.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement10.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement11.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement12.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement13.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement14.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement15.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement16.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement18.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement2.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement21.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement3.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement4.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement5.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement6.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement7.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement8.errors.txt | 4 ++-- .../reference/parserES5ForOfStatement9.errors.txt | 4 ++-- .../reference/parserForOfStatement1.d.errors.txt | 4 ++-- .../baselines/reference/parserForOfStatement10.errors.txt | 8 -------- .../baselines/reference/parserForOfStatement11.errors.txt | 8 -------- .../baselines/reference/parserForOfStatement12.errors.txt | 8 -------- .../baselines/reference/parserForOfStatement13.errors.txt | 8 -------- .../baselines/reference/parserForOfStatement14.errors.txt | 8 -------- .../baselines/reference/parserForOfStatement15.errors.txt | 8 -------- .../baselines/reference/parserForOfStatement16.errors.txt | 8 -------- .../baselines/reference/parserForOfStatement18.errors.txt | 7 ------- .../baselines/reference/parserForOfStatement2.errors.txt | 6 +++--- .../baselines/reference/parserForOfStatement21.errors.txt | 6 +++--- .../baselines/reference/parserForOfStatement3.errors.txt | 6 +++--- .../baselines/reference/parserForOfStatement4.errors.txt | 6 +++--- .../baselines/reference/parserForOfStatement5.errors.txt | 6 +++--- .../baselines/reference/parserForOfStatement6.errors.txt | 6 +++--- .../baselines/reference/parserForOfStatement7.errors.txt | 6 +++--- .../baselines/reference/parserForOfStatement8.errors.txt | 8 -------- .../baselines/reference/parserForOfStatement9.errors.txt | 8 -------- 39 files changed, 59 insertions(+), 145 deletions(-) delete mode 100644 tests/baselines/reference/parserForOfStatement10.errors.txt delete mode 100644 tests/baselines/reference/parserForOfStatement11.errors.txt delete mode 100644 tests/baselines/reference/parserForOfStatement12.errors.txt delete mode 100644 tests/baselines/reference/parserForOfStatement13.errors.txt delete mode 100644 tests/baselines/reference/parserForOfStatement14.errors.txt delete mode 100644 tests/baselines/reference/parserForOfStatement15.errors.txt delete mode 100644 tests/baselines/reference/parserForOfStatement16.errors.txt delete mode 100644 tests/baselines/reference/parserForOfStatement18.errors.txt delete mode 100644 tests/baselines/reference/parserForOfStatement8.errors.txt delete mode 100644 tests/baselines/reference/parserForOfStatement9.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d666da91fe0..a92e77f6978 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11246,8 +11246,6 @@ module ts { } function checkGrammarForOfStatement(forOfStatement: ForOfStatement): boolean { - // Temporarily disallow for-of statements until type check work is complete. - return grammarErrorOnFirstToken(forOfStatement, Diagnostics.for_of_statements_are_not_currently_supported); if (languageVersion < ScriptTarget.ES6) { return grammarErrorOnFirstToken(forOfStatement, Diagnostics.for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher); } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 7c53d70f591..5f8be858627 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -471,6 +471,5 @@ module ts { yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." }, Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." }, The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 9002, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." }, - for_of_statements_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'for...of' statements are not currently supported." }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 7a7efe4e43c..b7102337ef6 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1877,9 +1877,5 @@ "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression.": { "category": "Error", "code": 9002 - }, - "'for...of' statements are not currently supported.": { - "category": "Error", - "code": 9003 } } diff --git a/tests/baselines/reference/parserES5ForOfStatement1.d.errors.txt b/tests/baselines/reference/parserES5ForOfStatement1.d.errors.txt index 9c1a39b1f4a..c280b597b2c 100644 --- a/tests/baselines/reference/parserES5ForOfStatement1.d.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement1.d.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement1.d.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement1.d.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement1.d.ts (1 errors) ==== for (var i of e) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement10.errors.txt b/tests/baselines/reference/parserES5ForOfStatement10.errors.txt index d7f411b1879..5cee7472d24 100644 --- a/tests/baselines/reference/parserES5ForOfStatement10.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement10.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement10.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement10.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement10.ts (1 errors) ==== for (const v of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement11.errors.txt b/tests/baselines/reference/parserES5ForOfStatement11.errors.txt index 48805a336c7..79b16ed1ad6 100644 --- a/tests/baselines/reference/parserES5ForOfStatement11.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement11.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement11.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement11.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement11.ts (1 errors) ==== for (const [a, b] of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement12.errors.txt b/tests/baselines/reference/parserES5ForOfStatement12.errors.txt index 3b9f242b975..cdb6db690cf 100644 --- a/tests/baselines/reference/parserES5ForOfStatement12.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement12.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement12.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement12.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement12.ts (1 errors) ==== for (const {a, b} of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement13.errors.txt b/tests/baselines/reference/parserES5ForOfStatement13.errors.txt index 8b8c8ce0868..9d97fd9e249 100644 --- a/tests/baselines/reference/parserES5ForOfStatement13.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement13.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement13.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement13.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement13.ts (1 errors) ==== for (let {a, b} of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement14.errors.txt b/tests/baselines/reference/parserES5ForOfStatement14.errors.txt index dc4db95270a..303439ec447 100644 --- a/tests/baselines/reference/parserES5ForOfStatement14.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement14.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement14.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement14.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement14.ts (1 errors) ==== for (let [a, b] of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement15.errors.txt b/tests/baselines/reference/parserES5ForOfStatement15.errors.txt index 07aa6dd5b37..f0eab288fa7 100644 --- a/tests/baselines/reference/parserES5ForOfStatement15.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement15.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement15.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement15.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement15.ts (1 errors) ==== for (var [a, b] of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement16.errors.txt b/tests/baselines/reference/parserES5ForOfStatement16.errors.txt index 15a3e4f7f0b..b9248140f33 100644 --- a/tests/baselines/reference/parserES5ForOfStatement16.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement16.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement16.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement16.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement16.ts (1 errors) ==== for (var {a, b} of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement18.errors.txt b/tests/baselines/reference/parserES5ForOfStatement18.errors.txt index fc314e51012..e123be9c4f7 100644 --- a/tests/baselines/reference/parserES5ForOfStatement18.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement18.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement18.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement18.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement18.ts (1 errors) ==== for (var of of of) { } ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. \ No newline at end of file +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement2.errors.txt b/tests/baselines/reference/parserES5ForOfStatement2.errors.txt index 347ae29ddb8..618e2f3f0ae 100644 --- a/tests/baselines/reference/parserES5ForOfStatement2.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement2.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement2.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement2.ts (1 errors) ==== for (var of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement21.errors.txt b/tests/baselines/reference/parserES5ForOfStatement21.errors.txt index 2ddbf4b5666..14d97f49faf 100644 --- a/tests/baselines/reference/parserES5ForOfStatement21.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement21.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement21.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement21.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement21.ts (1 errors) ==== for (var of of) { } ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. \ No newline at end of file +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement3.errors.txt b/tests/baselines/reference/parserES5ForOfStatement3.errors.txt index 553ca40aee0..dd888a3120a 100644 --- a/tests/baselines/reference/parserES5ForOfStatement3.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement3.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement3.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement3.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement3.ts (1 errors) ==== for (var a, b of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement4.errors.txt b/tests/baselines/reference/parserES5ForOfStatement4.errors.txt index 6a08c8942ed..b94de56b17c 100644 --- a/tests/baselines/reference/parserES5ForOfStatement4.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement4.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement4.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement4.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement4.ts (1 errors) ==== for (var a = 1 of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement5.errors.txt b/tests/baselines/reference/parserES5ForOfStatement5.errors.txt index 212eae8ac10..0b8dafc0b90 100644 --- a/tests/baselines/reference/parserES5ForOfStatement5.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement5.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement5.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement5.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement5.ts (1 errors) ==== for (var a: number of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement6.errors.txt b/tests/baselines/reference/parserES5ForOfStatement6.errors.txt index e331b66eb85..04ac84fbd73 100644 --- a/tests/baselines/reference/parserES5ForOfStatement6.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement6.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement6.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement6.ts (1 errors) ==== for (var a = 1, b = 2 of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement7.errors.txt b/tests/baselines/reference/parserES5ForOfStatement7.errors.txt index 5ba60c264eb..1def5279f65 100644 --- a/tests/baselines/reference/parserES5ForOfStatement7.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement7.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement7.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement7.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement7.ts (1 errors) ==== for (var a: number = 1, b: string = "" of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement8.errors.txt b/tests/baselines/reference/parserES5ForOfStatement8.errors.txt index 3696bf11f8c..829fea57e6e 100644 --- a/tests/baselines/reference/parserES5ForOfStatement8.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement8.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement8.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement8.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement8.ts (1 errors) ==== for (var v of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ForOfStatement9.errors.txt b/tests/baselines/reference/parserES5ForOfStatement9.errors.txt index 6e2e9d05705..4cf082b4f15 100644 --- a/tests/baselines/reference/parserES5ForOfStatement9.errors.txt +++ b/tests/baselines/reference/parserES5ForOfStatement9.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement9.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement9.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement9.ts (1 errors) ==== for (let v of X) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement1.d.errors.txt b/tests/baselines/reference/parserForOfStatement1.d.errors.txt index 05af0a6f775..3b1b2a65922 100644 --- a/tests/baselines/reference/parserForOfStatement1.d.errors.txt +++ b/tests/baselines/reference/parserForOfStatement1.d.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement1.d.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement1.d.ts(1,1): error TS1036: Statements are not allowed in ambient contexts. ==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement1.d.ts (1 errors) ==== for (var i of e) { ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. +!!! error TS1036: Statements are not allowed in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement10.errors.txt b/tests/baselines/reference/parserForOfStatement10.errors.txt deleted file mode 100644 index 570c319b51f..00000000000 --- a/tests/baselines/reference/parserForOfStatement10.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement10.ts(1,1): error TS9003: 'for...of' statements are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement10.ts (1 errors) ==== - for (const v of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement11.errors.txt b/tests/baselines/reference/parserForOfStatement11.errors.txt deleted file mode 100644 index f253a2d4295..00000000000 --- a/tests/baselines/reference/parserForOfStatement11.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement11.ts(1,1): error TS9003: 'for...of' statements are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement11.ts (1 errors) ==== - for (const [a, b] of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement12.errors.txt b/tests/baselines/reference/parserForOfStatement12.errors.txt deleted file mode 100644 index 07ef4498984..00000000000 --- a/tests/baselines/reference/parserForOfStatement12.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement12.ts(1,1): error TS9003: 'for...of' statements are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement12.ts (1 errors) ==== - for (const {a, b} of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement13.errors.txt b/tests/baselines/reference/parserForOfStatement13.errors.txt deleted file mode 100644 index 6c10a7b0582..00000000000 --- a/tests/baselines/reference/parserForOfStatement13.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement13.ts(1,1): error TS9003: 'for...of' statements are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement13.ts (1 errors) ==== - for (let {a, b} of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement14.errors.txt b/tests/baselines/reference/parserForOfStatement14.errors.txt deleted file mode 100644 index 209a39c0513..00000000000 --- a/tests/baselines/reference/parserForOfStatement14.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement14.ts(1,1): error TS9003: 'for...of' statements are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement14.ts (1 errors) ==== - for (let [a, b] of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement15.errors.txt b/tests/baselines/reference/parserForOfStatement15.errors.txt deleted file mode 100644 index c5fd77af299..00000000000 --- a/tests/baselines/reference/parserForOfStatement15.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement15.ts(1,1): error TS9003: 'for...of' statements are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement15.ts (1 errors) ==== - for (var [a, b] of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement16.errors.txt b/tests/baselines/reference/parserForOfStatement16.errors.txt deleted file mode 100644 index d169eef1256..00000000000 --- a/tests/baselines/reference/parserForOfStatement16.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement16.ts(1,1): error TS9003: 'for...of' statements are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement16.ts (1 errors) ==== - for (var {a, b} of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement18.errors.txt b/tests/baselines/reference/parserForOfStatement18.errors.txt deleted file mode 100644 index 9312af76fc1..00000000000 --- a/tests/baselines/reference/parserForOfStatement18.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement18.ts(1,1): error TS9003: 'for...of' statements are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement18.ts (1 errors) ==== - for (var of of of) { } - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement2.errors.txt b/tests/baselines/reference/parserForOfStatement2.errors.txt index 8e7da497308..7229fe4196d 100644 --- a/tests/baselines/reference/parserForOfStatement2.errors.txt +++ b/tests/baselines/reference/parserForOfStatement2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement2.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement2.ts(1,9): error TS1123: Variable declaration list cannot be empty. ==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement2.ts (1 errors) ==== for (var of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. + +!!! error TS1123: Variable declaration list cannot be empty. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement21.errors.txt b/tests/baselines/reference/parserForOfStatement21.errors.txt index dad48f415cd..9103e2fedee 100644 --- a/tests/baselines/reference/parserForOfStatement21.errors.txt +++ b/tests/baselines/reference/parserForOfStatement21.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement21.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement21.ts(1,9): error TS1123: Variable declaration list cannot be empty. ==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement21.ts (1 errors) ==== for (var of of) { } - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. \ No newline at end of file + +!!! error TS1123: Variable declaration list cannot be empty. \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement3.errors.txt b/tests/baselines/reference/parserForOfStatement3.errors.txt index 83985f1a710..995ef4637c2 100644 --- a/tests/baselines/reference/parserForOfStatement3.errors.txt +++ b/tests/baselines/reference/parserForOfStatement3.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement3.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement3.ts(1,13): error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. ==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement3.ts (1 errors) ==== for (var a, b of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. + ~ +!!! error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement4.errors.txt b/tests/baselines/reference/parserForOfStatement4.errors.txt index 94dd08ed597..65b4bf342f2 100644 --- a/tests/baselines/reference/parserForOfStatement4.errors.txt +++ b/tests/baselines/reference/parserForOfStatement4.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement4.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement4.ts(1,10): error TS1190: The variable declaration of a 'for...of' statement cannot have an initializer. ==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement4.ts (1 errors) ==== for (var a = 1 of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. + ~ +!!! error TS1190: The variable declaration of a 'for...of' statement cannot have an initializer. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement5.errors.txt b/tests/baselines/reference/parserForOfStatement5.errors.txt index 6570f4a0755..13fd8739866 100644 --- a/tests/baselines/reference/parserForOfStatement5.errors.txt +++ b/tests/baselines/reference/parserForOfStatement5.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement5.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement5.ts(1,10): error TS2483: The left-hand side of a 'for...of' statement cannot use a type annotation. ==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement5.ts (1 errors) ==== for (var a: number of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. + ~ +!!! error TS2483: The left-hand side of a 'for...of' statement cannot use a type annotation. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement6.errors.txt b/tests/baselines/reference/parserForOfStatement6.errors.txt index 6208749911f..57d95361b65 100644 --- a/tests/baselines/reference/parserForOfStatement6.errors.txt +++ b/tests/baselines/reference/parserForOfStatement6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement6.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement6.ts(1,17): error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. ==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement6.ts (1 errors) ==== for (var a = 1, b = 2 of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. + ~ +!!! error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement7.errors.txt b/tests/baselines/reference/parserForOfStatement7.errors.txt index 1810daad5ee..07f93c263ec 100644 --- a/tests/baselines/reference/parserForOfStatement7.errors.txt +++ b/tests/baselines/reference/parserForOfStatement7.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement7.ts(1,1): error TS9003: 'for...of' statements are not currently supported. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement7.ts(1,25): error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. ==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement7.ts (1 errors) ==== for (var a: number = 1, b: string = "" of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. + ~ +!!! error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement8.errors.txt b/tests/baselines/reference/parserForOfStatement8.errors.txt deleted file mode 100644 index 8e2c41d0cef..00000000000 --- a/tests/baselines/reference/parserForOfStatement8.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement8.ts(1,1): error TS9003: 'for...of' statements are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement8.ts (1 errors) ==== - for (var v of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement9.errors.txt b/tests/baselines/reference/parserForOfStatement9.errors.txt deleted file mode 100644 index 01fd729e9cd..00000000000 --- a/tests/baselines/reference/parserForOfStatement9.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement9.ts(1,1): error TS9003: 'for...of' statements are not currently supported. - - -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement9.ts (1 errors) ==== - for (let v of X) { - ~~~ -!!! error TS9003: 'for...of' statements are not currently supported. - } \ No newline at end of file From 9e9dcdeca2da3a4e30907610a16412210968d4b1 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 19 Feb 2015 18:19:19 -0800 Subject: [PATCH 56/96] Fix naming in checkForInStatement --- src/compiler/checker.ts | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a92e77f6978..39d963712b0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8747,8 +8747,13 @@ module ts { } function checkForOfStatement(node: ForOfStatement) { - // TODO: not yet implemented - checkGrammarForOfStatement(node); + if (languageVersion < ScriptTarget.ES6) { + return grammarErrorOnFirstToken(node, Diagnostics.for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher); + } + + checkGrammarForInOrForOfStatement(node); + + // Check the expr } function checkForInStatement(node: ForInStatement) { @@ -8773,8 +8778,8 @@ module ts { // Var must be an expression classified as a reference of type Any or the String primitive type, // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; - var exprType = checkExpression(varExpr); - if (!allConstituentTypesHaveKind(exprType, TypeFlags.Any | TypeFlags.StringLike)) { + var leftType = checkExpression(varExpr); + if (!allConstituentTypesHaveKind(leftType, TypeFlags.Any | TypeFlags.StringLike)) { error(varExpr, Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); } else { @@ -8783,10 +8788,10 @@ module ts { } } - var exprType = checkExpression(node.expression); + var rightType = checkExpression(node.expression); // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!allConstituentTypesHaveKind(exprType, TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.TypeParameter)) { + if (!allConstituentTypesHaveKind(rightType, TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.TypeParameter)) { error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } @@ -11245,14 +11250,6 @@ module ts { return false; } - function checkGrammarForOfStatement(forOfStatement: ForOfStatement): boolean { - if (languageVersion < ScriptTarget.ES6) { - return grammarErrorOnFirstToken(forOfStatement, Diagnostics.for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher); - } - - return checkGrammarForInOrForOfStatement(forOfStatement); - } - function checkGrammarAccessor(accessor: MethodDeclaration): boolean { var kind = accessor.kind; if (languageVersion < ScriptTarget.ES5) { From e0d77346996e08d615850b34d104532de9eb0f44 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 19 Feb 2015 19:24:54 -0800 Subject: [PATCH 57/96] Basic for...of checking --- src/compiler/checker.ts | 106 ++++++++++-------- .../diagnosticInformationMap.generated.ts | 3 + src/compiler/diagnosticMessages.json | 12 ++ 3 files changed, 77 insertions(+), 44 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 39d963712b0..cfe7134c741 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -595,13 +595,13 @@ module ts { } if (name.kind === SyntaxKind.Identifier) { - var symbol = resolveName(location,(name).text, meaning, Diagnostics.Cannot_find_name_0, name); + var symbol = resolveName(location, (name).text, meaning, Diagnostics.Cannot_find_name_0, name); if (!symbol) { return; } } else if (name.kind === SyntaxKind.QualifiedName) { - var namespace = resolveEntityName(location,(name).left, SymbolFlags.Namespace); + var namespace = resolveEntityName(location, (name).left, SymbolFlags.Namespace); if (!namespace || namespace === unknownSymbol || getFullWidth((name).right) === 0) return; var symbol = getSymbol(getExportsOfSymbol(namespace), (name).right.text, meaning); if (!symbol) { @@ -3536,7 +3536,7 @@ module ts { isContextSensitive((node).whenFalse); case SyntaxKind.BinaryExpression: return (node).operatorToken.kind === SyntaxKind.BarBarToken && - (isContextSensitive((node).left) || isContextSensitive((node).right)); + (isContextSensitive((node).left) || isContextSensitive((node).right)); case SyntaxKind.PropertyAssignment: return isContextSensitive((node).initializer); case SyntaxKind.MethodDeclaration: @@ -5002,7 +5002,7 @@ module ts { break; case SyntaxKind.PrefixUnaryExpression: if ((expr).operator === SyntaxKind.ExclamationToken) { - return narrowType(type,(expr).operand, !assumeTrue); + return narrowType(type, (expr).operand, !assumeTrue); } break; } @@ -5073,7 +5073,7 @@ module ts { nodeLinks.importOnRightSide = symbol; } } - + if (symbolLinks.referenced) { markLinkedImportsAsReferenced(getDeclarationOfKind(symbol, SyntaxKind.ImportEqualsDeclaration)); } @@ -5198,20 +5198,20 @@ module ts { if (container && container.parent && container.parent.kind === SyntaxKind.ClassDeclaration) { if (container.flags & NodeFlags.Static) { canUseSuperExpression = - container.kind === SyntaxKind.MethodDeclaration || - container.kind === SyntaxKind.MethodSignature || - container.kind === SyntaxKind.GetAccessor || - container.kind === SyntaxKind.SetAccessor; + container.kind === SyntaxKind.MethodDeclaration || + container.kind === SyntaxKind.MethodSignature || + container.kind === SyntaxKind.GetAccessor || + container.kind === SyntaxKind.SetAccessor; } else { canUseSuperExpression = - container.kind === SyntaxKind.MethodDeclaration || - container.kind === SyntaxKind.MethodSignature || - container.kind === SyntaxKind.GetAccessor || - container.kind === SyntaxKind.SetAccessor || - container.kind === SyntaxKind.PropertyDeclaration || - container.kind === SyntaxKind.PropertySignature || - container.kind === SyntaxKind.Constructor; + container.kind === SyntaxKind.MethodDeclaration || + container.kind === SyntaxKind.MethodSignature || + container.kind === SyntaxKind.GetAccessor || + container.kind === SyntaxKind.SetAccessor || + container.kind === SyntaxKind.PropertyDeclaration || + container.kind === SyntaxKind.PropertySignature || + container.kind === SyntaxKind.Constructor; } } } @@ -5441,7 +5441,7 @@ module ts { return propertyType; } } - + return isNumericName(element.name) && getIndexTypeOfContextualType(type, IndexKind.Number) || getIndexTypeOfContextualType(type, IndexKind.String); } @@ -6034,7 +6034,7 @@ module ts { if (!leftHandSideSymbol) { return false; } - + var globalESSymbol = getGlobalESSymbolConstructorSymbol(); if (!globalESSymbol) { // Already errored when we tried to look up the symbol @@ -6308,7 +6308,7 @@ module ts { // unless we're reporting errors var argType = i === 0 && node.kind === SyntaxKind.TaggedTemplateExpression ? globalTemplateStringsArrayType : arg.kind === SyntaxKind.StringLiteral && !reportErrors ? getStringLiteralType(arg) : - checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); // Use argument expression as error location when reporting errors if (!checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1)) { @@ -6933,7 +6933,7 @@ module ts { if (produceDiagnostics && node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) { checkCollisionWithCapturedSuperVariable(node, (node).name); - checkCollisionWithCapturedThisVariable(node,(node).name); + checkCollisionWithCapturedThisVariable(node, (node).name); } return type; @@ -7226,7 +7226,7 @@ module ts { var propName = "" + i; var type = sourceType.flags & TypeFlags.Any ? sourceType : isTupleLikeType(sourceType) ? getTypeOfPropertyOfType(sourceType, propName) : - getIndexTypeOfType(sourceType, IndexKind.Number); + getIndexTypeOfType(sourceType, IndexKind.Number); if (type) { checkDestructuringAssignment(e, type, contextualMapper); } @@ -7380,7 +7380,7 @@ module ts { if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - // Fall through + // Fall through case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: @@ -7408,8 +7408,8 @@ module ts { function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { var offendingSymbolOperand = someConstituentTypeHasKind(leftType, TypeFlags.ESSymbol) ? node.left : - someConstituentTypeHasKind(rightType, TypeFlags.ESSymbol) ? node.right : - undefined; + someConstituentTypeHasKind(rightType, TypeFlags.ESSymbol) ? node.right : + undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator)); return false; @@ -7708,8 +7708,8 @@ module ts { } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.ConstructorType || - node.kind === SyntaxKind.CallSignature || node.kind === SyntaxKind.Constructor || - node.kind === SyntaxKind.ConstructSignature){ + node.kind === SyntaxKind.CallSignature || node.kind === SyntaxKind.Constructor || + node.kind === SyntaxKind.ConstructSignature) { checkGrammarFunctionLikeDeclaration(node); } @@ -8319,9 +8319,9 @@ module ts { function checkFunctionDeclaration(node: FunctionDeclaration): void { if (produceDiagnostics) { checkFunctionLikeDeclaration(node) || - checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || - checkGrammarFunctionName(node.name) || - checkGrammarForGenerator(node); + checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || + checkGrammarFunctionName(node.name) || + checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); @@ -8428,7 +8428,7 @@ module ts { return true; } - + function checkCollisionWithCapturedThisVariable(node: Node, name: Identifier): void { if (needCollisionCheckForIdentifier(node, name, "_this")) { potentialThisCollisions.push(node); @@ -8438,7 +8438,7 @@ module ts { // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node: Node): void { var current = node; - while (current) { + while (current) { if (getNodeCheckFlags(current) & NodeCheckFlags.CaptureThis) { var isDeclaration = node.kind !== SyntaxKind.Identifier; if (isDeclaration) { @@ -8539,8 +8539,8 @@ module ts { var namesShareScope = container && (container.kind === SyntaxKind.Block && isAnyFunction(container.parent) || - (container.kind === SyntaxKind.ModuleBlock && container.kind === SyntaxKind.ModuleDeclaration) || - container.kind === SyntaxKind.SourceFile); + (container.kind === SyntaxKind.ModuleBlock && container.kind === SyntaxKind.ModuleDeclaration) || + container.kind === SyntaxKind.SourceFile); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error @@ -8746,14 +8746,28 @@ module ts { checkSourceElement(node.statement); } - function checkForOfStatement(node: ForOfStatement) { + function checkForOfStatement(node: ForOfStatement): void { if (languageVersion < ScriptTarget.ES6) { - return grammarErrorOnFirstToken(node, Diagnostics.for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher); + grammarErrorOnFirstToken(node, Diagnostics.for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher); + return; } - - checkGrammarForInOrForOfStatement(node); - // Check the expr + checkGrammarForInOrForOfStatement(node) + + // Check the LHS and RHS + // If decl: Check var decl, which will check the RHS + // If expr: Check LHS, check that it's a reference, and check that RHS is assignable to it, which will check RHS + if (node.initializer.kind === SyntaxKind.VariableDeclarationList) { + checkForInOrForOfVariableDeclaration(node); + } + else { + var varExpr = node.initializer; + var leftType = checkExpression(varExpr); + checkReferenceExpression(varExpr, Diagnostics.Invalid_left_hand_side_in_for_of_statement, Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); + var rightType = checkExpression(node.expression); + } + + checkSourceElement(node.statement); } function checkForInStatement(node: ForInStatement) { @@ -8766,11 +8780,7 @@ module ts { // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. if (node.initializer.kind === SyntaxKind.VariableDeclarationList) { - var variableDeclarationList = node.initializer; - if (variableDeclarationList.declarations.length >= 1) { - var decl = variableDeclarationList.declarations[0]; - checkVariableDeclaration(decl); - } + checkForInOrForOfVariableDeclaration(node); } else { // In a 'for-in' statement of the form @@ -8784,7 +8794,7 @@ module ts { } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, Diagnostics.Invalid_left_hand_side_in_for_in_statement, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + checkReferenceExpression(varExpr, Diagnostics.Invalid_left_hand_side_in_for_in_statement, Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); } } @@ -8798,6 +8808,14 @@ module ts { checkSourceElement(node.statement); } + function checkForInOrForOfVariableDeclaration(iterationStatement: ForInStatement | ForOfStatement): void { + var variableDeclarationList = iterationStatement.initializer; + if (variableDeclarationList.declarations.length >= 1) { + var decl = variableDeclarationList.declarations[0]; + checkVariableDeclaration(decl); + } + } + function checkBreakOrContinueStatement(node: BreakOrContinueStatement) { // Grammar checking checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 5f8be858627..35b5ca5cdc3 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -326,6 +326,9 @@ module ts { for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 2482, category: DiagnosticCategory.Error, key: "'for...of' statements are only available when targeting ECMAScript 6 or higher." }, The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" }, + The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, + Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b7102337ef6..8b57778a696 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1296,6 +1296,18 @@ "category": "Error", "code": 2484 }, + "The left-hand side of a 'for...of' statement cannot be a previously defined constant.": { + "category": "Error", + "code": 2485 + }, + "The left-hand side of a 'for...in' statement cannot be a previously defined constant.": { + "category": "Error", + "code": 2486 + }, + "Invalid left-hand side in 'for...of' statement.": { + "category": "Error", + "code": 2487 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", From aa0662269567a84d150395bfd36c0c91cda98b31 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Fri, 20 Feb 2015 12:22:32 -0800 Subject: [PATCH 58/96] Basic tests --- tests/baselines/reference/for-of1.js | 7 +++++++ tests/baselines/reference/for-of1.types | 8 ++++++++ tests/baselines/reference/for-of2.errors.txt | 11 +++++++++++ tests/baselines/reference/for-of2.js | 7 +++++++ tests/baselines/reference/for-of3.errors.txt | 8 ++++++++ tests/baselines/reference/for-of3.js | 7 +++++++ tests/baselines/reference/for-of4.js | 9 +++++++++ tests/baselines/reference/for-of5.js | 9 +++++++++ tests/baselines/reference/for-of6.errors.txt | 9 +++++++++ tests/baselines/reference/for-of6.js | 9 +++++++++ tests/baselines/reference/for-of7.errors.txt | 8 ++++++++ tests/baselines/reference/for-of7.js | 7 +++++++ tests/baselines/reference/for-of8.js | 7 +++++++ .../cases/conformance/es6/for-ofStatements/for-of1.ts | 3 +++ .../cases/conformance/es6/for-ofStatements/for-of2.ts | 3 +++ .../cases/conformance/es6/for-ofStatements/for-of3.ts | 3 +++ .../cases/conformance/es6/for-ofStatements/for-of4.ts | 4 ++++ .../cases/conformance/es6/for-ofStatements/for-of5.ts | 4 ++++ .../cases/conformance/es6/for-ofStatements/for-of6.ts | 4 ++++ .../cases/conformance/es6/for-ofStatements/for-of7.ts | 3 +++ .../cases/conformance/es6/for-ofStatements/for-of8.ts | 3 +++ 21 files changed, 133 insertions(+) create mode 100644 tests/baselines/reference/for-of1.js create mode 100644 tests/baselines/reference/for-of1.types create mode 100644 tests/baselines/reference/for-of2.errors.txt create mode 100644 tests/baselines/reference/for-of2.js create mode 100644 tests/baselines/reference/for-of3.errors.txt create mode 100644 tests/baselines/reference/for-of3.js create mode 100644 tests/baselines/reference/for-of4.js create mode 100644 tests/baselines/reference/for-of5.js create mode 100644 tests/baselines/reference/for-of6.errors.txt create mode 100644 tests/baselines/reference/for-of6.js create mode 100644 tests/baselines/reference/for-of7.errors.txt create mode 100644 tests/baselines/reference/for-of7.js create mode 100644 tests/baselines/reference/for-of8.js create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of1.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of2.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of3.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of4.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of5.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of6.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of7.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of8.ts diff --git a/tests/baselines/reference/for-of1.js b/tests/baselines/reference/for-of1.js new file mode 100644 index 00000000000..9df6a96d78f --- /dev/null +++ b/tests/baselines/reference/for-of1.js @@ -0,0 +1,7 @@ +//// [for-of1.ts] +var v; +for (v of []) { } + +//// [for-of1.js] +var v; +for (v of []) { } diff --git a/tests/baselines/reference/for-of1.types b/tests/baselines/reference/for-of1.types new file mode 100644 index 00000000000..b21bb6046a7 --- /dev/null +++ b/tests/baselines/reference/for-of1.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of1.ts === +var v; +>v : any + +for (v of []) { } +>v : any +>[] : undefined[] + diff --git a/tests/baselines/reference/for-of2.errors.txt b/tests/baselines/reference/for-of2.errors.txt new file mode 100644 index 00000000000..0b5133cde13 --- /dev/null +++ b/tests/baselines/reference/for-of2.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/es6/for-ofStatements/for-of2.ts(1,7): error TS1155: 'const' declarations must be initialized +tests/cases/conformance/es6/for-ofStatements/for-of2.ts(2,6): error TS2485: The left-hand side of a 'for...of' statement cannot be a previously defined constant. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of2.ts (2 errors) ==== + const v; + ~ +!!! error TS1155: 'const' declarations must be initialized + for (v of []) { } + ~ +!!! error TS2485: The left-hand side of a 'for...of' statement cannot be a previously defined constant. \ No newline at end of file diff --git a/tests/baselines/reference/for-of2.js b/tests/baselines/reference/for-of2.js new file mode 100644 index 00000000000..d7eceb7c49e --- /dev/null +++ b/tests/baselines/reference/for-of2.js @@ -0,0 +1,7 @@ +//// [for-of2.ts] +const v; +for (v of []) { } + +//// [for-of2.js] +const v; +for (v of []) { } diff --git a/tests/baselines/reference/for-of3.errors.txt b/tests/baselines/reference/for-of3.errors.txt new file mode 100644 index 00000000000..973230003f9 --- /dev/null +++ b/tests/baselines/reference/for-of3.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/es6/for-ofStatements/for-of3.ts(2,6): error TS2486: Invalid left-hand side in 'for...of' statement. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of3.ts (1 errors) ==== + var v; + for (v++ of []) { } + ~~~ +!!! error TS2486: Invalid left-hand side in 'for...of' statement. \ No newline at end of file diff --git a/tests/baselines/reference/for-of3.js b/tests/baselines/reference/for-of3.js new file mode 100644 index 00000000000..7ef27187702 --- /dev/null +++ b/tests/baselines/reference/for-of3.js @@ -0,0 +1,7 @@ +//// [for-of3.ts] +var v; +for (v++ of []) { } + +//// [for-of3.js] +var v; +for (v++ of []) { } diff --git a/tests/baselines/reference/for-of4.js b/tests/baselines/reference/for-of4.js new file mode 100644 index 00000000000..147619d2fe2 --- /dev/null +++ b/tests/baselines/reference/for-of4.js @@ -0,0 +1,9 @@ +//// [for-of4.ts] +for (var v of [0]) { + v; +} + +//// [for-of4.js] +for (var v of [0]) { + v; +} diff --git a/tests/baselines/reference/for-of5.js b/tests/baselines/reference/for-of5.js new file mode 100644 index 00000000000..4d93b0bd483 --- /dev/null +++ b/tests/baselines/reference/for-of5.js @@ -0,0 +1,9 @@ +//// [for-of5.ts] +for (let v of [0]) { + v; +} + +//// [for-of5.js] +for (let v of [0]) { + v; +} diff --git a/tests/baselines/reference/for-of6.errors.txt b/tests/baselines/reference/for-of6.errors.txt new file mode 100644 index 00000000000..03f41d18b2b --- /dev/null +++ b/tests/baselines/reference/for-of6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/for-ofStatements/for-of6.ts(1,6): error TS2304: Cannot find name 'v'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of6.ts (1 errors) ==== + for (v of [0]) { + ~ +!!! error TS2304: Cannot find name 'v'. + let v; + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of6.js b/tests/baselines/reference/for-of6.js new file mode 100644 index 00000000000..24e93e2a9fd --- /dev/null +++ b/tests/baselines/reference/for-of6.js @@ -0,0 +1,9 @@ +//// [for-of6.ts] +for (v of [0]) { + let v; +} + +//// [for-of6.js] +for (v of [0]) { + let v; +} diff --git a/tests/baselines/reference/for-of7.errors.txt b/tests/baselines/reference/for-of7.errors.txt new file mode 100644 index 00000000000..e67c51e2d96 --- /dev/null +++ b/tests/baselines/reference/for-of7.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/es6/for-ofStatements/for-of7.ts(1,1): error TS2304: Cannot find name 'v'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of7.ts (1 errors) ==== + v; + ~ +!!! error TS2304: Cannot find name 'v'. + for (let v of [0]) { } \ No newline at end of file diff --git a/tests/baselines/reference/for-of7.js b/tests/baselines/reference/for-of7.js new file mode 100644 index 00000000000..04aadd9736a --- /dev/null +++ b/tests/baselines/reference/for-of7.js @@ -0,0 +1,7 @@ +//// [for-of7.ts] +v; +for (let v of [0]) { } + +//// [for-of7.js] +v; +for (let v of [0]) { } diff --git a/tests/baselines/reference/for-of8.js b/tests/baselines/reference/for-of8.js new file mode 100644 index 00000000000..f33d69166dc --- /dev/null +++ b/tests/baselines/reference/for-of8.js @@ -0,0 +1,7 @@ +//// [for-of8.ts] +v; +for (var v of [0]) { } + +//// [for-of8.js] +v; +for (var v of [0]) { } diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of1.ts b/tests/cases/conformance/es6/for-ofStatements/for-of1.ts new file mode 100644 index 00000000000..b9e25f20606 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of1.ts @@ -0,0 +1,3 @@ +//@target: ES6 +var v; +for (v of []) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of2.ts b/tests/cases/conformance/es6/for-ofStatements/for-of2.ts new file mode 100644 index 00000000000..77f72330dee --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of2.ts @@ -0,0 +1,3 @@ +//@target: ES6 +const v; +for (v of []) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of3.ts b/tests/cases/conformance/es6/for-ofStatements/for-of3.ts new file mode 100644 index 00000000000..7eb1e1fd220 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of3.ts @@ -0,0 +1,3 @@ +//@target: ES6 +var v; +for (v++ of []) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of4.ts b/tests/cases/conformance/es6/for-ofStatements/for-of4.ts new file mode 100644 index 00000000000..d37925b67a0 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of4.ts @@ -0,0 +1,4 @@ +//@target: ES6 +for (var v of [0]) { + v; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of5.ts b/tests/cases/conformance/es6/for-ofStatements/for-of5.ts new file mode 100644 index 00000000000..2a581676b4b --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of5.ts @@ -0,0 +1,4 @@ +//@target: ES6 +for (let v of [0]) { + v; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of6.ts b/tests/cases/conformance/es6/for-ofStatements/for-of6.ts new file mode 100644 index 00000000000..1d8eccde01a --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of6.ts @@ -0,0 +1,4 @@ +//@target: ES6 +for (v of [0]) { + let v; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of7.ts b/tests/cases/conformance/es6/for-ofStatements/for-of7.ts new file mode 100644 index 00000000000..5303278d910 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of7.ts @@ -0,0 +1,3 @@ +//@target: ES6 +v; +for (let v of [0]) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of8.ts b/tests/cases/conformance/es6/for-ofStatements/for-of8.ts new file mode 100644 index 00000000000..34bd4943c70 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of8.ts @@ -0,0 +1,3 @@ +//@target: ES6 +v; +for (var v of [0]) { } \ No newline at end of file From 277c931a0d87ad80102a0f4cb10ff86f45288feb Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Fri, 20 Feb 2015 17:09:03 -0800 Subject: [PATCH 59/96] Basic iterator support in for..of statement --- src/compiler/checker.ts | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cfe7134c741..1357d659e82 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8765,6 +8765,8 @@ module ts { var leftType = checkExpression(varExpr); checkReferenceExpression(varExpr, Diagnostics.Invalid_left_hand_side_in_for_of_statement, Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); var rightType = checkExpression(node.expression); + var iteratedType = getIteratedType(rightType); + checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); } checkSourceElement(node.statement); @@ -8816,6 +8818,45 @@ module ts { } } + function getIteratedType(iterable: Type): Type { + Debug.assert(languageVersion >= ScriptTarget.ES6); + if (allConstituentTypesHaveKind(iterable, TypeFlags.Any)) { + return anyType; + } + + // We want to treat type as an iterable, and get the type it is an iterable of. The iterable + // must have the following structure (annotated with the names of the variables below): + // + // { // iterable + // [Symbol.iterator]: { // iteratorFunction + // (): { // iterator + // next: { // iteratorNextFunction + // (): { // iteratorNextResult + // value: T // iteratorNextValue + // } + // } + // } + // } + // } + // + // T is the type we are after. At every level that involves analyzing return types + // of signatures, we union the return types of all the signatures. + var iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator")); + var iteratorFunctionSignatures = getSignaturesOfType(iteratorFunction, SignatureKind.Call); + var iterator = getUnionType(map(iteratorFunctionSignatures, getReturnTypeOfSignature)); + + var iteratorNextFunction = getTypeOfPropertyOfType(iterator, "next"); + var iteratorNextFunctionSignatures = getSignaturesOfType(iteratorNextFunction, SignatureKind.Call); + var iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); + + var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); + + return iteratorNextValue; + // TODO + // Now even though we have extracted the iteratorNextValue, we will have to validate that the type + // passed in is actually an Iterable. + } + function checkBreakOrContinueStatement(node: BreakOrContinueStatement) { // Grammar checking checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); From ec9e5632386d35871a137cc6ad219d744dbb9704 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Fri, 20 Feb 2015 18:00:03 -0800 Subject: [PATCH 60/96] Add tests and accept correct baselines --- tests/baselines/reference/for-of10.errors.txt | 8 ++++++++ tests/baselines/reference/for-of10.js | 7 +++++++ tests/baselines/reference/for-of11.errors.txt | 10 ++++++++++ tests/baselines/reference/for-of11.js | 7 +++++++ tests/baselines/reference/for-of12.errors.txt | 10 ++++++++++ tests/baselines/reference/for-of12.js | 7 +++++++ tests/baselines/reference/for-of13.js | 7 +++++++ tests/baselines/reference/for-of13.types | 11 +++++++++++ tests/baselines/reference/for-of3.errors.txt | 4 ++-- tests/baselines/reference/for-of9.js | 9 +++++++++ tests/baselines/reference/for-of9.types | 11 +++++++++++ .../reference/parserForOfStatement18.types | 5 +++++ .../reference/parserForOfStatement8.types | 5 +++++ .../reference/parserForOfStatement9.types | 5 +++++ .../conformance/es6/for-ofStatements/for-of10.ts | 3 +++ .../conformance/es6/for-ofStatements/for-of11.ts | 3 +++ .../conformance/es6/for-ofStatements/for-of12.ts | 3 +++ .../conformance/es6/for-ofStatements/for-of13.ts | 3 +++ .../conformance/es6/for-ofStatements/for-of14.ts | 9 +++++++++ .../conformance/es6/for-ofStatements/for-of15.ts | 12 ++++++++++++ .../conformance/es6/for-ofStatements/for-of16.ts | 12 ++++++++++++ .../conformance/es6/for-ofStatements/for-of17.ts | 12 ++++++++++++ .../conformance/es6/for-ofStatements/for-of18.ts | 15 +++++++++++++++ .../conformance/es6/for-ofStatements/for-of19.ts | 15 +++++++++++++++ .../conformance/es6/for-ofStatements/for-of9.ts | 4 ++++ 25 files changed, 195 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/for-of10.errors.txt create mode 100644 tests/baselines/reference/for-of10.js create mode 100644 tests/baselines/reference/for-of11.errors.txt create mode 100644 tests/baselines/reference/for-of11.js create mode 100644 tests/baselines/reference/for-of12.errors.txt create mode 100644 tests/baselines/reference/for-of12.js create mode 100644 tests/baselines/reference/for-of13.js create mode 100644 tests/baselines/reference/for-of13.types create mode 100644 tests/baselines/reference/for-of9.js create mode 100644 tests/baselines/reference/for-of9.types create mode 100644 tests/baselines/reference/parserForOfStatement18.types create mode 100644 tests/baselines/reference/parserForOfStatement8.types create mode 100644 tests/baselines/reference/parserForOfStatement9.types create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of10.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of11.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of12.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of13.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of14.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of15.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of16.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of17.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of18.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of19.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of9.ts diff --git a/tests/baselines/reference/for-of10.errors.txt b/tests/baselines/reference/for-of10.errors.txt new file mode 100644 index 00000000000..1636f1a02d0 --- /dev/null +++ b/tests/baselines/reference/for-of10.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/es6/for-ofStatements/for-of10.ts(2,6): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of10.ts (1 errors) ==== + var v: string; + for (v of [0]) { } + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/for-of10.js b/tests/baselines/reference/for-of10.js new file mode 100644 index 00000000000..7fd05f5479b --- /dev/null +++ b/tests/baselines/reference/for-of10.js @@ -0,0 +1,7 @@ +//// [for-of10.ts] +var v: string; +for (v of [0]) { } + +//// [for-of10.js] +var v; +for (v of [0]) { } diff --git a/tests/baselines/reference/for-of11.errors.txt b/tests/baselines/reference/for-of11.errors.txt new file mode 100644 index 00000000000..dc527e73efe --- /dev/null +++ b/tests/baselines/reference/for-of11.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/es6/for-ofStatements/for-of11.ts(2,6): error TS2322: Type 'string | number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of11.ts (1 errors) ==== + var v: string; + for (v of [0, ""]) { } + ~ +!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/for-of11.js b/tests/baselines/reference/for-of11.js new file mode 100644 index 00000000000..055ed0039dc --- /dev/null +++ b/tests/baselines/reference/for-of11.js @@ -0,0 +1,7 @@ +//// [for-of11.ts] +var v: string; +for (v of [0, ""]) { } + +//// [for-of11.js] +var v; +for (v of [0, ""]) { } diff --git a/tests/baselines/reference/for-of12.errors.txt b/tests/baselines/reference/for-of12.errors.txt new file mode 100644 index 00000000000..f19fa5ed014 --- /dev/null +++ b/tests/baselines/reference/for-of12.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/es6/for-ofStatements/for-of12.ts(2,6): error TS2322: Type 'string | number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of12.ts (1 errors) ==== + var v: string; + for (v of [0, ""].values()) { } + ~ +!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/for-of12.js b/tests/baselines/reference/for-of12.js new file mode 100644 index 00000000000..6185ca8e331 --- /dev/null +++ b/tests/baselines/reference/for-of12.js @@ -0,0 +1,7 @@ +//// [for-of12.ts] +var v: string; +for (v of [0, ""].values()) { } + +//// [for-of12.js] +var v; +for (v of [0, ""].values()) { } diff --git a/tests/baselines/reference/for-of13.js b/tests/baselines/reference/for-of13.js new file mode 100644 index 00000000000..e66668f1736 --- /dev/null +++ b/tests/baselines/reference/for-of13.js @@ -0,0 +1,7 @@ +//// [for-of13.ts] +var v: string; +for (v of [""].values()) { } + +//// [for-of13.js] +var v; +for (v of [""].values()) { } diff --git a/tests/baselines/reference/for-of13.types b/tests/baselines/reference/for-of13.types new file mode 100644 index 00000000000..4bb29c1e0ab --- /dev/null +++ b/tests/baselines/reference/for-of13.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of13.ts === +var v: string; +>v : string + +for (v of [""].values()) { } +>v : string +>[""].values() : IterableIterator +>[""].values : () => IterableIterator +>[""] : string[] +>values : () => IterableIterator + diff --git a/tests/baselines/reference/for-of3.errors.txt b/tests/baselines/reference/for-of3.errors.txt index 973230003f9..ba8e3e4a5c6 100644 --- a/tests/baselines/reference/for-of3.errors.txt +++ b/tests/baselines/reference/for-of3.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/for-ofStatements/for-of3.ts(2,6): error TS2486: Invalid left-hand side in 'for...of' statement. +tests/cases/conformance/es6/for-ofStatements/for-of3.ts(2,6): error TS2487: Invalid left-hand side in 'for...of' statement. ==== tests/cases/conformance/es6/for-ofStatements/for-of3.ts (1 errors) ==== var v; for (v++ of []) { } ~~~ -!!! error TS2486: Invalid left-hand side in 'for...of' statement. \ No newline at end of file +!!! error TS2487: Invalid left-hand side in 'for...of' statement. \ No newline at end of file diff --git a/tests/baselines/reference/for-of9.js b/tests/baselines/reference/for-of9.js new file mode 100644 index 00000000000..f96d353bd7a --- /dev/null +++ b/tests/baselines/reference/for-of9.js @@ -0,0 +1,9 @@ +//// [for-of9.ts] +var v: string; +for (v of ["hello"]) { } +for (v of "hello") { } + +//// [for-of9.js] +var v; +for (v of ["hello"]) { } +for (v of "hello") { } diff --git a/tests/baselines/reference/for-of9.types b/tests/baselines/reference/for-of9.types new file mode 100644 index 00000000000..55c8167094f --- /dev/null +++ b/tests/baselines/reference/for-of9.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of9.ts === +var v: string; +>v : string + +for (v of ["hello"]) { } +>v : string +>["hello"] : string[] + +for (v of "hello") { } +>v : string + diff --git a/tests/baselines/reference/parserForOfStatement18.types b/tests/baselines/reference/parserForOfStatement18.types new file mode 100644 index 00000000000..8e3b52ac877 --- /dev/null +++ b/tests/baselines/reference/parserForOfStatement18.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement18.ts === +for (var of of of) { } +>of : any +>of : any + diff --git a/tests/baselines/reference/parserForOfStatement8.types b/tests/baselines/reference/parserForOfStatement8.types new file mode 100644 index 00000000000..a4168caf262 --- /dev/null +++ b/tests/baselines/reference/parserForOfStatement8.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement8.ts === +for (var v of X) { +>v : any +>X : unknown +} diff --git a/tests/baselines/reference/parserForOfStatement9.types b/tests/baselines/reference/parserForOfStatement9.types new file mode 100644 index 00000000000..0285a3e4b76 --- /dev/null +++ b/tests/baselines/reference/parserForOfStatement9.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement9.ts === +for (let v of X) { +>v : any +>X : unknown +} diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of10.ts b/tests/cases/conformance/es6/for-ofStatements/for-of10.ts new file mode 100644 index 00000000000..dec00541e93 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of10.ts @@ -0,0 +1,3 @@ +//@target: ES6 +var v: string; +for (v of [0]) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of11.ts b/tests/cases/conformance/es6/for-ofStatements/for-of11.ts new file mode 100644 index 00000000000..e434758efa4 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of11.ts @@ -0,0 +1,3 @@ +//@target: ES6 +var v: string; +for (v of [0, ""]) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of12.ts b/tests/cases/conformance/es6/for-ofStatements/for-of12.ts new file mode 100644 index 00000000000..78cfbaccecb --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of12.ts @@ -0,0 +1,3 @@ +//@target: ES6 +var v: string; +for (v of [0, ""].values()) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of13.ts b/tests/cases/conformance/es6/for-ofStatements/for-of13.ts new file mode 100644 index 00000000000..2f2b922cb1d --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of13.ts @@ -0,0 +1,3 @@ +//@target: ES6 +var v: string; +for (v of [""].values()) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of14.ts b/tests/cases/conformance/es6/for-ofStatements/for-of14.ts new file mode 100644 index 00000000000..8bb3e959501 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of14.ts @@ -0,0 +1,9 @@ +//@target: ES6 +var v: string; +for (v of new StringIterator) { } // Should fail because the iterator is not iterable + +class StringIterator implements Iterator { + next() { + return ""; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of15.ts b/tests/cases/conformance/es6/for-ofStatements/for-of15.ts new file mode 100644 index 00000000000..87ff3e9603d --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of15.ts @@ -0,0 +1,12 @@ +//@target: ES6 +var v: string; +for (v of new StringIterator) { } // Should succeed + +class StringIterator implements Iterator { + next() { + return ""; + } + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of16.ts b/tests/cases/conformance/es6/for-ofStatements/for-of16.ts new file mode 100644 index 00000000000..92b3b4e6de5 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of16.ts @@ -0,0 +1,12 @@ +//@target: ES6 +var v: string; +for (v of (new StringIterator)[Symbol.iterator]()) { } // Should succeed + +class StringIterator implements Iterator { + next() { + return ""; + } + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of17.ts b/tests/cases/conformance/es6/for-ofStatements/for-of17.ts new file mode 100644 index 00000000000..819e9218bd1 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of17.ts @@ -0,0 +1,12 @@ +//@target: ES6 +var v: number; +for (v of (new NumberIterator)[Symbol.iterator]().next()) { } // Should fail + +class NumberIterator { + next() { + return 0; + } + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of18.ts b/tests/cases/conformance/es6/for-ofStatements/for-of18.ts new file mode 100644 index 00000000000..10e566cf64c --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of18.ts @@ -0,0 +1,15 @@ +//@target: ES6 +var v: string; +for (v of (new StringIterator)[Symbol.iterator]().next()) { } // Should succeed + +class StringIterator { + next() { + return { + value: "", + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of19.ts b/tests/cases/conformance/es6/for-ofStatements/for-of19.ts new file mode 100644 index 00000000000..1e45c32e8ad --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of19.ts @@ -0,0 +1,15 @@ +//@target: ES6 +var v: string; +for (v of (new StringIterator)[Symbol.iterator]().next()) { } // Should fail + +class StringIterator { + next() { + return { + value: 0, + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of9.ts b/tests/cases/conformance/es6/for-ofStatements/for-of9.ts new file mode 100644 index 00000000000..45a3c7e1d94 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of9.ts @@ -0,0 +1,4 @@ +//@target: ES6 +var v: string; +for (v of ["hello"]) { } +for (v of "hello") { } \ No newline at end of file From a2c557320b5c8fe641e02f5fb1e59529bd38f7c4 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 23 Feb 2015 18:06:07 -0800 Subject: [PATCH 61/96] Get type of 'for...of' variables --- src/compiler/checker.ts | 57 ++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1357d659e82..5a9e9575bca 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1862,6 +1862,9 @@ module ts { if (declaration.parent.parent.kind === SyntaxKind.ForInStatement) { return anyType; } + if (declaration.parent.parent.kind === SyntaxKind.ForOfStatement) { + return getTypeForVariableDeclarationInForOfStatement(declaration.parent.parent); + } if (isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } @@ -8818,6 +8821,28 @@ module ts { } } + function getTypeForVariableDeclarationInForOfStatement(forOfStatement: ForOfStatement): Type { + // Temporarily return 'any' below ES6 + if (languageVersion < ScriptTarget.ES6) { + return anyType; + } + + var variable = forOfStatement.initializer; + var links = getNodeLinks(variable); + if (!links.resolvedType) { + links.resolvedType = resolvingType; + var type = getIteratedType(getTypeOfExpression(forOfStatement.expression)); + if (links.resolvedType === resolvingType) { + links.resolvedType = type; + } + } + else if (links.resolvedType === resolvingType) { + links.resolvedType = anyType; + } + + return links.resolvedType; + } + function getIteratedType(iterable: Type): Type { Debug.assert(languageVersion >= ScriptTarget.ES6); if (allConstituentTypesHaveKind(iterable, TypeFlags.Any)) { @@ -11483,22 +11508,24 @@ module ts { } function checkGrammarVariableDeclaration(node: VariableDeclaration) { - if (isInAmbientContext(node)) { - if (isBindingPattern(node.name)) { - return grammarErrorOnNode(node, Diagnostics.Destructuring_declarations_are_not_allowed_in_ambient_contexts); - } - if (node.initializer) { - // Error on equals token which immediate precedes the initializer - return grammarErrorAtPos(getSourceFileOfNode(node), node.initializer.pos - 1, 1, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - } - else { - if (!node.initializer) { - if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) { - return grammarErrorOnNode(node, Diagnostics.A_destructuring_declaration_must_have_an_initializer); + if (node.parent.parent.kind !== SyntaxKind.ForInStatement && node.parent.parent.kind !== SyntaxKind.ForOfStatement) { + if (isInAmbientContext(node)) { + if (isBindingPattern(node.name)) { + return grammarErrorOnNode(node, Diagnostics.Destructuring_declarations_are_not_allowed_in_ambient_contexts); } - if (isConst(node)) { - return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized); + if (node.initializer) { + // Error on equals token which immediate precedes the initializer + return grammarErrorAtPos(getSourceFileOfNode(node), node.initializer.pos - 1, 1, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + else { + if (!node.initializer) { + if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) { + return grammarErrorOnNode(node, Diagnostics.A_destructuring_declaration_must_have_an_initializer); + } + if (isConst(node)) { + return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized); + } } } } From 1043d8703faca8aa130700087439ced3767cbbd8 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 23 Feb 2015 18:06:38 -0800 Subject: [PATCH 62/96] Tests and baselines for 'for...of' variables --- .../reference/constDeclarations-errors.errors.txt | 5 +---- tests/baselines/reference/for-of4.types | 8 ++++++++ tests/baselines/reference/for-of5.types | 8 ++++++++ tests/baselines/reference/for-of8.types | 8 ++++++++ .../reference/parserForOfStatement1.d.errors.txt | 5 ++++- .../baselines/reference/parserForOfStatement10.errors.txt | 8 ++++++++ .../baselines/reference/parserForOfStatement11.errors.txt | 8 ++++++++ .../baselines/reference/parserForOfStatement12.errors.txt | 8 ++++++++ .../baselines/reference/parserForOfStatement13.errors.txt | 8 ++++++++ .../baselines/reference/parserForOfStatement14.errors.txt | 8 ++++++++ .../baselines/reference/parserForOfStatement15.errors.txt | 8 ++++++++ .../baselines/reference/parserForOfStatement16.errors.txt | 8 ++++++++ .../baselines/reference/parserForOfStatement3.errors.txt | 5 ++++- .../baselines/reference/parserForOfStatement4.errors.txt | 5 ++++- .../baselines/reference/parserForOfStatement5.errors.txt | 5 ++++- .../baselines/reference/parserForOfStatement6.errors.txt | 5 ++++- .../baselines/reference/parserForOfStatement7.errors.txt | 5 ++++- .../baselines/reference/parserForOfStatement8.errors.txt | 8 ++++++++ tests/baselines/reference/parserForOfStatement8.types | 5 ----- .../baselines/reference/parserForOfStatement9.errors.txt | 8 ++++++++ tests/baselines/reference/parserForOfStatement9.types | 5 ----- 21 files changed, 121 insertions(+), 20 deletions(-) create mode 100644 tests/baselines/reference/for-of4.types create mode 100644 tests/baselines/reference/for-of5.types create mode 100644 tests/baselines/reference/for-of8.types create mode 100644 tests/baselines/reference/parserForOfStatement10.errors.txt create mode 100644 tests/baselines/reference/parserForOfStatement11.errors.txt create mode 100644 tests/baselines/reference/parserForOfStatement12.errors.txt create mode 100644 tests/baselines/reference/parserForOfStatement13.errors.txt create mode 100644 tests/baselines/reference/parserForOfStatement14.errors.txt create mode 100644 tests/baselines/reference/parserForOfStatement15.errors.txt create mode 100644 tests/baselines/reference/parserForOfStatement16.errors.txt create mode 100644 tests/baselines/reference/parserForOfStatement8.errors.txt delete mode 100644 tests/baselines/reference/parserForOfStatement8.types create mode 100644 tests/baselines/reference/parserForOfStatement9.errors.txt delete mode 100644 tests/baselines/reference/parserForOfStatement9.types diff --git a/tests/baselines/reference/constDeclarations-errors.errors.txt b/tests/baselines/reference/constDeclarations-errors.errors.txt index c0ae6635c5e..c8d25b05e54 100644 --- a/tests/baselines/reference/constDeclarations-errors.errors.txt +++ b/tests/baselines/reference/constDeclarations-errors.errors.txt @@ -4,13 +4,12 @@ tests/cases/compiler/constDeclarations-errors.ts(5,7): error TS1155: 'const' dec tests/cases/compiler/constDeclarations-errors.ts(5,11): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(5,15): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(5,27): error TS1155: 'const' declarations must be initialized -tests/cases/compiler/constDeclarations-errors.ts(8,11): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(11,27): error TS2449: The operand of an increment or decrement operator cannot be a constant. tests/cases/compiler/constDeclarations-errors.ts(14,11): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(17,20): error TS1155: 'const' declarations must be initialized -==== tests/cases/compiler/constDeclarations-errors.ts (10 errors) ==== +==== tests/cases/compiler/constDeclarations-errors.ts (9 errors) ==== // error, missing intialicer const c1; @@ -31,8 +30,6 @@ tests/cases/compiler/constDeclarations-errors.ts(17,20): error TS1155: 'const' d // error, can not be unintalized for(const c in {}) { } - ~ -!!! error TS1155: 'const' declarations must be initialized // error, assigning to a const for(const c8 = 0; c8 < 1; c8++) { } diff --git a/tests/baselines/reference/for-of4.types b/tests/baselines/reference/for-of4.types new file mode 100644 index 00000000000..2076fae84fc --- /dev/null +++ b/tests/baselines/reference/for-of4.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of4.ts === +for (var v of [0]) { +>v : number +>[0] : number[] + + v; +>v : number +} diff --git a/tests/baselines/reference/for-of5.types b/tests/baselines/reference/for-of5.types new file mode 100644 index 00000000000..feac5ef9e52 --- /dev/null +++ b/tests/baselines/reference/for-of5.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of5.ts === +for (let v of [0]) { +>v : number +>[0] : number[] + + v; +>v : number +} diff --git a/tests/baselines/reference/for-of8.types b/tests/baselines/reference/for-of8.types new file mode 100644 index 00000000000..5f239d141fe --- /dev/null +++ b/tests/baselines/reference/for-of8.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of8.ts === +v; +>v : number + +for (var v of [0]) { } +>v : number +>[0] : number[] + diff --git a/tests/baselines/reference/parserForOfStatement1.d.errors.txt b/tests/baselines/reference/parserForOfStatement1.d.errors.txt index 3b1b2a65922..c492c7817e8 100644 --- a/tests/baselines/reference/parserForOfStatement1.d.errors.txt +++ b/tests/baselines/reference/parserForOfStatement1.d.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement1.d.ts(1,1): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement1.d.ts(1,15): error TS2304: Cannot find name 'e'. -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement1.d.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement1.d.ts (2 errors) ==== for (var i of e) { ~~~ !!! error TS1036: Statements are not allowed in ambient contexts. + ~ +!!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement10.errors.txt b/tests/baselines/reference/parserForOfStatement10.errors.txt new file mode 100644 index 00000000000..d2fc73e6b68 --- /dev/null +++ b/tests/baselines/reference/parserForOfStatement10.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement10.ts(1,17): error TS2304: Cannot find name 'X'. + + +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement10.ts (1 errors) ==== + for (const v of X) { + ~ +!!! error TS2304: Cannot find name 'X'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement11.errors.txt b/tests/baselines/reference/parserForOfStatement11.errors.txt new file mode 100644 index 00000000000..2c5af586ae3 --- /dev/null +++ b/tests/baselines/reference/parserForOfStatement11.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement11.ts(1,22): error TS2304: Cannot find name 'X'. + + +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement11.ts (1 errors) ==== + for (const [a, b] of X) { + ~ +!!! error TS2304: Cannot find name 'X'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement12.errors.txt b/tests/baselines/reference/parserForOfStatement12.errors.txt new file mode 100644 index 00000000000..951b70eac35 --- /dev/null +++ b/tests/baselines/reference/parserForOfStatement12.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement12.ts(1,22): error TS2304: Cannot find name 'X'. + + +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement12.ts (1 errors) ==== + for (const {a, b} of X) { + ~ +!!! error TS2304: Cannot find name 'X'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement13.errors.txt b/tests/baselines/reference/parserForOfStatement13.errors.txt new file mode 100644 index 00000000000..c789ab89d9a --- /dev/null +++ b/tests/baselines/reference/parserForOfStatement13.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement13.ts(1,20): error TS2304: Cannot find name 'X'. + + +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement13.ts (1 errors) ==== + for (let {a, b} of X) { + ~ +!!! error TS2304: Cannot find name 'X'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement14.errors.txt b/tests/baselines/reference/parserForOfStatement14.errors.txt new file mode 100644 index 00000000000..46e71e5242f --- /dev/null +++ b/tests/baselines/reference/parserForOfStatement14.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement14.ts(1,20): error TS2304: Cannot find name 'X'. + + +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement14.ts (1 errors) ==== + for (let [a, b] of X) { + ~ +!!! error TS2304: Cannot find name 'X'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement15.errors.txt b/tests/baselines/reference/parserForOfStatement15.errors.txt new file mode 100644 index 00000000000..0f159c7a25a --- /dev/null +++ b/tests/baselines/reference/parserForOfStatement15.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement15.ts(1,20): error TS2304: Cannot find name 'X'. + + +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement15.ts (1 errors) ==== + for (var [a, b] of X) { + ~ +!!! error TS2304: Cannot find name 'X'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement16.errors.txt b/tests/baselines/reference/parserForOfStatement16.errors.txt new file mode 100644 index 00000000000..3d950fd145d --- /dev/null +++ b/tests/baselines/reference/parserForOfStatement16.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement16.ts(1,20): error TS2304: Cannot find name 'X'. + + +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement16.ts (1 errors) ==== + for (var {a, b} of X) { + ~ +!!! error TS2304: Cannot find name 'X'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement3.errors.txt b/tests/baselines/reference/parserForOfStatement3.errors.txt index 995ef4637c2..a565ae37d32 100644 --- a/tests/baselines/reference/parserForOfStatement3.errors.txt +++ b/tests/baselines/reference/parserForOfStatement3.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement3.ts(1,13): error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement3.ts(1,18): error TS2304: Cannot find name 'X'. -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement3.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement3.ts (2 errors) ==== for (var a, b of X) { ~ !!! error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement4.errors.txt b/tests/baselines/reference/parserForOfStatement4.errors.txt index 65b4bf342f2..97873682082 100644 --- a/tests/baselines/reference/parserForOfStatement4.errors.txt +++ b/tests/baselines/reference/parserForOfStatement4.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement4.ts(1,10): error TS1190: The variable declaration of a 'for...of' statement cannot have an initializer. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement4.ts(1,19): error TS2304: Cannot find name 'X'. -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement4.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement4.ts (2 errors) ==== for (var a = 1 of X) { ~ !!! error TS1190: The variable declaration of a 'for...of' statement cannot have an initializer. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement5.errors.txt b/tests/baselines/reference/parserForOfStatement5.errors.txt index 13fd8739866..e3ed3235910 100644 --- a/tests/baselines/reference/parserForOfStatement5.errors.txt +++ b/tests/baselines/reference/parserForOfStatement5.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement5.ts(1,10): error TS2483: The left-hand side of a 'for...of' statement cannot use a type annotation. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement5.ts(1,23): error TS2304: Cannot find name 'X'. -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement5.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement5.ts (2 errors) ==== for (var a: number of X) { ~ !!! error TS2483: The left-hand side of a 'for...of' statement cannot use a type annotation. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement6.errors.txt b/tests/baselines/reference/parserForOfStatement6.errors.txt index 57d95361b65..59a18f03bcd 100644 --- a/tests/baselines/reference/parserForOfStatement6.errors.txt +++ b/tests/baselines/reference/parserForOfStatement6.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement6.ts(1,17): error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement6.ts(1,26): error TS2304: Cannot find name 'X'. -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement6.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement6.ts (2 errors) ==== for (var a = 1, b = 2 of X) { ~ !!! error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement7.errors.txt b/tests/baselines/reference/parserForOfStatement7.errors.txt index 07f93c263ec..f5ab97b4413 100644 --- a/tests/baselines/reference/parserForOfStatement7.errors.txt +++ b/tests/baselines/reference/parserForOfStatement7.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement7.ts(1,25): error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement7.ts(1,43): error TS2304: Cannot find name 'X'. -==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement7.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement7.ts (2 errors) ==== for (var a: number = 1, b: string = "" of X) { ~ !!! error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. + ~ +!!! error TS2304: Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement8.errors.txt b/tests/baselines/reference/parserForOfStatement8.errors.txt new file mode 100644 index 00000000000..5fe9bb43415 --- /dev/null +++ b/tests/baselines/reference/parserForOfStatement8.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement8.ts(1,15): error TS2304: Cannot find name 'X'. + + +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement8.ts (1 errors) ==== + for (var v of X) { + ~ +!!! error TS2304: Cannot find name 'X'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement8.types b/tests/baselines/reference/parserForOfStatement8.types deleted file mode 100644 index a4168caf262..00000000000 --- a/tests/baselines/reference/parserForOfStatement8.types +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement8.ts === -for (var v of X) { ->v : any ->X : unknown -} diff --git a/tests/baselines/reference/parserForOfStatement9.errors.txt b/tests/baselines/reference/parserForOfStatement9.errors.txt new file mode 100644 index 00000000000..fae9beec253 --- /dev/null +++ b/tests/baselines/reference/parserForOfStatement9.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement9.ts(1,15): error TS2304: Cannot find name 'X'. + + +==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement9.ts (1 errors) ==== + for (let v of X) { + ~ +!!! error TS2304: Cannot find name 'X'. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement9.types b/tests/baselines/reference/parserForOfStatement9.types deleted file mode 100644 index 0285a3e4b76..00000000000 --- a/tests/baselines/reference/parserForOfStatement9.types +++ /dev/null @@ -1,5 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement9.ts === -for (let v of X) { ->v : any ->X : unknown -} From 2858771a54b7c426b5131fd3e47bdf93f2a3a6f2 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 23 Feb 2015 19:07:29 -0800 Subject: [PATCH 63/96] Check iterable structure of the right hand side of 'for...of' statement --- src/compiler/checker.ts | 24 +++++++++++++++---- .../diagnosticInformationMap.generated.ts | 3 +++ src/compiler/diagnosticMessages.json | 12 ++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5a9e9575bca..efd101d8c06 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8768,7 +8768,7 @@ module ts { var leftType = checkExpression(varExpr); checkReferenceExpression(varExpr, Diagnostics.Invalid_left_hand_side_in_for_of_statement, Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); var rightType = checkExpression(node.expression); - var iteratedType = getIteratedType(rightType); + var iteratedType = getIteratedType(rightType, node.expression); checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); } @@ -8831,7 +8831,7 @@ module ts { var links = getNodeLinks(variable); if (!links.resolvedType) { links.resolvedType = resolvingType; - var type = getIteratedType(getTypeOfExpression(forOfStatement.expression)); + var type = getIteratedType(getTypeOfExpression(forOfStatement.expression), forOfStatement.expression); if (links.resolvedType === resolvingType) { links.resolvedType = type; } @@ -8843,7 +8843,7 @@ module ts { return links.resolvedType; } - function getIteratedType(iterable: Type): Type { + function getIteratedType(iterable: Type, expressionForError: Expression): Type { Debug.assert(languageVersion >= ScriptTarget.ES6); if (allConstituentTypesHaveKind(iterable, TypeFlags.Any)) { return anyType; @@ -8867,14 +8867,28 @@ module ts { // T is the type we are after. At every level that involves analyzing return types // of signatures, we union the return types of all the signatures. var iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator")); - var iteratorFunctionSignatures = getSignaturesOfType(iteratorFunction, SignatureKind.Call); + var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray; + if (iteratorFunctionSignatures.length === 0) { + error(expressionForError, Diagnostics.The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + return unknownType; + } + var iterator = getUnionType(map(iteratorFunctionSignatures, getReturnTypeOfSignature)); var iteratorNextFunction = getTypeOfPropertyOfType(iterator, "next"); - var iteratorNextFunctionSignatures = getSignaturesOfType(iteratorNextFunction, SignatureKind.Call); + var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray; + if (iteratorNextFunctionSignatures.length === 0) { + error(expressionForError, Diagnostics.The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method); + return unknownType; + } + var iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); + if (!iteratorNextValue) { + error(expressionForError, Diagnostics.The_object_returned_by_the_next_method_of_the_iterator_must_have_a_value_property); + return unknownType; + } return iteratorNextValue; // TODO diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 35b5ca5cdc3..08de6681226 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -329,6 +329,9 @@ module ts { The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." }, + The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." }, + The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." }, + The_object_returned_by_the_next_method_of_the_iterator_must_have_a_value_property: { code: 2490, category: DiagnosticCategory.Error, key: "The object returned by the next method of the iterator must have a 'value' property." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8b57778a696..45661c570c2 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1308,6 +1308,18 @@ "category": "Error", "code": 2487 }, + "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator.": { + "category": "Error", + "code": 2488 + }, + "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method.": { + "category": "Error", + "code": 2489 + }, + "The object returned by the next method of the iterator must have a 'value' property.": { + "category": "Error", + "code": 2490 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", From 3d5c113bee2d75cc0aa754b6c43cf3773b116310 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 23 Feb 2015 19:07:45 -0800 Subject: [PATCH 64/96] Iterator tests --- tests/baselines/reference/for-of14.errors.txt | 14 ++++++++ tests/baselines/reference/for-of14.js | 21 +++++++++++ tests/baselines/reference/for-of15.errors.txt | 17 +++++++++ tests/baselines/reference/for-of15.js | 27 ++++++++++++++ tests/baselines/reference/for-of16.errors.txt | 14 ++++++++ tests/baselines/reference/for-of16.js | 21 +++++++++++ tests/baselines/reference/for-of17.errors.txt | 20 +++++++++++ tests/baselines/reference/for-of17.js | 33 +++++++++++++++++ tests/baselines/reference/for-of18.js | 33 +++++++++++++++++ tests/baselines/reference/for-of18.types | 35 +++++++++++++++++++ .../es6/for-ofStatements/for-of14.ts | 2 +- .../es6/for-ofStatements/for-of15.ts | 4 +-- .../es6/for-ofStatements/for-of16.ts | 7 ++-- .../es6/for-ofStatements/for-of17.ts | 9 +++-- .../es6/for-ofStatements/for-of18.ts | 2 +- .../es6/for-ofStatements/for-of19.ts | 15 -------- 16 files changed, 247 insertions(+), 27 deletions(-) create mode 100644 tests/baselines/reference/for-of14.errors.txt create mode 100644 tests/baselines/reference/for-of14.js create mode 100644 tests/baselines/reference/for-of15.errors.txt create mode 100644 tests/baselines/reference/for-of15.js create mode 100644 tests/baselines/reference/for-of16.errors.txt create mode 100644 tests/baselines/reference/for-of16.js create mode 100644 tests/baselines/reference/for-of17.errors.txt create mode 100644 tests/baselines/reference/for-of17.js create mode 100644 tests/baselines/reference/for-of18.js create mode 100644 tests/baselines/reference/for-of18.types delete mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of19.ts diff --git a/tests/baselines/reference/for-of14.errors.txt b/tests/baselines/reference/for-of14.errors.txt new file mode 100644 index 00000000000..5e8223381c7 --- /dev/null +++ b/tests/baselines/reference/for-of14.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/es6/for-ofStatements/for-of14.ts(2,11): error TS2488: The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of14.ts (1 errors) ==== + var v: string; + for (v of new StringIterator) { } // Should fail because the iterator is not iterable + ~~~~~~~~~~~~~~~~~~ +!!! error TS2488: The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator. + + class StringIterator { + next() { + return ""; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of14.js b/tests/baselines/reference/for-of14.js new file mode 100644 index 00000000000..d5f9e29b766 --- /dev/null +++ b/tests/baselines/reference/for-of14.js @@ -0,0 +1,21 @@ +//// [for-of14.ts] +var v: string; +for (v of new StringIterator) { } // Should fail because the iterator is not iterable + +class StringIterator { + next() { + return ""; + } +} + +//// [for-of14.js] +var v; +for (v of new StringIterator) { } // Should fail because the iterator is not iterable +var StringIterator = (function () { + function StringIterator() { + } + StringIterator.prototype.next = function () { + return ""; + }; + return StringIterator; +})(); diff --git a/tests/baselines/reference/for-of15.errors.txt b/tests/baselines/reference/for-of15.errors.txt new file mode 100644 index 00000000000..ab6b6c03ea7 --- /dev/null +++ b/tests/baselines/reference/for-of15.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/es6/for-ofStatements/for-of15.ts(2,11): error TS2490: The object returned by the next method of the iterator must have a 'value' property. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of15.ts (1 errors) ==== + var v: string; + for (v of new StringIterator) { } // Should fail + ~~~~~~~~~~~~~~~~~~ +!!! error TS2490: The object returned by the next method of the iterator must have a 'value' property. + + class StringIterator { + next() { + return ""; + } + [Symbol.iterator]() { + return this; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of15.js b/tests/baselines/reference/for-of15.js new file mode 100644 index 00000000000..36955389756 --- /dev/null +++ b/tests/baselines/reference/for-of15.js @@ -0,0 +1,27 @@ +//// [for-of15.ts] +var v: string; +for (v of new StringIterator) { } // Should fail + +class StringIterator { + next() { + return ""; + } + [Symbol.iterator]() { + return this; + } +} + +//// [for-of15.js] +var v; +for (v of new StringIterator) { } // Should fail +var StringIterator = (function () { + function StringIterator() { + } + StringIterator.prototype.next = function () { + return ""; + }; + StringIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return StringIterator; +})(); diff --git a/tests/baselines/reference/for-of16.errors.txt b/tests/baselines/reference/for-of16.errors.txt new file mode 100644 index 00000000000..e3ecca1a256 --- /dev/null +++ b/tests/baselines/reference/for-of16.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/es6/for-ofStatements/for-of16.ts(2,11): error TS2489: The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of16.ts (1 errors) ==== + var v: string; + for (v of new StringIterator) { } // Should fail + ~~~~~~~~~~~~~~~~~~ +!!! error TS2489: The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method. + + class StringIterator { + [Symbol.iterator]() { + return this; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of16.js b/tests/baselines/reference/for-of16.js new file mode 100644 index 00000000000..21ba2adb75c --- /dev/null +++ b/tests/baselines/reference/for-of16.js @@ -0,0 +1,21 @@ +//// [for-of16.ts] +var v: string; +for (v of new StringIterator) { } // Should fail + +class StringIterator { + [Symbol.iterator]() { + return this; + } +} + +//// [for-of16.js] +var v; +for (v of new StringIterator) { } // Should fail +var StringIterator = (function () { + function StringIterator() { + } + StringIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return StringIterator; +})(); diff --git a/tests/baselines/reference/for-of17.errors.txt b/tests/baselines/reference/for-of17.errors.txt new file mode 100644 index 00000000000..dfdeb8db007 --- /dev/null +++ b/tests/baselines/reference/for-of17.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/es6/for-ofStatements/for-of17.ts(2,6): error TS2322: Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of17.ts (1 errors) ==== + var v: string; + for (v of new NumberIterator) { } // Should succeed + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + class NumberIterator { + next() { + return { + value: 0, + done: false + }; + } + [Symbol.iterator]() { + return this; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of17.js b/tests/baselines/reference/for-of17.js new file mode 100644 index 00000000000..5c56cdab445 --- /dev/null +++ b/tests/baselines/reference/for-of17.js @@ -0,0 +1,33 @@ +//// [for-of17.ts] +var v: string; +for (v of new NumberIterator) { } // Should succeed + +class NumberIterator { + next() { + return { + value: 0, + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} + +//// [for-of17.js] +var v; +for (v of new NumberIterator) { } // Should succeed +var NumberIterator = (function () { + function NumberIterator() { + } + NumberIterator.prototype.next = function () { + return { + value: 0, + done: false + }; + }; + NumberIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return NumberIterator; +})(); diff --git a/tests/baselines/reference/for-of18.js b/tests/baselines/reference/for-of18.js new file mode 100644 index 00000000000..57168d9bf07 --- /dev/null +++ b/tests/baselines/reference/for-of18.js @@ -0,0 +1,33 @@ +//// [for-of18.ts] +var v: string; +for (v of new StringIterator) { } // Should succeed + +class StringIterator { + next() { + return { + value: "", + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} + +//// [for-of18.js] +var v; +for (v of new StringIterator) { } // Should succeed +var StringIterator = (function () { + function StringIterator() { + } + StringIterator.prototype.next = function () { + return { + value: "", + done: false + }; + }; + StringIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return StringIterator; +})(); diff --git a/tests/baselines/reference/for-of18.types b/tests/baselines/reference/for-of18.types new file mode 100644 index 00000000000..9ade9359475 --- /dev/null +++ b/tests/baselines/reference/for-of18.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of18.ts === +var v: string; +>v : string + +for (v of new StringIterator) { } // Should succeed +>v : string +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + +class StringIterator { +>StringIterator : StringIterator + + next() { +>next : () => { value: string; done: boolean; } + + return { +>{ value: "", done: false } : { value: string; done: boolean; } + + value: "", +>value : string + + done: false +>done : boolean + + }; + } + [Symbol.iterator]() { +>Symbol.iterator : symbol +>Symbol : SymbolConstructor +>iterator : symbol + + return this; +>this : StringIterator + } +} diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of14.ts b/tests/cases/conformance/es6/for-ofStatements/for-of14.ts index 8bb3e959501..84fbda4825c 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of14.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of14.ts @@ -2,7 +2,7 @@ var v: string; for (v of new StringIterator) { } // Should fail because the iterator is not iterable -class StringIterator implements Iterator { +class StringIterator { next() { return ""; } diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of15.ts b/tests/cases/conformance/es6/for-ofStatements/for-of15.ts index 87ff3e9603d..1973e7ff95e 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of15.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of15.ts @@ -1,8 +1,8 @@ //@target: ES6 var v: string; -for (v of new StringIterator) { } // Should succeed +for (v of new StringIterator) { } // Should fail -class StringIterator implements Iterator { +class StringIterator { next() { return ""; } diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of16.ts b/tests/cases/conformance/es6/for-ofStatements/for-of16.ts index 92b3b4e6de5..8f7bd6d8486 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of16.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of16.ts @@ -1,11 +1,8 @@ //@target: ES6 var v: string; -for (v of (new StringIterator)[Symbol.iterator]()) { } // Should succeed +for (v of new StringIterator) { } // Should fail -class StringIterator implements Iterator { - next() { - return ""; - } +class StringIterator { [Symbol.iterator]() { return this; } diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of17.ts b/tests/cases/conformance/es6/for-ofStatements/for-of17.ts index 819e9218bd1..431f066d477 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of17.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of17.ts @@ -1,10 +1,13 @@ //@target: ES6 -var v: number; -for (v of (new NumberIterator)[Symbol.iterator]().next()) { } // Should fail +var v: string; +for (v of new NumberIterator) { } // Should succeed class NumberIterator { next() { - return 0; + return { + value: 0, + done: false + }; } [Symbol.iterator]() { return this; diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of18.ts b/tests/cases/conformance/es6/for-ofStatements/for-of18.ts index 10e566cf64c..407ad7f0ed8 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of18.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of18.ts @@ -1,6 +1,6 @@ //@target: ES6 var v: string; -for (v of (new StringIterator)[Symbol.iterator]().next()) { } // Should succeed +for (v of new StringIterator) { } // Should succeed class StringIterator { next() { diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of19.ts b/tests/cases/conformance/es6/for-ofStatements/for-of19.ts deleted file mode 100644 index 1e45c32e8ad..00000000000 --- a/tests/cases/conformance/es6/for-ofStatements/for-of19.ts +++ /dev/null @@ -1,15 +0,0 @@ -//@target: ES6 -var v: string; -for (v of (new StringIterator)[Symbol.iterator]().next()) { } // Should fail - -class StringIterator { - next() { - return { - value: 0, - done: false - }; - } - [Symbol.iterator]() { - return this; - } -} \ No newline at end of file From 057108646d67e75fbbfdd9d2f9651b96a2b896ee Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 24 Feb 2015 11:31:42 -0800 Subject: [PATCH 65/96] More tests --- tests/baselines/reference/for-of19.js | 41 ++++++++++++++++++ tests/baselines/reference/for-of19.types | 41 ++++++++++++++++++ tests/baselines/reference/for-of20.js | 41 ++++++++++++++++++ tests/baselines/reference/for-of20.types | 41 ++++++++++++++++++ tests/baselines/reference/for-of21.js | 41 ++++++++++++++++++ tests/baselines/reference/for-of21.types | 41 ++++++++++++++++++ tests/baselines/reference/for-of22.js | 42 +++++++++++++++++++ tests/baselines/reference/for-of22.types | 42 +++++++++++++++++++ tests/baselines/reference/for-of23.js | 41 ++++++++++++++++++ tests/baselines/reference/for-of23.types | 41 ++++++++++++++++++ .../es6/for-ofStatements/for-of19.ts | 17 ++++++++ .../es6/for-ofStatements/for-of20.ts | 17 ++++++++ .../es6/for-ofStatements/for-of21.ts | 17 ++++++++ .../es6/for-ofStatements/for-of22.ts | 18 ++++++++ .../es6/for-ofStatements/for-of23.ts | 17 ++++++++ 15 files changed, 498 insertions(+) create mode 100644 tests/baselines/reference/for-of19.js create mode 100644 tests/baselines/reference/for-of19.types create mode 100644 tests/baselines/reference/for-of20.js create mode 100644 tests/baselines/reference/for-of20.types create mode 100644 tests/baselines/reference/for-of21.js create mode 100644 tests/baselines/reference/for-of21.types create mode 100644 tests/baselines/reference/for-of22.js create mode 100644 tests/baselines/reference/for-of22.types create mode 100644 tests/baselines/reference/for-of23.js create mode 100644 tests/baselines/reference/for-of23.types create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of19.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of20.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of21.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of22.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of23.ts diff --git a/tests/baselines/reference/for-of19.js b/tests/baselines/reference/for-of19.js new file mode 100644 index 00000000000..eefb9339f18 --- /dev/null +++ b/tests/baselines/reference/for-of19.js @@ -0,0 +1,41 @@ +//// [for-of19.ts] +for (var v of new FooIterator) { + v; +} + +class Foo { } +class FooIterator { + next() { + return { + value: new Foo, + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} + +//// [for-of19.js] +for (var v of new FooIterator) { + v; +} +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +var FooIterator = (function () { + function FooIterator() { + } + FooIterator.prototype.next = function () { + return { + value: new Foo, + done: false + }; + }; + FooIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return FooIterator; +})(); diff --git a/tests/baselines/reference/for-of19.types b/tests/baselines/reference/for-of19.types new file mode 100644 index 00000000000..49172b09d83 --- /dev/null +++ b/tests/baselines/reference/for-of19.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of19.ts === +for (var v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + + v; +>v : Foo +} + +class Foo { } +>Foo : Foo + +class FooIterator { +>FooIterator : FooIterator + + next() { +>next : () => { value: Foo; done: boolean; } + + return { +>{ value: new Foo, done: false } : { value: Foo; done: boolean; } + + value: new Foo, +>value : Foo +>new Foo : Foo +>Foo : typeof Foo + + done: false +>done : boolean + + }; + } + [Symbol.iterator]() { +>Symbol.iterator : symbol +>Symbol : SymbolConstructor +>iterator : symbol + + return this; +>this : FooIterator + } +} diff --git a/tests/baselines/reference/for-of20.js b/tests/baselines/reference/for-of20.js new file mode 100644 index 00000000000..39b1081954b --- /dev/null +++ b/tests/baselines/reference/for-of20.js @@ -0,0 +1,41 @@ +//// [for-of20.ts] +for (let v of new FooIterator) { + v; +} + +class Foo { } +class FooIterator { + next() { + return { + value: new Foo, + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} + +//// [for-of20.js] +for (let v of new FooIterator) { + v; +} +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +var FooIterator = (function () { + function FooIterator() { + } + FooIterator.prototype.next = function () { + return { + value: new Foo, + done: false + }; + }; + FooIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return FooIterator; +})(); diff --git a/tests/baselines/reference/for-of20.types b/tests/baselines/reference/for-of20.types new file mode 100644 index 00000000000..e967869fbd0 --- /dev/null +++ b/tests/baselines/reference/for-of20.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of20.ts === +for (let v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + + v; +>v : Foo +} + +class Foo { } +>Foo : Foo + +class FooIterator { +>FooIterator : FooIterator + + next() { +>next : () => { value: Foo; done: boolean; } + + return { +>{ value: new Foo, done: false } : { value: Foo; done: boolean; } + + value: new Foo, +>value : Foo +>new Foo : Foo +>Foo : typeof Foo + + done: false +>done : boolean + + }; + } + [Symbol.iterator]() { +>Symbol.iterator : symbol +>Symbol : SymbolConstructor +>iterator : symbol + + return this; +>this : FooIterator + } +} diff --git a/tests/baselines/reference/for-of21.js b/tests/baselines/reference/for-of21.js new file mode 100644 index 00000000000..c11514b192c --- /dev/null +++ b/tests/baselines/reference/for-of21.js @@ -0,0 +1,41 @@ +//// [for-of21.ts] +for (const v of new FooIterator) { + v; +} + +class Foo { } +class FooIterator { + next() { + return { + value: new Foo, + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} + +//// [for-of21.js] +for (var v of new FooIterator) { + v; +} +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +var FooIterator = (function () { + function FooIterator() { + } + FooIterator.prototype.next = function () { + return { + value: new Foo, + done: false + }; + }; + FooIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return FooIterator; +})(); diff --git a/tests/baselines/reference/for-of21.types b/tests/baselines/reference/for-of21.types new file mode 100644 index 00000000000..362f92577e2 --- /dev/null +++ b/tests/baselines/reference/for-of21.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of21.ts === +for (const v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + + v; +>v : Foo +} + +class Foo { } +>Foo : Foo + +class FooIterator { +>FooIterator : FooIterator + + next() { +>next : () => { value: Foo; done: boolean; } + + return { +>{ value: new Foo, done: false } : { value: Foo; done: boolean; } + + value: new Foo, +>value : Foo +>new Foo : Foo +>Foo : typeof Foo + + done: false +>done : boolean + + }; + } + [Symbol.iterator]() { +>Symbol.iterator : symbol +>Symbol : SymbolConstructor +>iterator : symbol + + return this; +>this : FooIterator + } +} diff --git a/tests/baselines/reference/for-of22.js b/tests/baselines/reference/for-of22.js new file mode 100644 index 00000000000..d38accb6cd8 --- /dev/null +++ b/tests/baselines/reference/for-of22.js @@ -0,0 +1,42 @@ +//// [for-of22.ts] +v; +for (var v of new FooIterator) { + +} + +class Foo { } +class FooIterator { + next() { + return { + value: new Foo, + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} + +//// [for-of22.js] +v; +for (var v of new FooIterator) { +} +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +var FooIterator = (function () { + function FooIterator() { + } + FooIterator.prototype.next = function () { + return { + value: new Foo, + done: false + }; + }; + FooIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return FooIterator; +})(); diff --git a/tests/baselines/reference/for-of22.types b/tests/baselines/reference/for-of22.types new file mode 100644 index 00000000000..bb2d5569bfc --- /dev/null +++ b/tests/baselines/reference/for-of22.types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of22.ts === +v; +>v : Foo + +for (var v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + +} + +class Foo { } +>Foo : Foo + +class FooIterator { +>FooIterator : FooIterator + + next() { +>next : () => { value: Foo; done: boolean; } + + return { +>{ value: new Foo, done: false } : { value: Foo; done: boolean; } + + value: new Foo, +>value : Foo +>new Foo : Foo +>Foo : typeof Foo + + done: false +>done : boolean + + }; + } + [Symbol.iterator]() { +>Symbol.iterator : symbol +>Symbol : SymbolConstructor +>iterator : symbol + + return this; +>this : FooIterator + } +} diff --git a/tests/baselines/reference/for-of23.js b/tests/baselines/reference/for-of23.js new file mode 100644 index 00000000000..943c5b6cecb --- /dev/null +++ b/tests/baselines/reference/for-of23.js @@ -0,0 +1,41 @@ +//// [for-of23.ts] +for (const v of new FooIterator) { + const v = 0; // new scope +} + +class Foo { } +class FooIterator { + next() { + return { + value: new Foo, + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} + +//// [for-of23.js] +for (var v of new FooIterator) { + const v = 0; // new scope +} +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +var FooIterator = (function () { + function FooIterator() { + } + FooIterator.prototype.next = function () { + return { + value: new Foo, + done: false + }; + }; + FooIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return FooIterator; +})(); diff --git a/tests/baselines/reference/for-of23.types b/tests/baselines/reference/for-of23.types new file mode 100644 index 00000000000..b490616edc8 --- /dev/null +++ b/tests/baselines/reference/for-of23.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of23.ts === +for (const v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + + const v = 0; // new scope +>v : number +} + +class Foo { } +>Foo : Foo + +class FooIterator { +>FooIterator : FooIterator + + next() { +>next : () => { value: Foo; done: boolean; } + + return { +>{ value: new Foo, done: false } : { value: Foo; done: boolean; } + + value: new Foo, +>value : Foo +>new Foo : Foo +>Foo : typeof Foo + + done: false +>done : boolean + + }; + } + [Symbol.iterator]() { +>Symbol.iterator : symbol +>Symbol : SymbolConstructor +>iterator : symbol + + return this; +>this : FooIterator + } +} diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of19.ts b/tests/cases/conformance/es6/for-ofStatements/for-of19.ts new file mode 100644 index 00000000000..ff80b2690ef --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of19.ts @@ -0,0 +1,17 @@ +//@target: ES6 +for (var v of new FooIterator) { + v; +} + +class Foo { } +class FooIterator { + next() { + return { + value: new Foo, + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of20.ts b/tests/cases/conformance/es6/for-ofStatements/for-of20.ts new file mode 100644 index 00000000000..615f5149375 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of20.ts @@ -0,0 +1,17 @@ +//@target: ES6 +for (let v of new FooIterator) { + v; +} + +class Foo { } +class FooIterator { + next() { + return { + value: new Foo, + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of21.ts b/tests/cases/conformance/es6/for-ofStatements/for-of21.ts new file mode 100644 index 00000000000..4e4621034e1 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of21.ts @@ -0,0 +1,17 @@ +//@target: ES6 +for (const v of new FooIterator) { + v; +} + +class Foo { } +class FooIterator { + next() { + return { + value: new Foo, + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of22.ts b/tests/cases/conformance/es6/for-ofStatements/for-of22.ts new file mode 100644 index 00000000000..10a96502cdd --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of22.ts @@ -0,0 +1,18 @@ +//@target: ES6 +v; +for (var v of new FooIterator) { + +} + +class Foo { } +class FooIterator { + next() { + return { + value: new Foo, + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of23.ts b/tests/cases/conformance/es6/for-ofStatements/for-of23.ts new file mode 100644 index 00000000000..81227cd0665 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of23.ts @@ -0,0 +1,17 @@ +//@target: ES6 +for (const v of new FooIterator) { + const v = 0; // new scope +} + +class Foo { } +class FooIterator { + next() { + return { + value: new Foo, + done: false + }; + } + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file From 732637dd5427944793e23893663862ce92844563 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 24 Feb 2015 13:35:42 -0800 Subject: [PATCH 66/96] Fix getIteratedType to work with 'any' at all levels --- src/compiler/checker.ts | 16 ++++++++++- tests/baselines/reference/for-of24.js | 8 ++++++ tests/baselines/reference/for-of24.types | 8 ++++++ tests/baselines/reference/for-of25.js | 21 +++++++++++++++ tests/baselines/reference/for-of25.types | 21 +++++++++++++++ tests/baselines/reference/for-of26.js | 27 +++++++++++++++++++ tests/baselines/reference/for-of26.types | 27 +++++++++++++++++++ tests/baselines/reference/for-of27.js | 14 ++++++++++ tests/baselines/reference/for-of27.types | 14 ++++++++++ tests/baselines/reference/for-of28.js | 20 ++++++++++++++ tests/baselines/reference/for-of28.types | 21 +++++++++++++++ .../es6/for-ofStatements/for-of24.ts | 3 +++ .../es6/for-ofStatements/for-of25.ts | 9 +++++++ .../es6/for-ofStatements/for-of26.ts | 12 +++++++++ .../es6/for-ofStatements/for-of27.ts | 6 +++++ .../es6/for-ofStatements/for-of28.ts | 9 +++++++ 16 files changed, 235 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/for-of24.js create mode 100644 tests/baselines/reference/for-of24.types create mode 100644 tests/baselines/reference/for-of25.js create mode 100644 tests/baselines/reference/for-of25.types create mode 100644 tests/baselines/reference/for-of26.js create mode 100644 tests/baselines/reference/for-of26.types create mode 100644 tests/baselines/reference/for-of27.js create mode 100644 tests/baselines/reference/for-of27.types create mode 100644 tests/baselines/reference/for-of28.js create mode 100644 tests/baselines/reference/for-of28.types create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of24.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of25.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of26.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of27.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of28.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index efd101d8c06..fd0724f3335 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8846,7 +8846,7 @@ module ts { function getIteratedType(iterable: Type, expressionForError: Expression): Type { Debug.assert(languageVersion >= ScriptTarget.ES6); if (allConstituentTypesHaveKind(iterable, TypeFlags.Any)) { - return anyType; + return iterable; // any or unknown } // We want to treat type as an iterable, and get the type it is an iterable of. The iterable @@ -8867,6 +8867,10 @@ module ts { // T is the type we are after. At every level that involves analyzing return types // of signatures, we union the return types of all the signatures. var iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator")); + if (iteratorFunction && allConstituentTypesHaveKind(iteratorFunction, TypeFlags.Any)) { + return iteratorFunction; // any or unknown + } + var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray; if (iteratorFunctionSignatures.length === 0) { error(expressionForError, Diagnostics.The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator); @@ -8874,8 +8878,15 @@ module ts { } var iterator = getUnionType(map(iteratorFunctionSignatures, getReturnTypeOfSignature)); + if (allConstituentTypesHaveKind(iterator, TypeFlags.Any)) { + return iterator; // any or unknown + } var iteratorNextFunction = getTypeOfPropertyOfType(iterator, "next"); + if (iteratorNextFunction && allConstituentTypesHaveKind(iteratorNextFunction, TypeFlags.Any)) { + return iteratorNextFunction; // any or unknown + } + var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray; if (iteratorNextFunctionSignatures.length === 0) { error(expressionForError, Diagnostics.The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method); @@ -8883,6 +8894,9 @@ module ts { } var iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); + if (allConstituentTypesHaveKind(iteratorNextResult, TypeFlags.Any)) { + return iteratorNextResult; // any or unknown + } var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); if (!iteratorNextValue) { diff --git a/tests/baselines/reference/for-of24.js b/tests/baselines/reference/for-of24.js new file mode 100644 index 00000000000..b4918519603 --- /dev/null +++ b/tests/baselines/reference/for-of24.js @@ -0,0 +1,8 @@ +//// [for-of24.ts] +var x: any; +for (var v of x) { } + + +//// [for-of24.js] +var x; +for (var v of x) { } diff --git a/tests/baselines/reference/for-of24.types b/tests/baselines/reference/for-of24.types new file mode 100644 index 00000000000..dc27cc32e21 --- /dev/null +++ b/tests/baselines/reference/for-of24.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of24.ts === +var x: any; +>x : any + +for (var v of x) { } +>v : any +>x : any + diff --git a/tests/baselines/reference/for-of25.js b/tests/baselines/reference/for-of25.js new file mode 100644 index 00000000000..21b5ce1408b --- /dev/null +++ b/tests/baselines/reference/for-of25.js @@ -0,0 +1,21 @@ +//// [for-of25.ts] +var x: any; +for (var v of new StringIterator) { } + +class StringIterator { + [Symbol.iterator]() { + return x; + } +} + +//// [for-of25.js] +var x; +for (var v of new StringIterator) { } +var StringIterator = (function () { + function StringIterator() { + } + StringIterator.prototype[Symbol.iterator] = function () { + return x; + }; + return StringIterator; +})(); diff --git a/tests/baselines/reference/for-of25.types b/tests/baselines/reference/for-of25.types new file mode 100644 index 00000000000..c4d6b32aebc --- /dev/null +++ b/tests/baselines/reference/for-of25.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of25.ts === +var x: any; +>x : any + +for (var v of new StringIterator) { } +>v : any +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + +class StringIterator { +>StringIterator : StringIterator + + [Symbol.iterator]() { +>Symbol.iterator : symbol +>Symbol : SymbolConstructor +>iterator : symbol + + return x; +>x : any + } +} diff --git a/tests/baselines/reference/for-of26.js b/tests/baselines/reference/for-of26.js new file mode 100644 index 00000000000..a45492a81c0 --- /dev/null +++ b/tests/baselines/reference/for-of26.js @@ -0,0 +1,27 @@ +//// [for-of26.ts] +var x: any; +for (var v of new StringIterator) { } + +class StringIterator { + next() { + return x; + } + [Symbol.iterator]() { + return this; + } +} + +//// [for-of26.js] +var x; +for (var v of new StringIterator) { } +var StringIterator = (function () { + function StringIterator() { + } + StringIterator.prototype.next = function () { + return x; + }; + StringIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return StringIterator; +})(); diff --git a/tests/baselines/reference/for-of26.types b/tests/baselines/reference/for-of26.types new file mode 100644 index 00000000000..d2608fbf154 --- /dev/null +++ b/tests/baselines/reference/for-of26.types @@ -0,0 +1,27 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of26.ts === +var x: any; +>x : any + +for (var v of new StringIterator) { } +>v : any +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + +class StringIterator { +>StringIterator : StringIterator + + next() { +>next : () => any + + return x; +>x : any + } + [Symbol.iterator]() { +>Symbol.iterator : symbol +>Symbol : SymbolConstructor +>iterator : symbol + + return this; +>this : StringIterator + } +} diff --git a/tests/baselines/reference/for-of27.js b/tests/baselines/reference/for-of27.js new file mode 100644 index 00000000000..91e1e7194c1 --- /dev/null +++ b/tests/baselines/reference/for-of27.js @@ -0,0 +1,14 @@ +//// [for-of27.ts] +for (var v of new StringIterator) { } + +class StringIterator { + [Symbol.iterator]: any; +} + +//// [for-of27.js] +for (var v of new StringIterator) { } +var StringIterator = (function () { + function StringIterator() { + } + return StringIterator; +})(); diff --git a/tests/baselines/reference/for-of27.types b/tests/baselines/reference/for-of27.types new file mode 100644 index 00000000000..8e9130ce272 --- /dev/null +++ b/tests/baselines/reference/for-of27.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of27.ts === +for (var v of new StringIterator) { } +>v : any +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + +class StringIterator { +>StringIterator : StringIterator + + [Symbol.iterator]: any; +>Symbol.iterator : symbol +>Symbol : SymbolConstructor +>iterator : symbol +} diff --git a/tests/baselines/reference/for-of28.js b/tests/baselines/reference/for-of28.js new file mode 100644 index 00000000000..06029e6bb08 --- /dev/null +++ b/tests/baselines/reference/for-of28.js @@ -0,0 +1,20 @@ +//// [for-of28.ts] +for (var v of new StringIterator) { } + +class StringIterator { + next: any; + [Symbol.iterator]() { + return this; + } +} + +//// [for-of28.js] +for (var v of new StringIterator) { } +var StringIterator = (function () { + function StringIterator() { + } + StringIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return StringIterator; +})(); diff --git a/tests/baselines/reference/for-of28.types b/tests/baselines/reference/for-of28.types new file mode 100644 index 00000000000..91b77a55a4d --- /dev/null +++ b/tests/baselines/reference/for-of28.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of28.ts === +for (var v of new StringIterator) { } +>v : any +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + +class StringIterator { +>StringIterator : StringIterator + + next: any; +>next : any + + [Symbol.iterator]() { +>Symbol.iterator : symbol +>Symbol : SymbolConstructor +>iterator : symbol + + return this; +>this : StringIterator + } +} diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of24.ts b/tests/cases/conformance/es6/for-ofStatements/for-of24.ts new file mode 100644 index 00000000000..6f68821a0b5 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of24.ts @@ -0,0 +1,3 @@ +//@target: ES6 +var x: any; +for (var v of x) { } diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of25.ts b/tests/cases/conformance/es6/for-ofStatements/for-of25.ts new file mode 100644 index 00000000000..a1698bd2824 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of25.ts @@ -0,0 +1,9 @@ +//@target: ES6 +var x: any; +for (var v of new StringIterator) { } + +class StringIterator { + [Symbol.iterator]() { + return x; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of26.ts b/tests/cases/conformance/es6/for-ofStatements/for-of26.ts new file mode 100644 index 00000000000..0ab564a4f52 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of26.ts @@ -0,0 +1,12 @@ +//@target: ES6 +var x: any; +for (var v of new StringIterator) { } + +class StringIterator { + next() { + return x; + } + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of27.ts b/tests/cases/conformance/es6/for-ofStatements/for-of27.ts new file mode 100644 index 00000000000..8f2b84cbe1d --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of27.ts @@ -0,0 +1,6 @@ +//@target: ES6 +for (var v of new StringIterator) { } + +class StringIterator { + [Symbol.iterator]: any; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of28.ts b/tests/cases/conformance/es6/for-ofStatements/for-of28.ts new file mode 100644 index 00000000000..8c693193b08 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of28.ts @@ -0,0 +1,9 @@ +//@target: ES6 +for (var v of new StringIterator) { } + +class StringIterator { + next: any; + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file From 0049b21d6cc5a6b911c224738ceb2316990526b7 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 24 Feb 2015 16:09:58 -0800 Subject: [PATCH 67/96] Check for assignability to the relevant iteratable type --- src/compiler/checker.ts | 141 ++++++++++-------- tests/baselines/reference/for-of29.errors.txt | 14 ++ tests/baselines/reference/for-of29.js | 11 ++ tests/baselines/reference/for-of30.errors.txt | 32 ++++ tests/baselines/reference/for-of30.js | 35 +++++ tests/baselines/reference/for-of31.errors.txt | 34 +++++ tests/baselines/reference/for-of31.js | 32 ++++ .../es6/for-ofStatements/for-of29.ts | 6 + .../es6/for-ofStatements/for-of30.ts | 17 +++ .../es6/for-ofStatements/for-of31.ts | 15 ++ 10 files changed, 272 insertions(+), 65 deletions(-) create mode 100644 tests/baselines/reference/for-of29.errors.txt create mode 100644 tests/baselines/reference/for-of29.js create mode 100644 tests/baselines/reference/for-of30.errors.txt create mode 100644 tests/baselines/reference/for-of30.js create mode 100644 tests/baselines/reference/for-of31.errors.txt create mode 100644 tests/baselines/reference/for-of31.js create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of29.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of30.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of31.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fd0724f3335..ae20772a209 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -97,6 +97,7 @@ module ts { var globalRegExpType: ObjectType; var globalTemplateStringsArrayType: ObjectType; var globalESSymbolType: ObjectType; + var globalIterableType: ObjectType; var anyArrayType: Type; @@ -3156,8 +3157,8 @@ module ts { return resolveName(undefined, name, meaning, diagnostic, name); } - function getGlobalType(name: string): ObjectType { - return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), 0); + function getGlobalType(name: string, arity = 0): ObjectType { + return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); } function getGlobalESSymbolConstructorSymbol() { @@ -8844,70 +8845,79 @@ module ts { } function getIteratedType(iterable: Type, expressionForError: Expression): Type { - Debug.assert(languageVersion >= ScriptTarget.ES6); - if (allConstituentTypesHaveKind(iterable, TypeFlags.Any)) { - return iterable; // any or unknown - } - - // We want to treat type as an iterable, and get the type it is an iterable of. The iterable - // must have the following structure (annotated with the names of the variables below): - // - // { // iterable - // [Symbol.iterator]: { // iteratorFunction - // (): { // iterator - // next: { // iteratorNextFunction - // (): { // iteratorNextResult - // value: T // iteratorNextValue - // } - // } - // } - // } - // } - // - // T is the type we are after. At every level that involves analyzing return types - // of signatures, we union the return types of all the signatures. - var iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator")); - if (iteratorFunction && allConstituentTypesHaveKind(iteratorFunction, TypeFlags.Any)) { - return iteratorFunction; // any or unknown - } - - var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray; - if (iteratorFunctionSignatures.length === 0) { - error(expressionForError, Diagnostics.The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - return unknownType; - } - - var iterator = getUnionType(map(iteratorFunctionSignatures, getReturnTypeOfSignature)); - if (allConstituentTypesHaveKind(iterator, TypeFlags.Any)) { - return iterator; // any or unknown - } - - var iteratorNextFunction = getTypeOfPropertyOfType(iterator, "next"); - if (iteratorNextFunction && allConstituentTypesHaveKind(iteratorNextFunction, TypeFlags.Any)) { - return iteratorNextFunction; // any or unknown - } - - var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray; - if (iteratorNextFunctionSignatures.length === 0) { - error(expressionForError, Diagnostics.The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method); - return unknownType; - } - - var iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); - if (allConstituentTypesHaveKind(iteratorNextResult, TypeFlags.Any)) { - return iteratorNextResult; // any or unknown - } - - var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); - if (!iteratorNextValue) { - error(expressionForError, Diagnostics.The_object_returned_by_the_next_method_of_the_iterator_must_have_a_value_property); - return unknownType; - } - - return iteratorNextValue; - // TODO - // Now even though we have extracted the iteratorNextValue, we will have to validate that the type + var iteratedType = getIteratedTypeSubroutine(iterable, expressionForError); + // Now even though we have extracted the iteratedType, we will have to validate that the type // passed in is actually an Iterable. + if (iteratedType !== unknownType) { + var completeIterableType = globalIterableType !== emptyObjectType ? createTypeReference(globalIterableType, [iteratedType]) : emptyObjectType; + checkTypeAssignableTo(iterable, completeIterableType, expressionForError); + } + + return iteratedType; + + function getIteratedTypeSubroutine(iterable: Type, expressionForError: Expression) { + Debug.assert(languageVersion >= ScriptTarget.ES6); + if (allConstituentTypesHaveKind(iterable, TypeFlags.Any)) { + return iterable; // any or unknown + } + + // We want to treat type as an iterable, and get the type it is an iterable of. The iterable + // must have the following structure (annotated with the names of the variables below): + // + // { // iterable + // [Symbol.iterator]: { // iteratorFunction + // (): { // iterator + // next: { // iteratorNextFunction + // (): { // iteratorNextResult + // value: T // iteratorNextValue + // } + // } + // } + // } + // } + // + // T is the type we are after. At every level that involves analyzing return types + // of signatures, we union the return types of all the signatures. + var iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator")); + if (iteratorFunction && allConstituentTypesHaveKind(iteratorFunction, TypeFlags.Any)) { + return iteratorFunction; // any or unknown + } + + var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray; + if (iteratorFunctionSignatures.length === 0) { + error(expressionForError, Diagnostics.The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + return unknownType; + } + + var iterator = getUnionType(map(iteratorFunctionSignatures, getReturnTypeOfSignature)); + if (allConstituentTypesHaveKind(iterator, TypeFlags.Any)) { + return iterator; // any or unknown + } + + var iteratorNextFunction = getTypeOfPropertyOfType(iterator, "next"); + if (iteratorNextFunction && allConstituentTypesHaveKind(iteratorNextFunction, TypeFlags.Any)) { + return iteratorNextFunction; // any or unknown + } + + var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray; + if (iteratorNextFunctionSignatures.length === 0) { + error(expressionForError, Diagnostics.The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method); + return unknownType; + } + + var iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); + if (allConstituentTypesHaveKind(iteratorNextResult, TypeFlags.Any)) { + return iteratorNextResult; // any or unknown + } + + var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); + if (!iteratorNextValue) { + error(expressionForError, Diagnostics.The_object_returned_by_the_next_method_of_the_iterator_must_have_a_value_property); + return unknownType; + } + + return iteratorNextValue; + } } function checkBreakOrContinueStatement(node: BreakOrContinueStatement) { @@ -10856,6 +10866,7 @@ module ts { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); + globalIterableType = getGlobalType("Iterable", 1); } else { globalTemplateStringsArrayType = unknownType; diff --git a/tests/baselines/reference/for-of29.errors.txt b/tests/baselines/reference/for-of29.errors.txt new file mode 100644 index 00000000000..748fcf49050 --- /dev/null +++ b/tests/baselines/reference/for-of29.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/es6/for-ofStatements/for-of29.ts(5,15): error TS2322: Type '{ [Symbol.iterator]?(): Iterator; }' is not assignable to type 'Iterable'. + Property '[Symbol.iterator]' is optional in type '{ [Symbol.iterator]?(): Iterator; }' but required in type 'Iterable'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of29.ts (1 errors) ==== + var iterableWithOptionalIterator: { + [Symbol.iterator]?(): Iterator + }; + + for (var v of iterableWithOptionalIterator) { } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ [Symbol.iterator]?(): Iterator; }' is not assignable to type 'Iterable'. +!!! error TS2322: Property '[Symbol.iterator]' is optional in type '{ [Symbol.iterator]?(): Iterator; }' but required in type 'Iterable'. + \ No newline at end of file diff --git a/tests/baselines/reference/for-of29.js b/tests/baselines/reference/for-of29.js new file mode 100644 index 00000000000..450cafbde85 --- /dev/null +++ b/tests/baselines/reference/for-of29.js @@ -0,0 +1,11 @@ +//// [for-of29.ts] +var iterableWithOptionalIterator: { + [Symbol.iterator]?(): Iterator +}; + +for (var v of iterableWithOptionalIterator) { } + + +//// [for-of29.js] +var iterableWithOptionalIterator; +for (var v of iterableWithOptionalIterator) { } diff --git a/tests/baselines/reference/for-of30.errors.txt b/tests/baselines/reference/for-of30.errors.txt new file mode 100644 index 00000000000..6434b5294d5 --- /dev/null +++ b/tests/baselines/reference/for-of30.errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/es6/for-ofStatements/for-of30.ts(1,15): error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. + Types of property '[Symbol.iterator]' are incompatible. + Type '() => StringIterator' is not assignable to type '() => Iterator'. + Type 'StringIterator' is not assignable to type 'Iterator'. + Types of property 'return' are incompatible. + Type 'number' is not assignable to type '(value?: any) => IteratorResult'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of30.ts (1 errors) ==== + for (var v of new StringIterator) { } + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. +!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. +!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator'. +!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator'. +!!! error TS2322: Types of property 'return' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type '(value?: any) => IteratorResult'. + + class StringIterator { + next() { + return { + done: false, + value: "" + } + } + + return = 0; + + [Symbol.iterator]() { + return this; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of30.js b/tests/baselines/reference/for-of30.js new file mode 100644 index 00000000000..4618dae5ff6 --- /dev/null +++ b/tests/baselines/reference/for-of30.js @@ -0,0 +1,35 @@ +//// [for-of30.ts] +for (var v of new StringIterator) { } + +class StringIterator { + next() { + return { + done: false, + value: "" + } + } + + return = 0; + + [Symbol.iterator]() { + return this; + } +} + +//// [for-of30.js] +for (var v of new StringIterator) { } +var StringIterator = (function () { + function StringIterator() { + this.return = 0; + } + StringIterator.prototype.next = function () { + return { + done: false, + value: "" + }; + }; + StringIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return StringIterator; +})(); diff --git a/tests/baselines/reference/for-of31.errors.txt b/tests/baselines/reference/for-of31.errors.txt new file mode 100644 index 00000000000..74afff00e99 --- /dev/null +++ b/tests/baselines/reference/for-of31.errors.txt @@ -0,0 +1,34 @@ +tests/cases/conformance/es6/for-ofStatements/for-of31.ts(1,15): error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. + Types of property '[Symbol.iterator]' are incompatible. + Type '() => StringIterator' is not assignable to type '() => Iterator'. + Type 'StringIterator' is not assignable to type 'Iterator'. + Types of property 'next' are incompatible. + Type '() => { value: string; }' is not assignable to type '() => IteratorResult'. + Type '{ value: string; }' is not assignable to type 'IteratorResult'. + Property 'done' is missing in type '{ value: string; }'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of31.ts (1 errors) ==== + for (var v of new StringIterator) { } + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. +!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. +!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator'. +!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator'. +!!! error TS2322: Types of property 'next' are incompatible. +!!! error TS2322: Type '() => { value: string; }' is not assignable to type '() => IteratorResult'. +!!! error TS2322: Type '{ value: string; }' is not assignable to type 'IteratorResult'. +!!! error TS2322: Property 'done' is missing in type '{ value: string; }'. + + class StringIterator { + next() { + return { + // no done property + value: "" + } + } + + [Symbol.iterator]() { + return this; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of31.js b/tests/baselines/reference/for-of31.js new file mode 100644 index 00000000000..588c75a1145 --- /dev/null +++ b/tests/baselines/reference/for-of31.js @@ -0,0 +1,32 @@ +//// [for-of31.ts] +for (var v of new StringIterator) { } + +class StringIterator { + next() { + return { + // no done property + value: "" + } + } + + [Symbol.iterator]() { + return this; + } +} + +//// [for-of31.js] +for (var v of new StringIterator) { } +var StringIterator = (function () { + function StringIterator() { + } + StringIterator.prototype.next = function () { + return { + // no done property + value: "" + }; + }; + StringIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return StringIterator; +})(); diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of29.ts b/tests/cases/conformance/es6/for-ofStatements/for-of29.ts new file mode 100644 index 00000000000..8df83db1588 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of29.ts @@ -0,0 +1,6 @@ +//@target: ES6 +var iterableWithOptionalIterator: { + [Symbol.iterator]?(): Iterator +}; + +for (var v of iterableWithOptionalIterator) { } diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of30.ts b/tests/cases/conformance/es6/for-ofStatements/for-of30.ts new file mode 100644 index 00000000000..03b97c23136 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of30.ts @@ -0,0 +1,17 @@ +//@target: ES6 +for (var v of new StringIterator) { } + +class StringIterator { + next() { + return { + done: false, + value: "" + } + } + + return = 0; + + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of31.ts b/tests/cases/conformance/es6/for-ofStatements/for-of31.ts new file mode 100644 index 00000000000..307f9b7cd43 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of31.ts @@ -0,0 +1,15 @@ +//@target: ES6 +for (var v of new StringIterator) { } + +class StringIterator { + next() { + return { + // no done property + value: "" + } + } + + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file From 034bd0952615b629d0f9a76053b7c8ef30cd0a19 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 24 Feb 2015 17:26:16 -0800 Subject: [PATCH 68/96] Add tests for circular references in for...of loops --- src/compiler/checker.ts | 15 +-------- tests/baselines/reference/for-of32.errors.txt | 7 ++++ tests/baselines/reference/for-of32.js | 5 +++ tests/baselines/reference/for-of33.errors.txt | 13 ++++++++ tests/baselines/reference/for-of33.js | 19 +++++++++++ tests/baselines/reference/for-of34.errors.txt | 17 ++++++++++ tests/baselines/reference/for-of34.js | 26 +++++++++++++++ tests/baselines/reference/for-of35.errors.txt | 20 ++++++++++++ tests/baselines/reference/for-of35.js | 32 +++++++++++++++++++ .../es6/for-ofStatements/for-of32.ts | 3 ++ .../es6/for-ofStatements/for-of33.ts | 9 ++++++ .../es6/for-ofStatements/for-of34.ts | 13 ++++++++ .../es6/for-ofStatements/for-of35.ts | 16 ++++++++++ 13 files changed, 181 insertions(+), 14 deletions(-) create mode 100644 tests/baselines/reference/for-of32.errors.txt create mode 100644 tests/baselines/reference/for-of32.js create mode 100644 tests/baselines/reference/for-of33.errors.txt create mode 100644 tests/baselines/reference/for-of33.js create mode 100644 tests/baselines/reference/for-of34.errors.txt create mode 100644 tests/baselines/reference/for-of34.js create mode 100644 tests/baselines/reference/for-of35.errors.txt create mode 100644 tests/baselines/reference/for-of35.js create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of32.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of33.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of34.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of35.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ae20772a209..7c4b9fe8dca 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8828,20 +8828,7 @@ module ts { return anyType; } - var variable = forOfStatement.initializer; - var links = getNodeLinks(variable); - if (!links.resolvedType) { - links.resolvedType = resolvingType; - var type = getIteratedType(getTypeOfExpression(forOfStatement.expression), forOfStatement.expression); - if (links.resolvedType === resolvingType) { - links.resolvedType = type; - } - } - else if (links.resolvedType === resolvingType) { - links.resolvedType = anyType; - } - - return links.resolvedType; + return getIteratedType(getTypeOfExpression(forOfStatement.expression), forOfStatement.expression); } function getIteratedType(iterable: Type, expressionForError: Expression): Type { diff --git a/tests/baselines/reference/for-of32.errors.txt b/tests/baselines/reference/for-of32.errors.txt new file mode 100644 index 00000000000..4b139d386c0 --- /dev/null +++ b/tests/baselines/reference/for-of32.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/for-ofStatements/for-of32.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of32.ts (1 errors) ==== + for (var v of v) { } + ~ +!!! error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. \ No newline at end of file diff --git a/tests/baselines/reference/for-of32.js b/tests/baselines/reference/for-of32.js new file mode 100644 index 00000000000..d25d16fbebe --- /dev/null +++ b/tests/baselines/reference/for-of32.js @@ -0,0 +1,5 @@ +//// [for-of32.ts] +for (var v of v) { } + +//// [for-of32.js] +for (var v of v) { } diff --git a/tests/baselines/reference/for-of33.errors.txt b/tests/baselines/reference/for-of33.errors.txt new file mode 100644 index 00000000000..1c631042d7d --- /dev/null +++ b/tests/baselines/reference/for-of33.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/es6/for-ofStatements/for-of33.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of33.ts (1 errors) ==== + for (var v of new StringIterator) { } + ~ +!!! error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. + + class StringIterator { + [Symbol.iterator]() { + return v; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of33.js b/tests/baselines/reference/for-of33.js new file mode 100644 index 00000000000..91d8de41c6a --- /dev/null +++ b/tests/baselines/reference/for-of33.js @@ -0,0 +1,19 @@ +//// [for-of33.ts] +for (var v of new StringIterator) { } + +class StringIterator { + [Symbol.iterator]() { + return v; + } +} + +//// [for-of33.js] +for (var v of new StringIterator) { } +var StringIterator = (function () { + function StringIterator() { + } + StringIterator.prototype[Symbol.iterator] = function () { + return v; + }; + return StringIterator; +})(); diff --git a/tests/baselines/reference/for-of34.errors.txt b/tests/baselines/reference/for-of34.errors.txt new file mode 100644 index 00000000000..994302db88b --- /dev/null +++ b/tests/baselines/reference/for-of34.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/es6/for-ofStatements/for-of34.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of34.ts (1 errors) ==== + for (var v of new StringIterator) { } + ~ +!!! error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. + + class StringIterator { + next() { + return v; + } + + [Symbol.iterator]() { + return this; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of34.js b/tests/baselines/reference/for-of34.js new file mode 100644 index 00000000000..ccb6006c63d --- /dev/null +++ b/tests/baselines/reference/for-of34.js @@ -0,0 +1,26 @@ +//// [for-of34.ts] +for (var v of new StringIterator) { } + +class StringIterator { + next() { + return v; + } + + [Symbol.iterator]() { + return this; + } +} + +//// [for-of34.js] +for (var v of new StringIterator) { } +var StringIterator = (function () { + function StringIterator() { + } + StringIterator.prototype.next = function () { + return v; + }; + StringIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return StringIterator; +})(); diff --git a/tests/baselines/reference/for-of35.errors.txt b/tests/baselines/reference/for-of35.errors.txt new file mode 100644 index 00000000000..f83b6d2ec3c --- /dev/null +++ b/tests/baselines/reference/for-of35.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/es6/for-ofStatements/for-of35.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of35.ts (1 errors) ==== + for (var v of new StringIterator) { } + ~ +!!! error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer. + + class StringIterator { + next() { + return { + done: true, + value: v + } + } + + [Symbol.iterator]() { + return this; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of35.js b/tests/baselines/reference/for-of35.js new file mode 100644 index 00000000000..a4f1a37e3bf --- /dev/null +++ b/tests/baselines/reference/for-of35.js @@ -0,0 +1,32 @@ +//// [for-of35.ts] +for (var v of new StringIterator) { } + +class StringIterator { + next() { + return { + done: true, + value: v + } + } + + [Symbol.iterator]() { + return this; + } +} + +//// [for-of35.js] +for (var v of new StringIterator) { } +var StringIterator = (function () { + function StringIterator() { + } + StringIterator.prototype.next = function () { + return { + done: true, + value: v + }; + }; + StringIterator.prototype[Symbol.iterator] = function () { + return this; + }; + return StringIterator; +})(); diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of32.ts b/tests/cases/conformance/es6/for-ofStatements/for-of32.ts new file mode 100644 index 00000000000..de95350b724 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of32.ts @@ -0,0 +1,3 @@ +//@target: ES6 +//@noImplicitAny: true +for (var v of v) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of33.ts b/tests/cases/conformance/es6/for-ofStatements/for-of33.ts new file mode 100644 index 00000000000..b73d2daee8a --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of33.ts @@ -0,0 +1,9 @@ +//@target: ES6 +//@noImplicitAny: true +for (var v of new StringIterator) { } + +class StringIterator { + [Symbol.iterator]() { + return v; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of34.ts b/tests/cases/conformance/es6/for-ofStatements/for-of34.ts new file mode 100644 index 00000000000..d00f5ccde2e --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of34.ts @@ -0,0 +1,13 @@ +//@target: ES6 +//@noImplicitAny: true +for (var v of new StringIterator) { } + +class StringIterator { + next() { + return v; + } + + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of35.ts b/tests/cases/conformance/es6/for-ofStatements/for-of35.ts new file mode 100644 index 00000000000..0d66ce39edf --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of35.ts @@ -0,0 +1,16 @@ +//@target: ES6 +//@noImplicitAny: true +for (var v of new StringIterator) { } + +class StringIterator { + next() { + return { + done: true, + value: v + } + } + + [Symbol.iterator]() { + return this; + } +} \ No newline at end of file From c00a264bb7b3e2870261e657d9489c4834325fcd Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 25 Feb 2015 14:28:37 -0800 Subject: [PATCH 69/96] Move assert --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7c4b9fe8dca..6df535bd322 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8832,6 +8832,7 @@ module ts { } function getIteratedType(iterable: Type, expressionForError: Expression): Type { + Debug.assert(languageVersion >= ScriptTarget.ES6); var iteratedType = getIteratedTypeSubroutine(iterable, expressionForError); // Now even though we have extracted the iteratedType, we will have to validate that the type // passed in is actually an Iterable. @@ -8843,7 +8844,6 @@ module ts { return iteratedType; function getIteratedTypeSubroutine(iterable: Type, expressionForError: Expression) { - Debug.assert(languageVersion >= ScriptTarget.ES6); if (allConstituentTypesHaveKind(iterable, TypeFlags.Any)) { return iterable; // any or unknown } From f3543b718f389cb6678bfc7b192b40c99ee0966e Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 25 Feb 2015 18:15:48 -0800 Subject: [PATCH 70/96] In ES6, an Iterable should contextually type an array literal --- src/compiler/checker.ts | 52 +++++++++++++------ tests/baselines/reference/for-of36.js | 11 ++++ tests/baselines/reference/for-of36.types | 12 +++++ tests/baselines/reference/for-of37.js | 11 ++++ tests/baselines/reference/for-of37.types | 15 ++++++ .../reference/iterableContextualTyping1.js | 5 ++ .../reference/iterableContextualTyping1.types | 12 +++++ .../es6/for-ofStatements/for-of36.ts | 5 ++ .../es6/for-ofStatements/for-of37.ts | 5 ++ .../iterableContextualTyping1.ts | 2 + 10 files changed, 115 insertions(+), 15 deletions(-) create mode 100644 tests/baselines/reference/for-of36.js create mode 100644 tests/baselines/reference/for-of36.types create mode 100644 tests/baselines/reference/for-of37.js create mode 100644 tests/baselines/reference/for-of37.types create mode 100644 tests/baselines/reference/iterableContextualTyping1.js create mode 100644 tests/baselines/reference/iterableContextualTyping1.types create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of36.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of37.ts create mode 100644 tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6df535bd322..2e5d61f860a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5461,7 +5461,9 @@ module ts { var type = getContextualType(arrayLiteral); if (type) { var index = indexOf(arrayLiteral.elements, node); - return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, IndexKind.Number); + return getTypeOfPropertyOfContextualType(type, "" + index) + || getIndexTypeOfContextualType(type, IndexKind.Number) + || (languageVersion >= ScriptTarget.ES6 ? getIteratedType(type, /*expressionForError*/ undefined) : undefined); } return undefined; } @@ -8770,7 +8772,14 @@ module ts { checkReferenceExpression(varExpr, Diagnostics.Invalid_left_hand_side_in_for_of_statement, Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); var rightType = checkExpression(node.expression); var iteratedType = getIteratedType(rightType, node.expression); - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + + // iteratedType will be undefined if the rightType was missing properties/signatures + // required to get it's iteratedType (like [Symbol.iterator] or next). This may be + // because we accessed properties from anyType, or it may have led to an error inside + // getIteratedType. + if (iteratedType) { + checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + } } checkSourceElement(node.statement); @@ -8828,15 +8837,22 @@ module ts { return anyType; } - return getIteratedType(getTypeOfExpression(forOfStatement.expression), forOfStatement.expression); + // iteratedType will be undefined if the for-of expression type was missing properties/signatures + // required to get it's iteratedType (like [Symbol.iterator] or next). This may be + // because we accessed properties from anyType, or it may have led to an error inside + // getIteratedType. + return getIteratedType(getTypeOfExpression(forOfStatement.expression), forOfStatement.expression) || anyType; } + /** + * When expressionForError is undefined, it means we should not report any errors. + */ function getIteratedType(iterable: Type, expressionForError: Expression): Type { Debug.assert(languageVersion >= ScriptTarget.ES6); var iteratedType = getIteratedTypeSubroutine(iterable, expressionForError); // Now even though we have extracted the iteratedType, we will have to validate that the type // passed in is actually an Iterable. - if (iteratedType !== unknownType) { + if (expressionForError && iteratedType) { var completeIterableType = globalIterableType !== emptyObjectType ? createTypeReference(globalIterableType, [iteratedType]) : emptyObjectType; checkTypeAssignableTo(iterable, completeIterableType, expressionForError); } @@ -8845,7 +8861,7 @@ module ts { function getIteratedTypeSubroutine(iterable: Type, expressionForError: Expression) { if (allConstituentTypesHaveKind(iterable, TypeFlags.Any)) { - return iterable; // any or unknown + return undefined; } // We want to treat type as an iterable, and get the type it is an iterable of. The iterable @@ -8867,40 +8883,46 @@ module ts { // of signatures, we union the return types of all the signatures. var iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator")); if (iteratorFunction && allConstituentTypesHaveKind(iteratorFunction, TypeFlags.Any)) { - return iteratorFunction; // any or unknown + return undefined; } var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray; if (iteratorFunctionSignatures.length === 0) { - error(expressionForError, Diagnostics.The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - return unknownType; + if (expressionForError) { + error(expressionForError, Diagnostics.The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + } + return undefined; } var iterator = getUnionType(map(iteratorFunctionSignatures, getReturnTypeOfSignature)); if (allConstituentTypesHaveKind(iterator, TypeFlags.Any)) { - return iterator; // any or unknown + return undefined; } var iteratorNextFunction = getTypeOfPropertyOfType(iterator, "next"); if (iteratorNextFunction && allConstituentTypesHaveKind(iteratorNextFunction, TypeFlags.Any)) { - return iteratorNextFunction; // any or unknown + return undefined; } var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray; if (iteratorNextFunctionSignatures.length === 0) { - error(expressionForError, Diagnostics.The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method); - return unknownType; + if (expressionForError) { + error(expressionForError, Diagnostics.The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method); + } + return undefined; } var iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature)); if (allConstituentTypesHaveKind(iteratorNextResult, TypeFlags.Any)) { - return iteratorNextResult; // any or unknown + return undefined; } var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); if (!iteratorNextValue) { - error(expressionForError, Diagnostics.The_object_returned_by_the_next_method_of_the_iterator_must_have_a_value_property); - return unknownType; + if (expressionForError) { + error(expressionForError, Diagnostics.The_object_returned_by_the_next_method_of_the_iterator_must_have_a_value_property); + } + return undefined; } return iteratorNextValue; diff --git a/tests/baselines/reference/for-of36.js b/tests/baselines/reference/for-of36.js new file mode 100644 index 00000000000..14523695151 --- /dev/null +++ b/tests/baselines/reference/for-of36.js @@ -0,0 +1,11 @@ +//// [for-of36.ts] +var tuple: [string, boolean] = ["", true]; +for (var v of tuple) { + v; +} + +//// [for-of36.js] +var tuple = ["", true]; +for (var v of tuple) { + v; +} diff --git a/tests/baselines/reference/for-of36.types b/tests/baselines/reference/for-of36.types new file mode 100644 index 00000000000..da03367ba5d --- /dev/null +++ b/tests/baselines/reference/for-of36.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of36.ts === +var tuple: [string, boolean] = ["", true]; +>tuple : [string, boolean] +>["", true] : [string, boolean] + +for (var v of tuple) { +>v : string | boolean +>tuple : [string, boolean] + + v; +>v : string | boolean +} diff --git a/tests/baselines/reference/for-of37.js b/tests/baselines/reference/for-of37.js new file mode 100644 index 00000000000..472193e6cb5 --- /dev/null +++ b/tests/baselines/reference/for-of37.js @@ -0,0 +1,11 @@ +//// [for-of37.ts] +var map = new Map([["", true]]); +for (var v of map) { + v; +} + +//// [for-of37.js] +var map = new Map([["", true]]); +for (var v of map) { + v; +} diff --git a/tests/baselines/reference/for-of37.types b/tests/baselines/reference/for-of37.types new file mode 100644 index 00000000000..f137db79af0 --- /dev/null +++ b/tests/baselines/reference/for-of37.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of37.ts === +var map = new Map([["", true]]); +>map : Map +>new Map([["", true]]) : Map +>Map : MapConstructor +>[["", true]] : [string, boolean][] +>["", true] : [string, boolean] + +for (var v of map) { +>v : [string, boolean] +>map : Map + + v; +>v : [string, boolean] +} diff --git a/tests/baselines/reference/iterableContextualTyping1.js b/tests/baselines/reference/iterableContextualTyping1.js new file mode 100644 index 00000000000..8621bbd8417 --- /dev/null +++ b/tests/baselines/reference/iterableContextualTyping1.js @@ -0,0 +1,5 @@ +//// [iterableContextualTyping1.ts] +var iter: Iterable<(x: string) => number> = [s => s.length]; + +//// [iterableContextualTyping1.js] +var iter = [s => s.length]; diff --git a/tests/baselines/reference/iterableContextualTyping1.types b/tests/baselines/reference/iterableContextualTyping1.types new file mode 100644 index 00000000000..386d64312fc --- /dev/null +++ b/tests/baselines/reference/iterableContextualTyping1.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts === +var iter: Iterable<(x: string) => number> = [s => s.length]; +>iter : Iterable<(x: string) => number> +>Iterable : Iterable +>x : string +>[s => s.length] : ((s: string) => number)[] +>s => s.length : (s: string) => number +>s : string +>s.length : number +>s : string +>length : number + diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of36.ts b/tests/cases/conformance/es6/for-ofStatements/for-of36.ts new file mode 100644 index 00000000000..e67806fef64 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of36.ts @@ -0,0 +1,5 @@ +//@target: ES6 +var tuple: [string, boolean] = ["", true]; +for (var v of tuple) { + v; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of37.ts b/tests/cases/conformance/es6/for-ofStatements/for-of37.ts new file mode 100644 index 00000000000..561e3bf2e52 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of37.ts @@ -0,0 +1,5 @@ +//@target: ES6 +var map = new Map([["", true]]); +for (var v of map) { + v; +} \ No newline at end of file diff --git a/tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts b/tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts new file mode 100644 index 00000000000..542d1928011 --- /dev/null +++ b/tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts @@ -0,0 +1,2 @@ +//@target: ES6 +var iter: Iterable<(x: string) => number> = [s => s.length]; \ No newline at end of file From 00408a68d3f5f6635af28eae5312d7148d44652a Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 25 Feb 2015 18:56:12 -0800 Subject: [PATCH 71/96] Add tests for for-of destructuring --- tests/baselines/reference/for-of38.js | 13 ++++++++++ tests/baselines/reference/for-of38.types | 19 +++++++++++++++ tests/baselines/reference/for-of39.errors.txt | 13 ++++++++++ tests/baselines/reference/for-of39.js | 13 ++++++++++ tests/baselines/reference/for-of40.js | 13 ++++++++++ tests/baselines/reference/for-of40.types | 19 +++++++++++++++ tests/baselines/reference/for-of41.js | 13 ++++++++++ tests/baselines/reference/for-of41.types | 24 +++++++++++++++++++ tests/baselines/reference/for-of42.js | 13 ++++++++++ tests/baselines/reference/for-of42.types | 21 ++++++++++++++++ tests/baselines/reference/for-of43.errors.txt | 11 +++++++++ tests/baselines/reference/for-of43.js | 13 ++++++++++ tests/baselines/reference/for-of44.js | 13 ++++++++++ tests/baselines/reference/for-of44.types | 21 ++++++++++++++++ tests/baselines/reference/for-of45.types | 24 +++++++++++++++++++ .../es6/for-ofStatements/for-of38.ts | 6 +++++ .../es6/for-ofStatements/for-of39.ts | 6 +++++ .../es6/for-ofStatements/for-of40.ts | 6 +++++ .../es6/for-ofStatements/for-of41.ts | 6 +++++ .../es6/for-ofStatements/for-of42.ts | 6 +++++ .../es6/for-ofStatements/for-of43.ts | 6 +++++ .../es6/for-ofStatements/for-of44.ts | 6 +++++ 22 files changed, 285 insertions(+) create mode 100644 tests/baselines/reference/for-of38.js create mode 100644 tests/baselines/reference/for-of38.types create mode 100644 tests/baselines/reference/for-of39.errors.txt create mode 100644 tests/baselines/reference/for-of39.js create mode 100644 tests/baselines/reference/for-of40.js create mode 100644 tests/baselines/reference/for-of40.types create mode 100644 tests/baselines/reference/for-of41.js create mode 100644 tests/baselines/reference/for-of41.types create mode 100644 tests/baselines/reference/for-of42.js create mode 100644 tests/baselines/reference/for-of42.types create mode 100644 tests/baselines/reference/for-of43.errors.txt create mode 100644 tests/baselines/reference/for-of43.js create mode 100644 tests/baselines/reference/for-of44.js create mode 100644 tests/baselines/reference/for-of44.types create mode 100644 tests/baselines/reference/for-of45.types create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of38.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of39.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of40.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of41.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of42.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of43.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of44.ts diff --git a/tests/baselines/reference/for-of38.js b/tests/baselines/reference/for-of38.js new file mode 100644 index 00000000000..1f0ac09682e --- /dev/null +++ b/tests/baselines/reference/for-of38.js @@ -0,0 +1,13 @@ +//// [for-of38.ts] +var map = new Map([["", true]]); +for (var [k, v] of map) { + k; + v; +} + +//// [for-of38.js] +var map = new Map([["", true]]); +for (var [k, v] of map) { + k; + v; +} diff --git a/tests/baselines/reference/for-of38.types b/tests/baselines/reference/for-of38.types new file mode 100644 index 00000000000..cdd1e05dd7e --- /dev/null +++ b/tests/baselines/reference/for-of38.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of38.ts === +var map = new Map([["", true]]); +>map : Map +>new Map([["", true]]) : Map +>Map : MapConstructor +>[["", true]] : [string, boolean][] +>["", true] : [string, boolean] + +for (var [k, v] of map) { +>k : string +>v : boolean +>map : Map + + k; +>k : string + + v; +>v : boolean +} diff --git a/tests/baselines/reference/for-of39.errors.txt b/tests/baselines/reference/for-of39.errors.txt new file mode 100644 index 00000000000..48db183a58c --- /dev/null +++ b/tests/baselines/reference/for-of39.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/es6/for-ofStatements/for-of39.ts(1,15): error TS2453: The type argument for type parameter 'V' cannot be inferred from the usage. Consider specifying the type arguments explicitly. + Type argument candidate 'boolean' is not a valid type argument because it is not a supertype of candidate 'number'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of39.ts (1 errors) ==== + var map = new Map([["", true], ["", 0]]); + ~~~ +!!! error TS2453: The type argument for type parameter 'V' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +!!! error TS2453: Type argument candidate 'boolean' is not a valid type argument because it is not a supertype of candidate 'number'. + for (var [k, v] of map) { + k; + v; + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of39.js b/tests/baselines/reference/for-of39.js new file mode 100644 index 00000000000..91dbc56c0ab --- /dev/null +++ b/tests/baselines/reference/for-of39.js @@ -0,0 +1,13 @@ +//// [for-of39.ts] +var map = new Map([["", true], ["", 0]]); +for (var [k, v] of map) { + k; + v; +} + +//// [for-of39.js] +var map = new Map([["", true], ["", 0]]); +for (var [k, v] of map) { + k; + v; +} diff --git a/tests/baselines/reference/for-of40.js b/tests/baselines/reference/for-of40.js new file mode 100644 index 00000000000..243f81097db --- /dev/null +++ b/tests/baselines/reference/for-of40.js @@ -0,0 +1,13 @@ +//// [for-of40.ts] +var map = new Map([["", true]]); +for (var [k = "", v = false] of map) { + k; + v; +} + +//// [for-of40.js] +var map = new Map([["", true]]); +for (var [k = "", v = false] of map) { + k; + v; +} diff --git a/tests/baselines/reference/for-of40.types b/tests/baselines/reference/for-of40.types new file mode 100644 index 00000000000..c0fe7cbbc02 --- /dev/null +++ b/tests/baselines/reference/for-of40.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of40.ts === +var map = new Map([["", true]]); +>map : Map +>new Map([["", true]]) : Map +>Map : MapConstructor +>[["", true]] : [string, boolean][] +>["", true] : [string, boolean] + +for (var [k = "", v = false] of map) { +>k : string +>v : boolean +>map : Map + + k; +>k : string + + v; +>v : boolean +} diff --git a/tests/baselines/reference/for-of41.js b/tests/baselines/reference/for-of41.js new file mode 100644 index 00000000000..0fa380c53c4 --- /dev/null +++ b/tests/baselines/reference/for-of41.js @@ -0,0 +1,13 @@ +//// [for-of41.ts] +var array = [{x: [0], y: {p: ""}}] +for (var {x: [a], y: {p}} of array) { + a; + p; +} + +//// [for-of41.js] +var array = [{ x: [0], y: { p: "" } }]; +for (var { x: [a], y: { p } } of array) { + a; + p; +} diff --git a/tests/baselines/reference/for-of41.types b/tests/baselines/reference/for-of41.types new file mode 100644 index 00000000000..54e58aa1ec7 --- /dev/null +++ b/tests/baselines/reference/for-of41.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of41.ts === +var array = [{x: [0], y: {p: ""}}] +>array : { x: number[]; y: { p: string; }; }[] +>[{x: [0], y: {p: ""}}] : { x: number[]; y: { p: string; }; }[] +>{x: [0], y: {p: ""}} : { x: number[]; y: { p: string; }; } +>x : number[] +>[0] : number[] +>y : { p: string; } +>{p: ""} : { p: string; } +>p : string + +for (var {x: [a], y: {p}} of array) { +>x : unknown +>a : number +>y : unknown +>p : string +>array : { x: number[]; y: { p: string; }; }[] + + a; +>a : number + + p; +>p : string +} diff --git a/tests/baselines/reference/for-of42.js b/tests/baselines/reference/for-of42.js new file mode 100644 index 00000000000..1fa9219df47 --- /dev/null +++ b/tests/baselines/reference/for-of42.js @@ -0,0 +1,13 @@ +//// [for-of42.ts] +var array = [{ x: "", y: 0 }] +for (var {x: a, y: b} of array) { + a; + b; +} + +//// [for-of42.js] +var array = [{ x: "", y: 0 }]; +for (var { x: a, y: b } of array) { + a; + b; +} diff --git a/tests/baselines/reference/for-of42.types b/tests/baselines/reference/for-of42.types new file mode 100644 index 00000000000..1a819452770 --- /dev/null +++ b/tests/baselines/reference/for-of42.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of42.ts === +var array = [{ x: "", y: 0 }] +>array : { x: string; y: number; }[] +>[{ x: "", y: 0 }] : { x: string; y: number; }[] +>{ x: "", y: 0 } : { x: string; y: number; } +>x : string +>y : number + +for (var {x: a, y: b} of array) { +>x : unknown +>a : string +>y : unknown +>b : number +>array : { x: string; y: number; }[] + + a; +>a : string + + b; +>b : number +} diff --git a/tests/baselines/reference/for-of43.errors.txt b/tests/baselines/reference/for-of43.errors.txt new file mode 100644 index 00000000000..c5790278e53 --- /dev/null +++ b/tests/baselines/reference/for-of43.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/es6/for-ofStatements/for-of43.ts(2,25): error TS2322: Type 'boolean' is not assignable to type 'number'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of43.ts (1 errors) ==== + var array = [{ x: "", y: 0 }] + for (var {x: a = "", y: b = true} of array) { + ~ +!!! error TS2322: Type 'boolean' is not assignable to type 'number'. + a; + b; + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of43.js b/tests/baselines/reference/for-of43.js new file mode 100644 index 00000000000..de3b4fcd9b0 --- /dev/null +++ b/tests/baselines/reference/for-of43.js @@ -0,0 +1,13 @@ +//// [for-of43.ts] +var array = [{ x: "", y: 0 }] +for (var {x: a = "", y: b = true} of array) { + a; + b; +} + +//// [for-of43.js] +var array = [{ x: "", y: 0 }]; +for (var { x: a = "", y: b = true } of array) { + a; + b; +} diff --git a/tests/baselines/reference/for-of44.js b/tests/baselines/reference/for-of44.js new file mode 100644 index 00000000000..087485ed73f --- /dev/null +++ b/tests/baselines/reference/for-of44.js @@ -0,0 +1,13 @@ +//// [for-of44.ts] +var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] +for (var [num, strBoolSym] of array) { + num; + strBoolSym; +} + +//// [for-of44.js] +var array = [[0, ""], [0, true], [1, Symbol()]]; +for (var [num, strBoolSym] of array) { + num; + strBoolSym; +} diff --git a/tests/baselines/reference/for-of44.types b/tests/baselines/reference/for-of44.types new file mode 100644 index 00000000000..078b49bd309 --- /dev/null +++ b/tests/baselines/reference/for-of44.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of44.ts === +var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] +>array : [number, string | boolean | symbol][] +>[[0, ""], [0, true], [1, Symbol()]] : ([number, string] | [number, boolean] | [number, symbol])[] +>[0, ""] : [number, string] +>[0, true] : [number, boolean] +>[1, Symbol()] : [number, symbol] +>Symbol() : symbol +>Symbol : SymbolConstructor + +for (var [num, strBoolSym] of array) { +>num : number +>strBoolSym : string | boolean | symbol +>array : [number, string | boolean | symbol][] + + num; +>num : number + + strBoolSym; +>strBoolSym : string | boolean | symbol +} diff --git a/tests/baselines/reference/for-of45.types b/tests/baselines/reference/for-of45.types new file mode 100644 index 00000000000..53b82a90111 --- /dev/null +++ b/tests/baselines/reference/for-of45.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of45.ts === +var array = [{x: [0], y: {p: ""}}] +>array : { x: number[]; y: { p: string; }; }[] +>[{x: [0], y: {p: ""}}] : { x: number[]; y: { p: string; }; }[] +>{x: [0], y: {p: ""}} : { x: number[]; y: { p: string; }; } +>x : number[] +>[0] : number[] +>y : { p: string; } +>{p: ""} : { p: string; } +>p : string + +for (var {x: [a], y: {p}} of array) { +>x : unknown +>a : number +>y : unknown +>p : string +>array : { x: number[]; y: { p: string; }; }[] + + a; +>a : number + + p; +>p : string +} diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of38.ts b/tests/cases/conformance/es6/for-ofStatements/for-of38.ts new file mode 100644 index 00000000000..0511ff140bd --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of38.ts @@ -0,0 +1,6 @@ +//@target: ES6 +var map = new Map([["", true]]); +for (var [k, v] of map) { + k; + v; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of39.ts b/tests/cases/conformance/es6/for-ofStatements/for-of39.ts new file mode 100644 index 00000000000..1d3ae5fc76c --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of39.ts @@ -0,0 +1,6 @@ +//@target: ES6 +var map = new Map([["", true], ["", 0]]); +for (var [k, v] of map) { + k; + v; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of40.ts b/tests/cases/conformance/es6/for-ofStatements/for-of40.ts new file mode 100644 index 00000000000..128e6b4f186 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of40.ts @@ -0,0 +1,6 @@ +//@target: ES6 +var map = new Map([["", true]]); +for (var [k = "", v = false] of map) { + k; + v; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of41.ts b/tests/cases/conformance/es6/for-ofStatements/for-of41.ts new file mode 100644 index 00000000000..207ab8ab2b9 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of41.ts @@ -0,0 +1,6 @@ +//@target: ES6 +var array = [{x: [0], y: {p: ""}}] +for (var {x: [a], y: {p}} of array) { + a; + p; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of42.ts b/tests/cases/conformance/es6/for-ofStatements/for-of42.ts new file mode 100644 index 00000000000..2eb25ab52f2 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of42.ts @@ -0,0 +1,6 @@ +//@target: ES6 +var array = [{ x: "", y: 0 }] +for (var {x: a, y: b} of array) { + a; + b; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of43.ts b/tests/cases/conformance/es6/for-ofStatements/for-of43.ts new file mode 100644 index 00000000000..fec349e1073 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of43.ts @@ -0,0 +1,6 @@ +//@target: ES6 +var array = [{ x: "", y: 0 }] +for (var {x: a = "", y: b = true} of array) { + a; + b; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of44.ts b/tests/cases/conformance/es6/for-ofStatements/for-of44.ts new file mode 100644 index 00000000000..7d7d21d8691 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of44.ts @@ -0,0 +1,6 @@ +//@target: ES6 +var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] +for (var [num, strBoolSym] of array) { + num; + strBoolSym; +} \ No newline at end of file From 79b609b6323755426ff07dd2d90f31d26fb700aa Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 26 Feb 2015 10:27:16 -0800 Subject: [PATCH 72/96] Update comment --- src/compiler/checker.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2e5d61f860a..be59b41fbee 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5454,8 +5454,9 @@ module ts { } // In an array literal contextually typed by a type T, the contextual type of an element expression at index N is - // the type of the property with the numeric name N in T, if one exists. Otherwise, it is the type of the numeric - // index signature in T, if one exists. + // the type of the property with the numeric name N in T, if one exists. Otherwise, if T has a numeric index signature, + // it is the type of the numeric index signature in T. Otherwise, in ES6 and higher, the contextual type is the iterated + // type of T. function getContextualTypeForElementExpression(node: Expression): Type { var arrayLiteral = node.parent; var type = getContextualType(arrayLiteral); From 9faa09b5d7e058f7d9a33d419f513de4965df97a Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 26 Feb 2015 15:11:48 -0800 Subject: [PATCH 73/96] Delete bad baseline --- tests/baselines/reference/for-of45.types | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 tests/baselines/reference/for-of45.types diff --git a/tests/baselines/reference/for-of45.types b/tests/baselines/reference/for-of45.types deleted file mode 100644 index 53b82a90111..00000000000 --- a/tests/baselines/reference/for-of45.types +++ /dev/null @@ -1,24 +0,0 @@ -=== tests/cases/conformance/es6/for-ofStatements/for-of45.ts === -var array = [{x: [0], y: {p: ""}}] ->array : { x: number[]; y: { p: string; }; }[] ->[{x: [0], y: {p: ""}}] : { x: number[]; y: { p: string; }; }[] ->{x: [0], y: {p: ""}} : { x: number[]; y: { p: string; }; } ->x : number[] ->[0] : number[] ->y : { p: string; } ->{p: ""} : { p: string; } ->p : string - -for (var {x: [a], y: {p}} of array) { ->x : unknown ->a : number ->y : unknown ->p : string ->array : { x: number[]; y: { p: string; }; }[] - - a; ->a : number - - p; ->p : string -} From f8150d3734759a0befc54a97074305efca6d86f9 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 26 Feb 2015 15:32:37 -0800 Subject: [PATCH 74/96] Support assignment patterns in 'for...of' statements --- src/compiler/checker.ts | 30 ++++++++++++------- tests/baselines/reference/for-of45.js | 15 ++++++++++ tests/baselines/reference/for-of45.types | 26 ++++++++++++++++ tests/baselines/reference/for-of46.errors.txt | 15 ++++++++++ tests/baselines/reference/for-of46.js | 15 ++++++++++ tests/baselines/reference/for-of47.errors.txt | 13 ++++++++ tests/baselines/reference/for-of47.js | 20 +++++++++++++ .../es6/for-ofStatements/for-of45.ts | 7 +++++ .../es6/for-ofStatements/for-of46.ts | 7 +++++ .../es6/for-ofStatements/for-of47.ts | 8 +++++ 10 files changed, 146 insertions(+), 10 deletions(-) create mode 100644 tests/baselines/reference/for-of45.js create mode 100644 tests/baselines/reference/for-of45.types create mode 100644 tests/baselines/reference/for-of46.errors.txt create mode 100644 tests/baselines/reference/for-of46.js create mode 100644 tests/baselines/reference/for-of47.errors.txt create mode 100644 tests/baselines/reference/for-of47.js create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of45.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of46.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of47.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index be59b41fbee..ae1e9a398a2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7411,7 +7411,7 @@ module ts { return rightType; } - // Return type is true if there was no error, false if there was an error. + // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { var offendingSymbolOperand = someConstituentTypeHasKind(leftType, TypeFlags.ESSymbol) ? node.left : @@ -8758,7 +8758,7 @@ module ts { grammarErrorOnFirstToken(node, Diagnostics.for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher); return; } - + checkGrammarForInOrForOfStatement(node) // Check the LHS and RHS @@ -8769,17 +8769,27 @@ module ts { } else { var varExpr = node.initializer; - var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, Diagnostics.Invalid_left_hand_side_in_for_of_statement, Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); var rightType = checkExpression(node.expression); var iteratedType = getIteratedType(rightType, node.expression); - // iteratedType will be undefined if the rightType was missing properties/signatures - // required to get it's iteratedType (like [Symbol.iterator] or next). This may be - // because we accessed properties from anyType, or it may have led to an error inside - // getIteratedType. - if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + // There may be a destructuring assignment on the left side + if (varExpr.kind === SyntaxKind.ArrayLiteralExpression || varExpr.kind === SyntaxKind.ObjectLiteralExpression) { + // iteratedType may be undefined. In this case, we still want to check the structure of + // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like + // to short circuit the type relation checking as much as possible, so we pass the unknownType. + checkDestructuringAssignment(varExpr, iteratedType || unknownType); + } + else { + var leftType = checkExpression(varExpr); + checkReferenceExpression(varExpr, Diagnostics.Invalid_left_hand_side_in_for_of_statement, Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); + + // iteratedType will be undefined if the rightType was missing properties/signatures + // required to get it's iteratedType (like [Symbol.iterator] or next). This may be + // because we accessed properties from anyType, or it may have led to an error inside + // getIteratedType. + if (iteratedType) { + checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + } } } diff --git a/tests/baselines/reference/for-of45.js b/tests/baselines/reference/for-of45.js new file mode 100644 index 00000000000..1222b2dcdd5 --- /dev/null +++ b/tests/baselines/reference/for-of45.js @@ -0,0 +1,15 @@ +//// [for-of45.ts] +var k: string, v: boolean; +var map = new Map([["", true]]); +for ([k = "", v = false] of map) { + k; + v; +} + +//// [for-of45.js] +var k, v; +var map = new Map([["", true]]); +for ([k = "", v = false] of map) { + k; + v; +} diff --git a/tests/baselines/reference/for-of45.types b/tests/baselines/reference/for-of45.types new file mode 100644 index 00000000000..8ac4b9fa7e9 --- /dev/null +++ b/tests/baselines/reference/for-of45.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of45.ts === +var k: string, v: boolean; +>k : string +>v : boolean + +var map = new Map([["", true]]); +>map : Map +>new Map([["", true]]) : Map +>Map : MapConstructor +>[["", true]] : [string, boolean][] +>["", true] : [string, boolean] + +for ([k = "", v = false] of map) { +>[k = "", v = false] : (string | boolean)[] +>k = "" : string +>k : string +>v = false : boolean +>v : boolean +>map : Map + + k; +>k : string + + v; +>v : boolean +} diff --git a/tests/baselines/reference/for-of46.errors.txt b/tests/baselines/reference/for-of46.errors.txt new file mode 100644 index 00000000000..13685b122ca --- /dev/null +++ b/tests/baselines/reference/for-of46.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/es6/for-ofStatements/for-of46.ts(3,7): error TS2322: Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/es6/for-ofStatements/for-of46.ts(3,18): error TS2322: Type 'string' is not assignable to type 'boolean'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of46.ts (2 errors) ==== + var k: string, v: boolean; + var map = new Map([["", true]]); + for ([k = false, v = ""] of map) { + ~ +!!! error TS2322: Type 'boolean' is not assignable to type 'string'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. + k; + v; + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of46.js b/tests/baselines/reference/for-of46.js new file mode 100644 index 00000000000..2ea15936c54 --- /dev/null +++ b/tests/baselines/reference/for-of46.js @@ -0,0 +1,15 @@ +//// [for-of46.ts] +var k: string, v: boolean; +var map = new Map([["", true]]); +for ([k = false, v = ""] of map) { + k; + v; +} + +//// [for-of46.js] +var k, v; +var map = new Map([["", true]]); +for ([k = false, v = ""] of map) { + k; + v; +} diff --git a/tests/baselines/reference/for-of47.errors.txt b/tests/baselines/reference/for-of47.errors.txt new file mode 100644 index 00000000000..241dc107caa --- /dev/null +++ b/tests/baselines/reference/for-of47.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/es6/for-ofStatements/for-of47.ts(4,13): error TS2322: Type 'boolean' is not assignable to type 'number'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of47.ts (1 errors) ==== + var x: string, y: number; + var array = [{ x: "", y: true }] + enum E { x } + for ({x, y: y = E.x} of array) { + ~ +!!! error TS2322: Type 'boolean' is not assignable to type 'number'. + x; + y; + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of47.js b/tests/baselines/reference/for-of47.js new file mode 100644 index 00000000000..b2de46d677f --- /dev/null +++ b/tests/baselines/reference/for-of47.js @@ -0,0 +1,20 @@ +//// [for-of47.ts] +var x: string, y: number; +var array = [{ x: "", y: true }] +enum E { x } +for ({x, y: y = E.x} of array) { + x; + y; +} + +//// [for-of47.js] +var x, y; +var array = [{ x: "", y: true }]; +var E; +(function (E) { + E[E["x"] = 0] = "x"; +})(E || (E = {})); +for ({ x, y: y = 0 /* x */ } of array) { + x; + y; +} diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of45.ts b/tests/cases/conformance/es6/for-ofStatements/for-of45.ts new file mode 100644 index 00000000000..f347069ab10 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of45.ts @@ -0,0 +1,7 @@ +//@target: ES6 +var k: string, v: boolean; +var map = new Map([["", true]]); +for ([k = "", v = false] of map) { + k; + v; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of46.ts b/tests/cases/conformance/es6/for-ofStatements/for-of46.ts new file mode 100644 index 00000000000..a08791068b7 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of46.ts @@ -0,0 +1,7 @@ +//@target: ES6 +var k: string, v: boolean; +var map = new Map([["", true]]); +for ([k = false, v = ""] of map) { + k; + v; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of47.ts b/tests/cases/conformance/es6/for-ofStatements/for-of47.ts new file mode 100644 index 00000000000..bd21a0db382 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of47.ts @@ -0,0 +1,8 @@ +//@target: ES6 +var x: string, y: number; +var array = [{ x: "", y: true }] +enum E { x } +for ({x, y: y = E.x} of array) { + x; + y; +} \ No newline at end of file From 84a22be433f8d0e44e2d98af38d685d214499f45 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 26 Feb 2015 15:58:46 -0800 Subject: [PATCH 75/96] Add a few more tests --- tests/baselines/reference/for-of48.errors.txt | 13 ++++++++++++ tests/baselines/reference/for-of48.js | 20 +++++++++++++++++++ tests/baselines/reference/for-of49.errors.txt | 12 +++++++++++ tests/baselines/reference/for-of49.js | 15 ++++++++++++++ tests/baselines/reference/for-of50.js | 13 ++++++++++++ tests/baselines/reference/for-of50.types | 19 ++++++++++++++++++ .../es6/for-ofStatements/for-of48.ts | 8 ++++++++ .../es6/for-ofStatements/for-of49.ts | 7 +++++++ .../es6/for-ofStatements/for-of50.ts | 6 ++++++ 9 files changed, 113 insertions(+) create mode 100644 tests/baselines/reference/for-of48.errors.txt create mode 100644 tests/baselines/reference/for-of48.js create mode 100644 tests/baselines/reference/for-of49.errors.txt create mode 100644 tests/baselines/reference/for-of49.js create mode 100644 tests/baselines/reference/for-of50.js create mode 100644 tests/baselines/reference/for-of50.types create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of48.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of49.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of50.ts diff --git a/tests/baselines/reference/for-of48.errors.txt b/tests/baselines/reference/for-of48.errors.txt new file mode 100644 index 00000000000..f6826e14c61 --- /dev/null +++ b/tests/baselines/reference/for-of48.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/es6/for-ofStatements/for-of48.ts(4,12): error TS1005: ':' expected. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of48.ts (1 errors) ==== + var x: string, y: number; + var array = [{ x: "", y: true }] + enum E { x } + for ({x, y = E.x} of array) { + ~ +!!! error TS1005: ':' expected. + x; + y; + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of48.js b/tests/baselines/reference/for-of48.js new file mode 100644 index 00000000000..15b9f5f12f6 --- /dev/null +++ b/tests/baselines/reference/for-of48.js @@ -0,0 +1,20 @@ +//// [for-of48.ts] +var x: string, y: number; +var array = [{ x: "", y: true }] +enum E { x } +for ({x, y = E.x} of array) { + x; + y; +} + +//// [for-of48.js] +var x, y; +var array = [{ x: "", y: true }]; +var E; +(function (E) { + E[E["x"] = 0] = "x"; +})(E || (E = {})); +for ({ x, y: = 0 /* x */ } of array) { + x; + y; +} diff --git a/tests/baselines/reference/for-of49.errors.txt b/tests/baselines/reference/for-of49.errors.txt new file mode 100644 index 00000000000..d5bc314e678 --- /dev/null +++ b/tests/baselines/reference/for-of49.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/es6/for-ofStatements/for-of49.ts(3,13): error TS2364: Invalid left-hand side of assignment expression. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of49.ts (1 errors) ==== + var k: string, v: boolean; + var map = new Map([["", true]]); + for ([k, ...[v]] of map) { + ~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + k; + v; + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of49.js b/tests/baselines/reference/for-of49.js new file mode 100644 index 00000000000..ac7f99f3607 --- /dev/null +++ b/tests/baselines/reference/for-of49.js @@ -0,0 +1,15 @@ +//// [for-of49.ts] +var k: string, v: boolean; +var map = new Map([["", true]]); +for ([k, ...[v]] of map) { + k; + v; +} + +//// [for-of49.js] +var k, v; +var map = new Map([["", true]]); +for ([k, ...[v]] of map) { + k; + v; +} diff --git a/tests/baselines/reference/for-of50.js b/tests/baselines/reference/for-of50.js new file mode 100644 index 00000000000..bf1192c59dd --- /dev/null +++ b/tests/baselines/reference/for-of50.js @@ -0,0 +1,13 @@ +//// [for-of50.ts] +var map = new Map([["", true]]); +for (const [k, v] of map) { + k; + v; +} + +//// [for-of50.js] +var map = new Map([["", true]]); +for (var [k, v] of map) { + k; + v; +} diff --git a/tests/baselines/reference/for-of50.types b/tests/baselines/reference/for-of50.types new file mode 100644 index 00000000000..a38f3855174 --- /dev/null +++ b/tests/baselines/reference/for-of50.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of50.ts === +var map = new Map([["", true]]); +>map : Map +>new Map([["", true]]) : Map +>Map : MapConstructor +>[["", true]] : [string, boolean][] +>["", true] : [string, boolean] + +for (const [k, v] of map) { +>k : string +>v : boolean +>map : Map + + k; +>k : string + + v; +>v : boolean +} diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of48.ts b/tests/cases/conformance/es6/for-ofStatements/for-of48.ts new file mode 100644 index 00000000000..c2e228d0fb9 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of48.ts @@ -0,0 +1,8 @@ +//@target: ES6 +var x: string, y: number; +var array = [{ x: "", y: true }] +enum E { x } +for ({x, y = E.x} of array) { + x; + y; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of49.ts b/tests/cases/conformance/es6/for-ofStatements/for-of49.ts new file mode 100644 index 00000000000..62fa4acd425 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of49.ts @@ -0,0 +1,7 @@ +//@target: ES6 +var k: string, v: boolean; +var map = new Map([["", true]]); +for ([k, ...[v]] of map) { + k; + v; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of50.ts b/tests/cases/conformance/es6/for-ofStatements/for-of50.ts new file mode 100644 index 00000000000..d4e1bba5ae4 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of50.ts @@ -0,0 +1,6 @@ +//@target: ES6 +var map = new Map([["", true]]); +for (const [k, v] of map) { + k; + v; +} \ No newline at end of file From fd0fd365977f344f153d426fdfea31d3865cd6fe Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 26 Feb 2015 18:16:21 -0800 Subject: [PATCH 76/96] Disallow destructuring in 'for...in' --- src/compiler/checker.ts | 10 +++++++++- src/compiler/diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 6 +++++- src/compiler/utilities.ts | 2 +- .../reference/for-inStatementsDestructuring.errors.txt | 7 +++++++ .../reference/for-inStatementsDestructuring.js | 5 +++++ .../for-inStatementsDestructuring2.errors.txt | 7 +++++++ .../reference/for-inStatementsDestructuring2.js | 5 +++++ .../for-inStatementsDestructuring3.errors.txt | 8 ++++++++ .../reference/for-inStatementsDestructuring3.js | 7 +++++++ .../for-inStatementsDestructuring4.errors.txt | 8 ++++++++ .../reference/for-inStatementsDestructuring4.js | 7 +++++++ .../baselines/reference/parserForStatement5.errors.txt | 4 ++-- .../for-inStatements/for-inStatementsDestructuring.ts | 1 + .../for-inStatements/for-inStatementsDestructuring2.ts | 1 + .../for-inStatements/for-inStatementsDestructuring3.ts | 2 ++ .../for-inStatements/for-inStatementsDestructuring4.ts | 2 ++ 17 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/for-inStatementsDestructuring.errors.txt create mode 100644 tests/baselines/reference/for-inStatementsDestructuring.js create mode 100644 tests/baselines/reference/for-inStatementsDestructuring2.errors.txt create mode 100644 tests/baselines/reference/for-inStatementsDestructuring2.js create mode 100644 tests/baselines/reference/for-inStatementsDestructuring3.errors.txt create mode 100644 tests/baselines/reference/for-inStatementsDestructuring3.js create mode 100644 tests/baselines/reference/for-inStatementsDestructuring4.errors.txt create mode 100644 tests/baselines/reference/for-inStatementsDestructuring4.js create mode 100644 tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring.ts create mode 100644 tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring2.ts create mode 100644 tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring3.ts create mode 100644 tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring4.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ae1e9a398a2..23aa8dc92c9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8806,6 +8806,11 @@ module ts { // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. if (node.initializer.kind === SyntaxKind.VariableDeclarationList) { + var variable = (node.initializer).declarations[0]; + if (variable && isBindingPattern(variable.name)) { + error(variable.name, Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); + } + checkForInOrForOfVariableDeclaration(node); } else { @@ -8815,7 +8820,10 @@ module ts { // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (!allConstituentTypesHaveKind(leftType, TypeFlags.Any | TypeFlags.StringLike)) { + if (varExpr.kind === SyntaxKind.ArrayLiteralExpression || varExpr.kind === SyntaxKind.ObjectLiteralExpression) { + error(varExpr, Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); + } + else if (!allConstituentTypesHaveKind(leftType, TypeFlags.Any | TypeFlags.StringLike)) { error(varExpr, Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); } else { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 08de6681226..7d1e4bcf34d 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -332,6 +332,7 @@ module ts { The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." }, The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." }, The_object_returned_by_the_next_method_of_the_iterator_must_have_a_value_property: { code: 2490, category: DiagnosticCategory.Error, key: "The object returned by the next method of the iterator must have a 'value' property." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 45661c570c2..81e451ef02a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1320,6 +1320,10 @@ "category": "Error", "code": 2490 }, + "The left-hand side of a 'for...in' statement cannot be a destructuring pattern.": { + "category": "Error", + "code": 2491 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", @@ -1596,7 +1600,7 @@ "Exported type alias '{0}' has or is using private name '{1}'.": { "category": "Error", "code": 4081 - }, + }, "The current host does not support the '{0}' option.": { "category": "Error", "code": 5001 diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b53c0007248..ddcd58fd2d6 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -665,7 +665,7 @@ module ts { } export function isBindingPattern(node: Node) { - return node.kind === SyntaxKind.ArrayBindingPattern || node.kind === SyntaxKind.ObjectBindingPattern; + return !!node && (node.kind === SyntaxKind.ArrayBindingPattern || node.kind === SyntaxKind.ObjectBindingPattern); } export function isInAmbientContext(node: Node): boolean { diff --git a/tests/baselines/reference/for-inStatementsDestructuring.errors.txt b/tests/baselines/reference/for-inStatementsDestructuring.errors.txt new file mode 100644 index 00000000000..e540b182cf5 --- /dev/null +++ b/tests/baselines/reference/for-inStatementsDestructuring.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring.ts(1,10): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. + + +==== tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring.ts (1 errors) ==== + for (var [a, b] in []) {} + ~~~~~~ +!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. \ No newline at end of file diff --git a/tests/baselines/reference/for-inStatementsDestructuring.js b/tests/baselines/reference/for-inStatementsDestructuring.js new file mode 100644 index 00000000000..e5e00d5b3ab --- /dev/null +++ b/tests/baselines/reference/for-inStatementsDestructuring.js @@ -0,0 +1,5 @@ +//// [for-inStatementsDestructuring.ts] +for (var [a, b] in []) {} + +//// [for-inStatementsDestructuring.js] +for (var _a = void 0, a = _a[0], b = _a[1] in []) { } diff --git a/tests/baselines/reference/for-inStatementsDestructuring2.errors.txt b/tests/baselines/reference/for-inStatementsDestructuring2.errors.txt new file mode 100644 index 00000000000..56d2436d4c7 --- /dev/null +++ b/tests/baselines/reference/for-inStatementsDestructuring2.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring2.ts(1,10): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. + + +==== tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring2.ts (1 errors) ==== + for (var {a, b} in []) {} + ~~~~~~ +!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. \ No newline at end of file diff --git a/tests/baselines/reference/for-inStatementsDestructuring2.js b/tests/baselines/reference/for-inStatementsDestructuring2.js new file mode 100644 index 00000000000..41a6d30919f --- /dev/null +++ b/tests/baselines/reference/for-inStatementsDestructuring2.js @@ -0,0 +1,5 @@ +//// [for-inStatementsDestructuring2.ts] +for (var {a, b} in []) {} + +//// [for-inStatementsDestructuring2.js] +for (var _a = void 0, a = _a.a, b = _a.b in []) { } diff --git a/tests/baselines/reference/for-inStatementsDestructuring3.errors.txt b/tests/baselines/reference/for-inStatementsDestructuring3.errors.txt new file mode 100644 index 00000000000..e3ce65f872d --- /dev/null +++ b/tests/baselines/reference/for-inStatementsDestructuring3.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring3.ts(2,6): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. + + +==== tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring3.ts (1 errors) ==== + var a, b; + for ([a, b] in []) { } + ~~~~~~ +!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. \ No newline at end of file diff --git a/tests/baselines/reference/for-inStatementsDestructuring3.js b/tests/baselines/reference/for-inStatementsDestructuring3.js new file mode 100644 index 00000000000..0970740acab --- /dev/null +++ b/tests/baselines/reference/for-inStatementsDestructuring3.js @@ -0,0 +1,7 @@ +//// [for-inStatementsDestructuring3.ts] +var a, b; +for ([a, b] in []) { } + +//// [for-inStatementsDestructuring3.js] +var a, b; +for ([a, b] in []) { } diff --git a/tests/baselines/reference/for-inStatementsDestructuring4.errors.txt b/tests/baselines/reference/for-inStatementsDestructuring4.errors.txt new file mode 100644 index 00000000000..8d3fe2d1b53 --- /dev/null +++ b/tests/baselines/reference/for-inStatementsDestructuring4.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring4.ts(2,6): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. + + +==== tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring4.ts (1 errors) ==== + var a, b; + for ({a, b} in []) { } + ~~~~~~ +!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. \ No newline at end of file diff --git a/tests/baselines/reference/for-inStatementsDestructuring4.js b/tests/baselines/reference/for-inStatementsDestructuring4.js new file mode 100644 index 00000000000..0cce61ac96d --- /dev/null +++ b/tests/baselines/reference/for-inStatementsDestructuring4.js @@ -0,0 +1,7 @@ +//// [for-inStatementsDestructuring4.ts] +var a, b; +for ({a, b} in []) { } + +//// [for-inStatementsDestructuring4.js] +var a, b; +for ({ a: a, b: b } in []) { } diff --git a/tests/baselines/reference/parserForStatement5.errors.txt b/tests/baselines/reference/parserForStatement5.errors.txt index 72c9bffce4c..ae1e855b765 100644 --- a/tests/baselines/reference/parserForStatement5.errors.txt +++ b/tests/baselines/reference/parserForStatement5.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement5.ts(1,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. +tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement5.ts(1,6): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement5.ts(1,12): error TS2304: Cannot find name 'b'. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement5.ts (2 errors) ==== for ({} in b) { ~~ -!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. +!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. ~ !!! error TS2304: Cannot find name 'b'. } \ No newline at end of file diff --git a/tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring.ts b/tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring.ts new file mode 100644 index 00000000000..94868ef3bd6 --- /dev/null +++ b/tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring.ts @@ -0,0 +1 @@ +for (var [a, b] in []) {} \ No newline at end of file diff --git a/tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring2.ts b/tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring2.ts new file mode 100644 index 00000000000..8671acc675b --- /dev/null +++ b/tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring2.ts @@ -0,0 +1 @@ +for (var {a, b} in []) {} \ No newline at end of file diff --git a/tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring3.ts b/tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring3.ts new file mode 100644 index 00000000000..411261dee43 --- /dev/null +++ b/tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring3.ts @@ -0,0 +1,2 @@ +var a, b; +for ([a, b] in []) { } \ No newline at end of file diff --git a/tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring4.ts b/tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring4.ts new file mode 100644 index 00000000000..816dd564b6a --- /dev/null +++ b/tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring4.ts @@ -0,0 +1,2 @@ +var a, b; +for ({a, b} in []) { } \ No newline at end of file From 996b9d27b4efd9a83613137ceb3f1f1e1cebddc2 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Fri, 27 Feb 2015 11:59:06 -0800 Subject: [PATCH 77/96] Respond to PR feedback --- src/compiler/checker.ts | 43 +++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 23aa8dc92c9..0f06a9d4b54 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5202,20 +5202,20 @@ module ts { if (container && container.parent && container.parent.kind === SyntaxKind.ClassDeclaration) { if (container.flags & NodeFlags.Static) { canUseSuperExpression = - container.kind === SyntaxKind.MethodDeclaration || - container.kind === SyntaxKind.MethodSignature || - container.kind === SyntaxKind.GetAccessor || - container.kind === SyntaxKind.SetAccessor; + container.kind === SyntaxKind.MethodDeclaration || + container.kind === SyntaxKind.MethodSignature || + container.kind === SyntaxKind.GetAccessor || + container.kind === SyntaxKind.SetAccessor; } else { canUseSuperExpression = - container.kind === SyntaxKind.MethodDeclaration || - container.kind === SyntaxKind.MethodSignature || - container.kind === SyntaxKind.GetAccessor || - container.kind === SyntaxKind.SetAccessor || - container.kind === SyntaxKind.PropertyDeclaration || - container.kind === SyntaxKind.PropertySignature || - container.kind === SyntaxKind.Constructor; + container.kind === SyntaxKind.MethodDeclaration || + container.kind === SyntaxKind.MethodSignature || + container.kind === SyntaxKind.GetAccessor || + container.kind === SyntaxKind.SetAccessor || + container.kind === SyntaxKind.PropertyDeclaration || + container.kind === SyntaxKind.PropertySignature || + container.kind === SyntaxKind.Constructor; } } } @@ -8879,10 +8879,6 @@ module ts { return iteratedType; function getIteratedTypeSubroutine(iterable: Type, expressionForError: Expression) { - if (allConstituentTypesHaveKind(iterable, TypeFlags.Any)) { - return undefined; - } - // We want to treat type as an iterable, and get the type it is an iterable of. The iterable // must have the following structure (annotated with the names of the variables below): // @@ -8900,6 +8896,19 @@ module ts { // // T is the type we are after. At every level that involves analyzing return types // of signatures, we union the return types of all the signatures. + // + // Another thing to note is that at any step of this process, we could run into a dead end, + // meaning either the property is missing, or we run into the anyType. If either of these things + // happens, we return undefined to signal that we could not find the iterated type. If a property + // is missing, and the previous step did not result in 'any', then we also give an error if the + // caller requested it. Then the caller can decide what to do in the case where there is no iterated + // type. This is different from returning anyType, because that would signify that we have matched the + // whole pattern and that T (above) is 'any'. + + if (allConstituentTypesHaveKind(iterable, TypeFlags.Any)) { + return undefined; + } + var iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator")); if (iteratorFunction && allConstituentTypesHaveKind(iteratorFunction, TypeFlags.Any)) { return undefined; @@ -10880,7 +10889,7 @@ module ts { globals[undefinedSymbol.name] = undefinedSymbol; // Initialize special types globalArraySymbol = getGlobalTypeSymbol("Array"); - globalArrayType = getTypeOfGlobalSymbol(globalArraySymbol, 1); + globalArrayType = getTypeOfGlobalSymbol(globalArraySymbol, /*arity*/ 1); globalObjectType = getGlobalType("Object"); globalFunctionType = getGlobalType("Function"); globalStringType = getGlobalType("String"); @@ -10894,7 +10903,7 @@ module ts { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); - globalIterableType = getGlobalType("Iterable", 1); + globalIterableType = getGlobalType("Iterable", /*arity*/ 1); } else { globalTemplateStringsArrayType = unknownType; From f23c79f3ae1d4fa775a2f053c3577bc1241f7cdc Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 27 Feb 2015 13:39:57 -0800 Subject: [PATCH 78/96] Fix issue where source files could get corrupted. This could happen when you had multiple language services, and they were sharing some files. If a file got edited in one LS, it could get corrupted in the other. Now, the DocumentRegistry serves as the canonical source of 'good' source files. Language services always go to it to get the correct source file instead of trying to manually update their own source files when they are notified about changes from the host. --- src/services/services.ts | 67 ++++++++++--------- .../baselines/reference/APISample_compile.js | 16 ++--- .../reference/APISample_compile.types | 22 ++---- tests/baselines/reference/APISample_linter.js | 16 ++--- .../reference/APISample_linter.types | 22 ++---- .../reference/APISample_transform.js | 16 ++--- .../reference/APISample_transform.types | 22 ++---- .../baselines/reference/APISample_watcher.js | 16 ++--- .../reference/APISample_watcher.types | 22 ++---- 9 files changed, 73 insertions(+), 146 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index c13ae22718b..734337a84cd 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1270,31 +1270,21 @@ module ts { /** * Request an updated version of an already existing SourceFile with a given fileName - * and compilationSettings. The update will intern call updateLanguageServiceSourceFile + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile * to get an updated SourceFile. * - * Note: It is not allowed to call update on a SourceFile that was not acquired from this - * registry originally. - * - * @param sourceFile The original sourceFile object to update * @param fileName The name of the file requested * @param compilationSettings Some compilation settings like target affects the * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm textChangeRange Change ranges since the last snapshot. Only used if the file - * was not found in the registry and a new one was created. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. */ updateDocument( - sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, - version: string, - textChangeRange: TextChangeRange): SourceFile; + version: string): SourceFile; /** * Informs the DocumentRegistry that a file is not needed any longer. @@ -1730,20 +1720,22 @@ module ts { } function updateDocument( - sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, - version: string, - textChangeRange: TextChangeRange - ): SourceFile { + version: string): SourceFile { var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ false); Debug.assert(bucket !== undefined); var entry = lookUp(bucket, fileName); Debug.assert(entry !== undefined); - entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, textChangeRange); + // Check with the host if anything actually changed. + if (entry.sourceFile.version !== version) { + var textChangeRange = scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot); + entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, textChangeRange); + } + return entry.sourceFile; } @@ -2162,19 +2154,34 @@ module ts { // it is safe to reuse the souceFiles; if not, then the shape of the AST can change, and the oldSourceFile // can not be reused. we have to dump all syntax trees and create new ones. if (!changesInCompilationSettingsAffectSyntax) { - // Check if the old program had this file already var oldSourceFile = program && program.getSourceFile(fileName); if (oldSourceFile) { - // This SourceFile is safe to reuse, return it - if (sourceFileUpToDate(oldSourceFile)) { - return oldSourceFile; - } - - // We have an older version of the sourceFile, incrementally parse the changes - var textChangeRange = hostFileInformation.scriptSnapshot.getChangeRange(oldSourceFile.scriptSnapshot); - return documentRegistry.updateDocument(oldSourceFile, fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, textChangeRange); + // We already had a source file for this file name. Go to the registry to + // ensure that we get the right up to date version of it. We need this to + // address the following 'race'. Specifically, say we have the following: + // + // LS1 + // \ + // DocumentRegistry + // / + // LS2 + // + // Each LS has a reference to file 'foo.ts' at version 1. LS2 then updates + // it's version of 'foo.ts' to version 2. This will cause LS2 and the + // DocumentRegistry to have version 2 of the document. HOwever, LS1 will + // have version 1. And *importantly* this source file will be *corrupt*. + // The act of creating version 2 of the file irrevocably damages the version + // 1 file. + // + // So, later when we call into LS1, we need to make sure that it doesn't use + // it's source file any more, and instead defers to DocumentRegistry to get + // either version 1, version 2 (or some other version) depending on what the + // host says should be used. + return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } + + // We didn't already have the file. Fall through and acquire it from the registry. } // Could not find this file in the old program, create a new SourceFile for it. @@ -2228,8 +2235,8 @@ module ts { function dispose(): void { if (program) { - forEach(program.getSourceFiles(), - (f) => { documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); }); + forEach(program.getSourceFiles(), f => + documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions())); } } diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 7f5bc29906a..b23774c680f 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -1872,25 +1872,17 @@ declare module "typescript" { acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; /** * Request an updated version of an already existing SourceFile with a given fileName - * and compilationSettings. The update will intern call updateLanguageServiceSourceFile + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile * to get an updated SourceFile. * - * Note: It is not allowed to call update on a SourceFile that was not acquired from this - * registry originally. - * - * @param sourceFile The original sourceFile object to update * @param fileName The name of the file requested * @param compilationSettings Some compilation settings like target affects the * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm textChangeRange Change ranges since the last snapshot. Only used if the file - * was not found in the registry and a new one was created. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. */ - updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile; + updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; /** * Informs the DocumentRegistry that a file is not needed any longer. * diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index d93a48b7852..0ec22a74523 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -5849,36 +5849,24 @@ declare module "typescript" { /** * Request an updated version of an already existing SourceFile with a given fileName - * and compilationSettings. The update will intern call updateLanguageServiceSourceFile + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile * to get an updated SourceFile. * - * Note: It is not allowed to call update on a SourceFile that was not acquired from this - * registry originally. - * - * @param sourceFile The original sourceFile object to update * @param fileName The name of the file requested * @param compilationSettings Some compilation settings like target affects the * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm textChangeRange Change ranges since the last snapshot. Only used if the file - * was not found in the registry and a new one was created. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. */ - updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile; ->updateDocument : (sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange) => SourceFile ->sourceFile : SourceFile ->SourceFile : SourceFile + updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; +>updateDocument : (fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string) => SourceFile >fileName : string >compilationSettings : CompilerOptions >CompilerOptions : CompilerOptions >scriptSnapshot : IScriptSnapshot >IScriptSnapshot : IScriptSnapshot >version : string ->textChangeRange : TextChangeRange ->TextChangeRange : TextChangeRange >SourceFile : SourceFile /** diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 36dd2421add..df516a19e5c 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -1903,25 +1903,17 @@ declare module "typescript" { acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; /** * Request an updated version of an already existing SourceFile with a given fileName - * and compilationSettings. The update will intern call updateLanguageServiceSourceFile + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile * to get an updated SourceFile. * - * Note: It is not allowed to call update on a SourceFile that was not acquired from this - * registry originally. - * - * @param sourceFile The original sourceFile object to update * @param fileName The name of the file requested * @param compilationSettings Some compilation settings like target affects the * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm textChangeRange Change ranges since the last snapshot. Only used if the file - * was not found in the registry and a new one was created. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. */ - updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile; + updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; /** * Informs the DocumentRegistry that a file is not needed any longer. * diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 7a282b61f42..013bd1a84fd 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -5995,36 +5995,24 @@ declare module "typescript" { /** * Request an updated version of an already existing SourceFile with a given fileName - * and compilationSettings. The update will intern call updateLanguageServiceSourceFile + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile * to get an updated SourceFile. * - * Note: It is not allowed to call update on a SourceFile that was not acquired from this - * registry originally. - * - * @param sourceFile The original sourceFile object to update * @param fileName The name of the file requested * @param compilationSettings Some compilation settings like target affects the * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm textChangeRange Change ranges since the last snapshot. Only used if the file - * was not found in the registry and a new one was created. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. */ - updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile; ->updateDocument : (sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange) => SourceFile ->sourceFile : SourceFile ->SourceFile : SourceFile + updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; +>updateDocument : (fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string) => SourceFile >fileName : string >compilationSettings : CompilerOptions >CompilerOptions : CompilerOptions >scriptSnapshot : IScriptSnapshot >IScriptSnapshot : IScriptSnapshot >version : string ->textChangeRange : TextChangeRange ->TextChangeRange : TextChangeRange >SourceFile : SourceFile /** diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 2ead5140261..759a0fcc047 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -1904,25 +1904,17 @@ declare module "typescript" { acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; /** * Request an updated version of an already existing SourceFile with a given fileName - * and compilationSettings. The update will intern call updateLanguageServiceSourceFile + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile * to get an updated SourceFile. * - * Note: It is not allowed to call update on a SourceFile that was not acquired from this - * registry originally. - * - * @param sourceFile The original sourceFile object to update * @param fileName The name of the file requested * @param compilationSettings Some compilation settings like target affects the * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm textChangeRange Change ranges since the last snapshot. Only used if the file - * was not found in the registry and a new one was created. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. */ - updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile; + updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; /** * Informs the DocumentRegistry that a file is not needed any longer. * diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index 7a9d0523653..92a2a5885ff 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -5945,36 +5945,24 @@ declare module "typescript" { /** * Request an updated version of an already existing SourceFile with a given fileName - * and compilationSettings. The update will intern call updateLanguageServiceSourceFile + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile * to get an updated SourceFile. * - * Note: It is not allowed to call update on a SourceFile that was not acquired from this - * registry originally. - * - * @param sourceFile The original sourceFile object to update * @param fileName The name of the file requested * @param compilationSettings Some compilation settings like target affects the * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm textChangeRange Change ranges since the last snapshot. Only used if the file - * was not found in the registry and a new one was created. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. */ - updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile; ->updateDocument : (sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange) => SourceFile ->sourceFile : SourceFile ->SourceFile : SourceFile + updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; +>updateDocument : (fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string) => SourceFile >fileName : string >compilationSettings : CompilerOptions >CompilerOptions : CompilerOptions >scriptSnapshot : IScriptSnapshot >IScriptSnapshot : IScriptSnapshot >version : string ->textChangeRange : TextChangeRange ->TextChangeRange : TextChangeRange >SourceFile : SourceFile /** diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 1d1f9f03d68..80149676d8f 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -1941,25 +1941,17 @@ declare module "typescript" { acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; /** * Request an updated version of an already existing SourceFile with a given fileName - * and compilationSettings. The update will intern call updateLanguageServiceSourceFile + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile * to get an updated SourceFile. * - * Note: It is not allowed to call update on a SourceFile that was not acquired from this - * registry originally. - * - * @param sourceFile The original sourceFile object to update * @param fileName The name of the file requested * @param compilationSettings Some compilation settings like target affects the * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm textChangeRange Change ranges since the last snapshot. Only used if the file - * was not found in the registry and a new one was created. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. */ - updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile; + updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; /** * Informs the DocumentRegistry that a file is not needed any longer. * diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 55c48d1354b..7eb789aca9f 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -6118,36 +6118,24 @@ declare module "typescript" { /** * Request an updated version of an already existing SourceFile with a given fileName - * and compilationSettings. The update will intern call updateLanguageServiceSourceFile + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile * to get an updated SourceFile. * - * Note: It is not allowed to call update on a SourceFile that was not acquired from this - * registry originally. - * - * @param sourceFile The original sourceFile object to update * @param fileName The name of the file requested * @param compilationSettings Some compilation settings like target affects the * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm textChangeRange Change ranges since the last snapshot. Only used if the file - * was not found in the registry and a new one was created. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. */ - updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile; ->updateDocument : (sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange) => SourceFile ->sourceFile : SourceFile ->SourceFile : SourceFile + updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; +>updateDocument : (fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string) => SourceFile >fileName : string >compilationSettings : CompilerOptions >CompilerOptions : CompilerOptions >scriptSnapshot : IScriptSnapshot >IScriptSnapshot : IScriptSnapshot >version : string ->textChangeRange : TextChangeRange ->TextChangeRange : TextChangeRange >SourceFile : SourceFile /** From 505c1f258f6a611efccd4b4b56655ee65b53385a Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 27 Feb 2015 13:45:29 -0800 Subject: [PATCH 79/96] Update comment. --- src/services/services.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/services/services.ts b/src/services/services.ts index 734337a84cd..e295bb0c912 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1732,6 +1732,8 @@ module ts { // Check with the host if anything actually changed. if (entry.sourceFile.version !== version) { + // If so, ask the host for what changed between these two versions and then do the + // actual incremental parsing. var textChangeRange = scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot); entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, textChangeRange); } From 604c37eee2239c942e0ea17842f79fb9461c288e Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 27 Feb 2015 15:29:31 -0800 Subject: [PATCH 80/96] Whenever a document is acquired, make sure it returns a source that corresponds to the version requested. --- src/services/services.ts | 71 ++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index e295bb0c912..ececc1082ca 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1432,7 +1432,11 @@ module ts { interface DocumentRegistryEntry { sourceFile: SourceFile; - refCount: number; + + // The number of language services that this source file is referenced in. When no more + // language services are referencing the file, then the file can be removed from the + // registry. + languageServiceRefCount: number; owners: string[]; } @@ -1661,6 +1665,8 @@ module ts { } export function createDocumentRegistry(): DocumentRegistry { + // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have + // for those settings. var buckets: Map> = {}; function getKeyFromCompilationSettings(settings: CompilerOptions): string { @@ -1684,7 +1690,7 @@ module ts { var entry = entries[i]; sourceFiles.push({ name: i, - refCount: entry.refCount, + refCount: entry.languageServiceRefCount, references: entry.owners.slice(0) }); } @@ -1697,45 +1703,52 @@ module ts { return JSON.stringify(bucketInfoArray, null, 2); } - function acquireDocument( + function acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ true); + } + + function updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ false); + } + + function acquireOrUpdateDocument( fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, - version: string): SourceFile { + version: string, + acquiring: boolean): SourceFile { var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); var entry = lookUp(bucket, fileName); if (!entry) { + Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); + + // Have never seen this file with these settings. Create a new source file for it. var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false); bucket[fileName] = entry = { sourceFile: sourceFile, - refCount: 0, + languageServiceRefCount: 0, owners: [] }; } - entry.refCount++; + else { + // We have an entry for this file. However, it may be for a different version of + // the script snapshot. If so, update it appropriately. Otherwise, we can just + // return it as is. + if (entry.sourceFile.version !== version) { + entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, + scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); + } + } - return entry.sourceFile; - } - - function updateDocument( - fileName: string, - compilationSettings: CompilerOptions, - scriptSnapshot: IScriptSnapshot, - version: string): SourceFile { - - var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ false); - Debug.assert(bucket !== undefined); - var entry = lookUp(bucket, fileName); - Debug.assert(entry !== undefined); - - // Check with the host if anything actually changed. - if (entry.sourceFile.version !== version) { - // If so, ask the host for what changed between these two versions and then do the - // actual incremental parsing. - var textChangeRange = scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot); - entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, textChangeRange); + // If we're acquiring, then this is the first time this LS is asking for this document. + // Increase our ref count so we know there's another LS using the document. If we're + // not acquiring, then that means the LS is 'updating' the file instead, and that means + // it has already acquired the document previously. As such, we do not need to increase + // the ref count. + if (acquiring) { + entry.languageServiceRefCount++; } return entry.sourceFile; @@ -1746,10 +1759,10 @@ module ts { Debug.assert(bucket !== undefined); var entry = lookUp(bucket, fileName); - entry.refCount--; + entry.languageServiceRefCount--; - Debug.assert(entry.refCount >= 0); - if (entry.refCount === 0) { + Debug.assert(entry.languageServiceRefCount >= 0); + if (entry.languageServiceRefCount === 0) { delete bucket[fileName]; } } From 7c2cc7698655b82d689f48c9cd250cd8f4b1f2e5 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 27 Feb 2015 15:38:24 -0800 Subject: [PATCH 81/96] Respond to code review comments --- src/services/services.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index a2400369aa2..7893a32d2f2 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1752,8 +1752,6 @@ module ts { }); } - - function recordModuleName() { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); @@ -1824,7 +1822,7 @@ module ts { if (token === SyntaxKind.OpenBraceToken) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== SyntaxKind.OpenBraceToken && token !== SyntaxKind.CloseBraceToken) { + while (token !== SyntaxKind.CloseBraceToken) { token = scanner.scan(); } @@ -1864,7 +1862,7 @@ module ts { if (token === SyntaxKind.OpenBraceToken) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== SyntaxKind.OpenBraceToken && token !== SyntaxKind.CloseBraceToken) { + while (token !== SyntaxKind.CloseBraceToken) { token = scanner.scan(); } From dc917d9d88e3c0d7a67482dc88b2277bb1471d08 Mon Sep 17 00:00:00 2001 From: Dan Quirk Date: Fri, 27 Feb 2015 16:09:44 -0800 Subject: [PATCH 82/96] Adding npm related badges to the readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f7e55d2dffe..ac00ef085bc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ [![Build Status](https://travis-ci.org/Microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/Microsoft/TypeScript) [![Issue Stats](http://issuestats.com/github/Microsoft/TypeScript/badge/pr)](http://issuestats.com/github/microsoft/typescript) [![Issue Stats](http://issuestats.com/github/Microsoft/TypeScript/badge/issue)](http://issuestats.com/github/microsoft/typescript) +[![npm version](https://badge.fury.io/js/typescript.svg)](http://badge.fury.io/js/typescript) +[![Downloads](http://img.shields.io/npm/dm/TypeScript.svg)](https://npmjs.org/package/typescript) # TypeScript From 545fa20efdfa6d8372052324abc70fce6686ed5a Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 27 Feb 2015 16:25:44 -0800 Subject: [PATCH 83/96] Add registry tests. --- .../unittests/services/documentRegistry.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/cases/unittests/services/documentRegistry.ts b/tests/cases/unittests/services/documentRegistry.ts index 339c8866329..34dda543c1c 100644 --- a/tests/cases/unittests/services/documentRegistry.ts +++ b/tests/cases/unittests/services/documentRegistry.ts @@ -35,4 +35,40 @@ describe("DocumentRegistry", () => { assert(f3 === f4, "Changed module: Expected to have the same instance of the document"); }); + + it("Acquiring document gets correct version 1", () => { + var documentRegistry = ts.createDocumentRegistry(); + var defaultCompilerOptions = ts.getDefaultCompilerOptions(); + + // Simulate one LS getting the document. + var f1 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), /* version */ "1"); + + // Simulate another LS getting the document at another version. + var f2 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, ts.ScriptSnapshot.fromString("var x = 1;"), /* version */ "2"); + + assert(f2.version === "2"); + }); + + it("Acquiring document gets correct version 2", () => { + debugger; + var documentRegistry = ts.createDocumentRegistry(); + var defaultCompilerOptions = ts.getDefaultCompilerOptions(); + + var contents = "var x = 1;" + var snapshot = ts.ScriptSnapshot.fromString(contents); + + // Simulate one LS getting the document. + var f1 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "1"); + + // Simulate another LS getting that document. + var f2 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "1"); + + // Now LS1 updates their document. + var f3 = documentRegistry.updateDocument(f1, "file1.ts", defaultCompilerOptions, snapshot, /* version */ "2", + ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length)); + + // Now LS2 tries to update their document. + var f4 = documentRegistry.updateDocument(f1, "file1.ts", defaultCompilerOptions, snapshot, /* version */ "3", + ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length)); + }); }); \ No newline at end of file From 3c78a0522bb56bd96b298321b7458ae924a0a5fd Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 27 Feb 2015 16:29:12 -0800 Subject: [PATCH 84/96] Add tests. --- tests/cases/unittests/services/documentRegistry.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/cases/unittests/services/documentRegistry.ts b/tests/cases/unittests/services/documentRegistry.ts index 34dda543c1c..8fc466b857f 100644 --- a/tests/cases/unittests/services/documentRegistry.ts +++ b/tests/cases/unittests/services/documentRegistry.ts @@ -50,13 +50,15 @@ describe("DocumentRegistry", () => { }); it("Acquiring document gets correct version 2", () => { - debugger; var documentRegistry = ts.createDocumentRegistry(); var defaultCompilerOptions = ts.getDefaultCompilerOptions(); var contents = "var x = 1;" var snapshot = ts.ScriptSnapshot.fromString(contents); + // Always treat any change as a full change. + snapshot.getChangeRange = old => ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length); + // Simulate one LS getting the document. var f1 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "1"); @@ -64,11 +66,9 @@ describe("DocumentRegistry", () => { var f2 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "1"); // Now LS1 updates their document. - var f3 = documentRegistry.updateDocument(f1, "file1.ts", defaultCompilerOptions, snapshot, /* version */ "2", - ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length)); + var f3 = documentRegistry.updateDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "2"); // Now LS2 tries to update their document. - var f4 = documentRegistry.updateDocument(f1, "file1.ts", defaultCompilerOptions, snapshot, /* version */ "3", - ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length)); + var f4 = documentRegistry.updateDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "3"); }); }); \ No newline at end of file From 3b3a94c7d7bea54baec55507d67dc458004da59d Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 27 Feb 2015 17:24:24 -0800 Subject: [PATCH 85/96] addressed PR feedback --- src/compiler/binder.ts | 12 +++--- src/compiler/checker.ts | 33 ++++++++------ .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/emitter.ts | 43 ++----------------- src/compiler/utilities.ts | 7 +-- .../reference/downlevelLetConst18.errors.txt | 28 ++++++------ 7 files changed, 49 insertions(+), 78 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7245ee4e82c..f5b23ffb59b 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -244,10 +244,13 @@ module ts { } if (isBlockScopeContainer) { - // clean locals in block scope container if - // - current node does not have local variables - // - current node is not source file (source file always have locals) - setBlockScopeContainer(node, /*cleanLocals*/ (symbolKind & SymbolFlags.HasLocals) == 0 && node.kind !== SyntaxKind.SourceFile); + // 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); @@ -354,7 +357,6 @@ module ts { function bindCatchVariableDeclaration(node: CatchClause) { bindChildren(node, /*symbolKind:*/ 0, /*isBlockScopeContainer:*/ true); - } function bindBlockScopedVariableDeclaration(node: Declaration) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7f6482bb272..2776c6595a8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5080,6 +5080,18 @@ module ts { 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 || @@ -5104,21 +5116,13 @@ module ts { container = container.parent; } - var inFunction = false; - var current = node.parent; - while (current && current !== container) { - if (isAnyFunction(current)) { - inFunction = true; - break; - } - current = current.parent; - } + var inFunction = isInsideFunction(node.parent, container); - var current: Node = container; + var current = container; while (current && !nodeStartsNewLexicalEnvironment(current)) { if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { if (inFunction) { - grammarErrorOnFirstToken(current, Diagnostics.Code_in_the_loop_captures_block_scoped_variable_0_in_closure_This_is_natively_supported_in_ECMAScript_6_or_higher, declarationNameToString(node)); + grammarErrorOnFirstToken(current, Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, declarationNameToString(node)); } // mark value declaration so during emit they can have a special handling getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.BlockScopedBindingInLoop; @@ -10744,7 +10748,12 @@ module ts { getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, SymbolFlags.BlockScopedVariable | SymbolFlags.Import, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); - if (symbol && (symbol.flags & SymbolFlags.BlockScopedVariable)) { + 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); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 36439a1fccd..0e8d1bdd25f 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -397,7 +397,7 @@ module ts { Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." }, - Code_in_the_loop_captures_block_scoped_variable_0_in_closure_This_is_natively_supported_in_ECMAScript_6_or_higher: { code: 4091, category: DiagnosticCategory.Error, key: "Code in the loop captures block-scoped variable '{0}' in closure. This is natively supported in ECMAScript 6 or higher." }, + Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: DiagnosticCategory.Error, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 22083ab6d56..cca74aac7ce 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1581,7 +1581,7 @@ "category": "Error", "code": 4081 }, - "Code in the loop captures block-scoped variable '{0}' in closure. This is natively supported in ECMAScript 6 or higher.": { + "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 }, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 53040fe776b..c4f7c79939f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -34,16 +34,6 @@ module ts { previous: ScopeFrame; } - // isExisingName function has signature string -> boolean, however check if name is unique should be performed - // in the context of some location. Instead of creating function expression and closing over location - // every time isExisingName is called we use one single instance of NameLookup that is effectively a - // handrolled closure where value of location can be swapped. This allows to avoid allocations of closures on - // every call and use one shared instance instead - interface NameLookup { - setLocation(location: Node): void; - isExistingName(name: string): boolean; - } - type GetSymbolAccessibilityDiagnostic = (symbolAccesibilityResult: SymbolAccessiblityResult) => SymbolAccessibilityDiagnostic; interface EmitTextWriterWithSymbolWriter extends EmitTextWriter, SymbolWriter { @@ -1541,7 +1531,6 @@ module ts { var sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap ? [] : undefined; var diagnostics: Diagnostic[] = []; var newLine = host.getNewLine(); - var nameLookup: NameLookup; if (targetSourceFile === undefined) { forEach(host.getSourceFiles(), sourceFile => { @@ -1686,38 +1675,14 @@ module ts { } } - // creates instance of NameLookup to be used in 'isExisingName' checks. - // see comment for NameLookup for more information - function createNameLookup(): NameLookup { - var location: Node; - return { - setLocation, - isExistingName: checkName - } - - function setLocation(l: Node): void { - location = l; - } - - function checkName(name: string): boolean { - Debug.assert(location !== undefined); - return isExistingName(location, name); - } - } - - function makeUniqueName(location: Node, baseName: string): string { + 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 { - if (!nameLookup) { - nameLookup = createNameLookup(); - } - nameLookup.setLocation(location); - name = generateUniqueName(baseName, nameLookup.isExistingName); - nameLookup.setLocation(undefined); + name = generateUniqueName(baseName, n => isExistingName(location, n)); } if (!currentScopeNames) { @@ -2560,7 +2525,7 @@ module ts { function getBlockScopedVariableId(node: Identifier): number { // return undefined for synthesized nodes - return node.parent && resolver.getBlockScopedVariableId(node); + return !nodeIsSynthesized(node) && resolver.getBlockScopedVariableId(node); } function emitIdentifier(node: Identifier) { @@ -3924,7 +3889,7 @@ module ts { ? blockScopeContainer : blockScopeContainer.parent; - var generatedName = makeUniqueName(parent, (node).text); + var generatedName = generateUniqueNameForLocation(parent, (node).text); var variableId = resolver.getBlockScopedVariableId(node); if (!generatedBlockScopeNames) { generatedBlockScopeNames = []; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 12ca74e953b..af574572055 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1139,17 +1139,14 @@ 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; } - // @internal export function nodeIsSynthesized(node: Node): boolean { return node.pos === -1 && node.end === -1; } - // @internal export function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node { var node = createNode(kind); node.pos = -1; @@ -1158,7 +1155,6 @@ module ts { return node; } - // @internal export function generateUniqueName(baseName: string, isExistingName: (name: string) => boolean): string { // First try '_name' if (baseName.charCodeAt(0) !== CharacterCodes._) { @@ -1173,7 +1169,7 @@ module ts { } var i = 1; while (true) { - name = baseName + i; + var name = baseName + i; if (!isExistingName(name)) { return name; } @@ -1181,7 +1177,6 @@ module ts { } } - // @internal export function createDiagnosticCollection(): DiagnosticCollection { var nonFileDiagnostics: Diagnostic[] = []; var fileDiagnostics: Map = {}; diff --git a/tests/baselines/reference/downlevelLetConst18.errors.txt b/tests/baselines/reference/downlevelLetConst18.errors.txt index 93a2578defa..8f30b0f802a 100644 --- a/tests/baselines/reference/downlevelLetConst18.errors.txt +++ b/tests/baselines/reference/downlevelLetConst18.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/downlevelLetConst18.ts(3,1): error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +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: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +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: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. -tests/cases/compiler/downlevelLetConst18.ts(15,1): error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. -tests/cases/compiler/downlevelLetConst18.ts(19,1): error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. -tests/cases/compiler/downlevelLetConst18.ts(23,1): error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. -tests/cases/compiler/downlevelLetConst18.ts(27,1): error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +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) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/downlevelLetConst18.ts(27,1): error TS4091: Code in the loo for (let x; ;) { ~~~ -!!! error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +!!! 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. @@ -22,7 +22,7 @@ tests/cases/compiler/downlevelLetConst18.ts(27,1): error TS4091: Code in the loo for (let x; ;) { ~~~ -!!! error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +!!! 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. @@ -30,31 +30,31 @@ tests/cases/compiler/downlevelLetConst18.ts(27,1): error TS4091: Code in the loo for (let x; ;) { ~~~ -!!! error TS4091: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +!!! 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: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +!!! 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: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +!!! 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: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +!!! 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: Code in the loop captures block-scoped variable 'x' in closure. This is natively supported in ECMAScript 6 or higher. +!!! error TS4091: Loop contains block-scoped variable 'x' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher. ({ set foo(v) { x } }) } \ No newline at end of file From b58f16b0213d98c9b2cceea2aa3676d31d92781d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 1 Mar 2015 11:35:31 -0800 Subject: [PATCH 86/96] Don't intern all strings and numbers. Just the ones used as declaration names. --- src/services/services.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index ececc1082ca..a4f1bb8563a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4044,7 +4044,16 @@ module ts { break; case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: - nameTable[(node).text] = (node).text; + // We want to store any numbers/strings if they were a name that could be + // related to a declaration. So, if we have 'import x = require("something")' + // then we want 'something' to be in the name table. Similarly, if we have + // "a['propname']" then we want to store "propname" in the name table. + if (isDeclarationName(node) || + node.parent.kind === SyntaxKind.ExternalModuleReference || + isArgumentOfElementAccessExpression(node)) { + + nameTable[(node).text] = (node).text; + } break; default: forEachChild(node, walk); @@ -4052,6 +4061,13 @@ module ts { } } + function isArgumentOfElementAccessExpression(node: Node) { + return node && + node.parent && + node.parent.kind === SyntaxKind.ElementAccessExpression && + (node.parent).argumentExpression === node; + } + function getReferencesForNode(node: Node, sourceFiles: SourceFile[], searchOnlyInCurrentFile: boolean, findInStrings: boolean, findInComments: boolean): ReferenceEntry[] { // Labels if (isLabelName(node)) { From 08439b7a89e43844225723ec7184055b7f20c656 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 1 Mar 2015 15:42:23 -0800 Subject: [PATCH 87/96] Expose a way to get the name table from the LS. --- src/services/services.ts | 91 +++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 43 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 65eba7e0a65..efee09e01e6 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4138,43 +4138,6 @@ module ts { return getReferencesForNode(node, program.getSourceFiles(), /*searchOnlyInCurrentFile*/ false, findInStrings, findInComments); } - function initializeNameTable(sourceFile: SourceFile): void { - var nameTable: Map = {}; - - walk(sourceFile); - sourceFile.nameTable = nameTable; - - function walk(node: Node) { - switch (node.kind) { - case SyntaxKind.Identifier: - nameTable[(node).text] = (node).text; - break; - case SyntaxKind.StringLiteral: - case SyntaxKind.NumericLiteral: - // We want to store any numbers/strings if they were a name that could be - // related to a declaration. So, if we have 'import x = require("something")' - // then we want 'something' to be in the name table. Similarly, if we have - // "a['propname']" then we want to store "propname" in the name table. - if (isDeclarationName(node) || - node.parent.kind === SyntaxKind.ExternalModuleReference || - isArgumentOfElementAccessExpression(node)) { - - nameTable[(node).text] = (node).text; - } - break; - default: - forEachChild(node, walk); - } - } - } - - function isArgumentOfElementAccessExpression(node: Node) { - return node && - node.parent && - node.parent.kind === SyntaxKind.ElementAccessExpression && - (node.parent).argumentExpression === node; - } - function getReferencesForNode(node: Node, sourceFiles: SourceFile[], searchOnlyInCurrentFile: boolean, findInStrings: boolean, findInComments: boolean): ReferenceEntry[] { // Labels if (isLabelName(node)) { @@ -4241,13 +4204,9 @@ module ts { forEach(sourceFiles, sourceFile => { cancellationToken.throwIfCancellationRequested(); - if (!sourceFile.nameTable) { - initializeNameTable(sourceFile) - } + var nameTable = getNameTable(sourceFile); - Debug.assert(sourceFile.nameTable !== undefined); - - if (lookUp(sourceFile.nameTable, internedName)) { + if (lookUp(nameTable, internedName)) { result = result || []; getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result); } @@ -5791,6 +5750,52 @@ module ts { }; } + /* @internal */ + export function getNameTable(sourceFile: SourceFile): Map { + if (!sourceFile.nameTable) { + initializeNameTable(sourceFile) + } + + return sourceFile.nameTable; + } + + function initializeNameTable(sourceFile: SourceFile): void { + var nameTable: Map = {}; + + walk(sourceFile); + sourceFile.nameTable = nameTable; + + function walk(node: Node) { + switch (node.kind) { + case SyntaxKind.Identifier: + nameTable[(node).text] = (node).text; + break; + case SyntaxKind.StringLiteral: + case SyntaxKind.NumericLiteral: + // We want to store any numbers/strings if they were a name that could be + // related to a declaration. So, if we have 'import x = require("something")' + // then we want 'something' to be in the name table. Similarly, if we have + // "a['propname']" then we want to store "propname" in the name table. + if (isDeclarationName(node) || + node.parent.kind === SyntaxKind.ExternalModuleReference || + isArgumentOfElementAccessExpression(node)) { + + nameTable[(node).text] = (node).text; + } + break; + default: + forEachChild(node, walk); + } + } + } + + function isArgumentOfElementAccessExpression(node: Node) { + return node && + node.parent && + node.parent.kind === SyntaxKind.ElementAccessExpression && + (node.parent).argumentExpression === node; + } + /// Classifier export function createClassifier(): Classifier { var scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false); From 8da49aaf443e453b40c967fe429b3b47b0f39c1a Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Sun, 1 Mar 2015 16:45:14 -0800 Subject: [PATCH 88/96] Address feedback --- src/compiler/checker.ts | 59 +++++++++++-------- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- tests/baselines/reference/for-of15.errors.txt | 4 +- 4 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0d4b243c71f..9daa87daed4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5514,7 +5514,7 @@ module ts { var index = indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, IndexKind.Number) - || (languageVersion >= ScriptTarget.ES6 ? getIteratedType(type, /*expressionForError*/ undefined) : undefined); + || (languageVersion >= ScriptTarget.ES6 ? checkIteratedType(type, /*expressionForError*/ undefined) : undefined); } return undefined; } @@ -7024,7 +7024,7 @@ module ts { return true; } - function checkReferenceExpression(n: Node, invalidReferenceMessage: DiagnosticMessage, constantVarianleMessage: DiagnosticMessage): boolean { + function checkReferenceExpression(n: Node, invalidReferenceMessage: DiagnosticMessage, constantVariableMessage: DiagnosticMessage): boolean { function findSymbol(n: Node): Symbol { var symbol = getNodeLinks(n).resolvedSymbol; // Because we got the symbol from the resolvedSymbol property, it might be of kind @@ -7091,7 +7091,7 @@ module ts { return false; } if (isConstVariableReference(n)) { - error(n, constantVarianleMessage); + error(n, constantVariableMessage); return false; } return true; @@ -7465,8 +7465,8 @@ module ts { function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { var offendingSymbolOperand = someConstituentTypeHasKind(leftType, TypeFlags.ESSymbol) ? node.left : - someConstituentTypeHasKind(rightType, TypeFlags.ESSymbol) ? node.right : - undefined; + someConstituentTypeHasKind(rightType, TypeFlags.ESSymbol) ? node.right : + undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator)); return false; @@ -8812,15 +8812,17 @@ module ts { checkGrammarForInOrForOfStatement(node) // Check the LHS and RHS - // If decl: Check var decl, which will check the RHS - // If expr: Check LHS, check that it's a reference, and check that RHS is assignable to it, which will check RHS + // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS + // via getTypeForVariableDeclarationInForOfStatement. + // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. + // Then check that the RHS is assignable to it. if (node.initializer.kind === SyntaxKind.VariableDeclarationList) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var rightType = checkExpression(node.expression); - var iteratedType = getIteratedType(rightType, node.expression); + var iteratedType = checkIteratedType(rightType, node.expression); // There may be a destructuring assignment on the left side if (varExpr.kind === SyntaxKind.ArrayLiteralExpression || varExpr.kind === SyntaxKind.ObjectLiteralExpression) { @@ -8831,10 +8833,11 @@ module ts { } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, Diagnostics.Invalid_left_hand_side_in_for_of_statement, Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); + checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ Diagnostics.Invalid_left_hand_side_in_for_of_statement, + /*constantVariableMessage*/ Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); // iteratedType will be undefined if the rightType was missing properties/signatures - // required to get it's iteratedType (like [Symbol.iterator] or next). This may be + // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside // getIteratedType. if (iteratedType) { @@ -8894,6 +8897,7 @@ module ts { function checkForInOrForOfVariableDeclaration(iterationStatement: ForInStatement | ForOfStatement): void { var variableDeclarationList = iterationStatement.initializer; + // checkGrammarForInOrForOfStatement will check that there is exactly one declaration. if (variableDeclarationList.declarations.length >= 1) { var decl = variableDeclarationList.declarations[0]; checkVariableDeclaration(decl); @@ -8907,28 +8911,31 @@ module ts { } // iteratedType will be undefined if the for-of expression type was missing properties/signatures - // required to get it's iteratedType (like [Symbol.iterator] or next). This may be + // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside // getIteratedType. - return getIteratedType(getTypeOfExpression(forOfStatement.expression), forOfStatement.expression) || anyType; + var expressionType = getTypeOfExpression(forOfStatement.expression); + return checkIteratedType(expressionType, forOfStatement.expression) || anyType; } /** * When expressionForError is undefined, it means we should not report any errors. */ - function getIteratedType(iterable: Type, expressionForError: Expression): Type { + function checkIteratedType(iterable: Type, expressionForError: Expression): Type { Debug.assert(languageVersion >= ScriptTarget.ES6); - var iteratedType = getIteratedTypeSubroutine(iterable, expressionForError); + var iteratedType = getIteratedType(iterable, expressionForError); // Now even though we have extracted the iteratedType, we will have to validate that the type // passed in is actually an Iterable. if (expressionForError && iteratedType) { - var completeIterableType = globalIterableType !== emptyObjectType ? createTypeReference(globalIterableType, [iteratedType]) : emptyObjectType; + var completeIterableType = globalIterableType !== emptyObjectType + ? createTypeReference(globalIterableType, [iteratedType]) + : emptyObjectType; checkTypeAssignableTo(iterable, completeIterableType, expressionForError); } return iteratedType; - function getIteratedTypeSubroutine(iterable: Type, expressionForError: Expression) { + function getIteratedType(iterable: Type, expressionForError: Expression) { // We want to treat type as an iterable, and get the type it is an iterable of. The iterable // must have the following structure (annotated with the names of the variables below): // @@ -8998,7 +9005,7 @@ module ts { var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); if (!iteratorNextValue) { if (expressionForError) { - error(expressionForError, Diagnostics.The_object_returned_by_the_next_method_of_the_iterator_must_have_a_value_property); + error(expressionForError, Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); } return undefined; } @@ -11671,17 +11678,17 @@ module ts { } if (node.initializer) { // Error on equals token which immediate precedes the initializer - return grammarErrorAtPos(getSourceFileOfNode(node), node.initializer.pos - 1, 1, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + var equalsTokenLength = "=".length; + return grammarErrorAtPos(getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength, + equalsTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } - else { - if (!node.initializer) { - if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) { - return grammarErrorOnNode(node, Diagnostics.A_destructuring_declaration_must_have_an_initializer); - } - if (isConst(node)) { - return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized); - } + else if (!node.initializer) { + if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) { + return grammarErrorOnNode(node, Diagnostics.A_destructuring_declaration_must_have_an_initializer); + } + if (isConst(node)) { + return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized); } } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index ca826b01a19..758c3ee6ba7 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -333,7 +333,7 @@ module ts { Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." }, The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." }, The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." }, - The_object_returned_by_the_next_method_of_the_iterator_must_have_a_value_property: { code: 2490, category: DiagnosticCategory.Error, key: "The object returned by the next method of the iterator must have a 'value' property." }, + The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index efc7bb6a202..b4786bb93d7 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1324,7 +1324,7 @@ "category": "Error", "code": 2489 }, - "The object returned by the next method of the iterator must have a 'value' property.": { + "The type returned by the 'next()' method of an iterator must have a 'value' property.": { "category": "Error", "code": 2490 }, diff --git a/tests/baselines/reference/for-of15.errors.txt b/tests/baselines/reference/for-of15.errors.txt index ab6b6c03ea7..20a4abe4bd0 100644 --- a/tests/baselines/reference/for-of15.errors.txt +++ b/tests/baselines/reference/for-of15.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/for-ofStatements/for-of15.ts(2,11): error TS2490: The object returned by the next method of the iterator must have a 'value' property. +tests/cases/conformance/es6/for-ofStatements/for-of15.ts(2,11): error TS2490: The type returned by the 'next()' method of an iterator must have a 'value' property. ==== tests/cases/conformance/es6/for-ofStatements/for-of15.ts (1 errors) ==== var v: string; for (v of new StringIterator) { } // Should fail ~~~~~~~~~~~~~~~~~~ -!!! error TS2490: The object returned by the next method of the iterator must have a 'value' property. +!!! error TS2490: The type returned by the 'next()' method of an iterator must have a 'value' property. class StringIterator { next() { From cb9768649655288c33a8ee1171eb392b23b93707 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Sun, 1 Mar 2015 18:16:20 -0800 Subject: [PATCH 89/96] Add tests for scoping --- tests/baselines/reference/for-of51.errors.txt | 7 +++++++ tests/baselines/reference/for-of51.js | 5 +++++ tests/baselines/reference/for-of52.errors.txt | 10 ++++++++++ tests/baselines/reference/for-of52.js | 5 +++++ tests/baselines/reference/for-of53.js | 9 +++++++++ tests/baselines/reference/for-of53.types | 8 ++++++++ tests/baselines/reference/for-of54.errors.txt | 9 +++++++++ tests/baselines/reference/for-of54.js | 9 +++++++++ tests/baselines/reference/for-of55.js | 11 +++++++++++ tests/baselines/reference/for-of55.types | 12 ++++++++++++ .../conformance/es6/for-ofStatements/for-of51.ts | 2 ++ .../conformance/es6/for-ofStatements/for-of52.ts | 2 ++ .../conformance/es6/for-ofStatements/for-of53.ts | 4 ++++ .../conformance/es6/for-ofStatements/for-of54.ts | 4 ++++ .../conformance/es6/for-ofStatements/for-of55.ts | 5 +++++ 15 files changed, 102 insertions(+) create mode 100644 tests/baselines/reference/for-of51.errors.txt create mode 100644 tests/baselines/reference/for-of51.js create mode 100644 tests/baselines/reference/for-of52.errors.txt create mode 100644 tests/baselines/reference/for-of52.js create mode 100644 tests/baselines/reference/for-of53.js create mode 100644 tests/baselines/reference/for-of53.types create mode 100644 tests/baselines/reference/for-of54.errors.txt create mode 100644 tests/baselines/reference/for-of54.js create mode 100644 tests/baselines/reference/for-of55.js create mode 100644 tests/baselines/reference/for-of55.types create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of51.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of52.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of53.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of54.ts create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of55.ts diff --git a/tests/baselines/reference/for-of51.errors.txt b/tests/baselines/reference/for-of51.errors.txt new file mode 100644 index 00000000000..54a6eb9d89c --- /dev/null +++ b/tests/baselines/reference/for-of51.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/for-ofStatements/for-of51.ts(1,10): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of51.ts (1 errors) ==== + for (let let of []) {} + ~~~ +!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. \ No newline at end of file diff --git a/tests/baselines/reference/for-of51.js b/tests/baselines/reference/for-of51.js new file mode 100644 index 00000000000..cae8c8b38fe --- /dev/null +++ b/tests/baselines/reference/for-of51.js @@ -0,0 +1,5 @@ +//// [for-of51.ts] +for (let let of []) {} + +//// [for-of51.js] +for (let let of []) { } diff --git a/tests/baselines/reference/for-of52.errors.txt b/tests/baselines/reference/for-of52.errors.txt new file mode 100644 index 00000000000..5110768e104 --- /dev/null +++ b/tests/baselines/reference/for-of52.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/es6/for-ofStatements/for-of52.ts(1,11): error TS2451: Cannot redeclare block-scoped variable 'v'. +tests/cases/conformance/es6/for-ofStatements/for-of52.ts(1,14): error TS2451: Cannot redeclare block-scoped variable 'v'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of52.ts (2 errors) ==== + for (let [v, v] of [[]]) {} + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'v'. + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'v'. \ No newline at end of file diff --git a/tests/baselines/reference/for-of52.js b/tests/baselines/reference/for-of52.js new file mode 100644 index 00000000000..48e1dca936c --- /dev/null +++ b/tests/baselines/reference/for-of52.js @@ -0,0 +1,5 @@ +//// [for-of52.ts] +for (let [v, v] of [[]]) {} + +//// [for-of52.js] +for (let [v, v] of [[]]) { } diff --git a/tests/baselines/reference/for-of53.js b/tests/baselines/reference/for-of53.js new file mode 100644 index 00000000000..810d23644a6 --- /dev/null +++ b/tests/baselines/reference/for-of53.js @@ -0,0 +1,9 @@ +//// [for-of53.ts] +for (let v of []) { + var v; +} + +//// [for-of53.js] +for (let v of []) { + var v; +} diff --git a/tests/baselines/reference/for-of53.types b/tests/baselines/reference/for-of53.types new file mode 100644 index 00000000000..475d63e9b5a --- /dev/null +++ b/tests/baselines/reference/for-of53.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of53.ts === +for (let v of []) { +>v : any +>[] : undefined[] + + var v; +>v : any +} diff --git a/tests/baselines/reference/for-of54.errors.txt b/tests/baselines/reference/for-of54.errors.txt new file mode 100644 index 00000000000..cb040c44382 --- /dev/null +++ b/tests/baselines/reference/for-of54.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/for-ofStatements/for-of54.ts(2,9): error TS2481: Cannot initialize outer scoped variable 'v' in the same scope as block scoped declaration 'v'. + + +==== tests/cases/conformance/es6/for-ofStatements/for-of54.ts (1 errors) ==== + for (let v of []) { + var v = 0; + ~ +!!! error TS2481: Cannot initialize outer scoped variable 'v' in the same scope as block scoped declaration 'v'. + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of54.js b/tests/baselines/reference/for-of54.js new file mode 100644 index 00000000000..442e6e86146 --- /dev/null +++ b/tests/baselines/reference/for-of54.js @@ -0,0 +1,9 @@ +//// [for-of54.ts] +for (let v of []) { + var v = 0; +} + +//// [for-of54.js] +for (let v of []) { + var v = 0; +} diff --git a/tests/baselines/reference/for-of55.js b/tests/baselines/reference/for-of55.js new file mode 100644 index 00000000000..a0f949c6ce5 --- /dev/null +++ b/tests/baselines/reference/for-of55.js @@ -0,0 +1,11 @@ +//// [for-of55.ts] +let v = [1]; +for (let v of v) { + v; +} + +//// [for-of55.js] +let v = [1]; +for (let v of v) { + v; +} diff --git a/tests/baselines/reference/for-of55.types b/tests/baselines/reference/for-of55.types new file mode 100644 index 00000000000..b0f5aab3fee --- /dev/null +++ b/tests/baselines/reference/for-of55.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of55.ts === +let v = [1]; +>v : number[] +>[1] : number[] + +for (let v of v) { +>v : any +>v : any + + v; +>v : any +} diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of51.ts b/tests/cases/conformance/es6/for-ofStatements/for-of51.ts new file mode 100644 index 00000000000..a97b05d7fe9 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of51.ts @@ -0,0 +1,2 @@ +//@target: ES6 +for (let let of []) {} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of52.ts b/tests/cases/conformance/es6/for-ofStatements/for-of52.ts new file mode 100644 index 00000000000..80cc680060d --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of52.ts @@ -0,0 +1,2 @@ +//@target: ES6 +for (let [v, v] of [[]]) {} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of53.ts b/tests/cases/conformance/es6/for-ofStatements/for-of53.ts new file mode 100644 index 00000000000..34db2bab704 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of53.ts @@ -0,0 +1,4 @@ +//@target: ES6 +for (let v of []) { + var v; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of54.ts b/tests/cases/conformance/es6/for-ofStatements/for-of54.ts new file mode 100644 index 00000000000..6cf79ae0945 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of54.ts @@ -0,0 +1,4 @@ +//@target: ES6 +for (let v of []) { + var v = 0; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of55.ts b/tests/cases/conformance/es6/for-ofStatements/for-of55.ts new file mode 100644 index 00000000000..e1d16a3e068 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of55.ts @@ -0,0 +1,5 @@ +//@target: ES6 +let v = [1]; +for (let v of v) { + v; +} \ No newline at end of file From 689d7d1c5d637c41cc44cf9318dc2db3170e3bec Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Mon, 2 Mar 2015 12:11:16 +0800 Subject: [PATCH 90/96] Adds editorconfig file --- .editorconfig | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000000..109cdbd79f6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ + +root = true + +[{src,scripts}/**.{ts,json,js}] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 From 4c6ebb132b774d829c90f0f3503f5168a31e9d37 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Mon, 2 Mar 2015 12:54:38 +0800 Subject: [PATCH 91/96] Changes to crlf --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 109cdbd79f6..8ed330c4a24 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,7 +2,7 @@ root = true [{src,scripts}/**.{ts,json,js}] -end_of_line = lf +end_of_line = crlf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true From 7dd7b4344813003f86b99b1bdc89e2e8fd770f1a Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 2 Mar 2015 13:53:59 -0800 Subject: [PATCH 92/96] Add one more test --- tests/baselines/reference/for-of56.js | 5 +++++ tests/baselines/reference/for-of56.types | 5 +++++ tests/cases/conformance/es6/for-ofStatements/for-of56.ts | 2 ++ 3 files changed, 12 insertions(+) create mode 100644 tests/baselines/reference/for-of56.js create mode 100644 tests/baselines/reference/for-of56.types create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of56.ts diff --git a/tests/baselines/reference/for-of56.js b/tests/baselines/reference/for-of56.js new file mode 100644 index 00000000000..0992b9c0bb9 --- /dev/null +++ b/tests/baselines/reference/for-of56.js @@ -0,0 +1,5 @@ +//// [for-of56.ts] +for (var let of []) {} + +//// [for-of56.js] +for (var let of []) { } diff --git a/tests/baselines/reference/for-of56.types b/tests/baselines/reference/for-of56.types new file mode 100644 index 00000000000..d853ff9f62c --- /dev/null +++ b/tests/baselines/reference/for-of56.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of56.ts === +for (var let of []) {} +>let : any +>[] : undefined[] + diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of56.ts b/tests/cases/conformance/es6/for-ofStatements/for-of56.ts new file mode 100644 index 00000000000..3b73a529425 --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of56.ts @@ -0,0 +1,2 @@ +//@target: ES6 +for (var let of []) {} \ No newline at end of file From e452cff5a7125e6045f419a0e2833824db4f736a Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 2 Mar 2015 14:08:32 -0800 Subject: [PATCH 93/96] Make fields internal. --- src/services/services.ts | 7 ++++--- tests/baselines/reference/APISample_compile.js | 3 --- tests/baselines/reference/APISample_compile.types | 11 ----------- tests/baselines/reference/APISample_linter.js | 3 --- tests/baselines/reference/APISample_linter.types | 11 ----------- tests/baselines/reference/APISample_transform.js | 3 --- tests/baselines/reference/APISample_transform.types | 11 ----------- tests/baselines/reference/APISample_watcher.js | 3 --- tests/baselines/reference/APISample_watcher.types | 11 ----------- 9 files changed, 4 insertions(+), 59 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index efee09e01e6..fc4d1eff223 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -58,9 +58,10 @@ module ts { } export interface SourceFile { - version: string; - scriptSnapshot: IScriptSnapshot; - nameTable: Map; + /* @internal */ version: string; + /* @internal */ scriptSnapshot: IScriptSnapshot; + /* @internal */ nameTable: Map; + getNamedDeclarations(): Declaration[]; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineStarts(): number[]; diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 1f2cb776526..ca2bb9511a7 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -1518,9 +1518,6 @@ declare module "typescript" { getDocumentationComment(): SymbolDisplayPart[]; } interface SourceFile { - version: string; - scriptSnapshot: IScriptSnapshot; - nameTable: Map; getNamedDeclarations(): Declaration[]; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineStarts(): number[]; diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index e2526712f12..896290f73c0 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -4896,17 +4896,6 @@ declare module "typescript" { interface SourceFile { >SourceFile : SourceFile - version: string; ->version : string - - scriptSnapshot: IScriptSnapshot; ->scriptSnapshot : IScriptSnapshot ->IScriptSnapshot : IScriptSnapshot - - nameTable: Map; ->nameTable : Map ->Map : Map - getNamedDeclarations(): Declaration[]; >getNamedDeclarations : () => Declaration[] >Declaration : Declaration diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 4998afa4661..d6177798c76 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -1549,9 +1549,6 @@ declare module "typescript" { getDocumentationComment(): SymbolDisplayPart[]; } interface SourceFile { - version: string; - scriptSnapshot: IScriptSnapshot; - nameTable: Map; getNamedDeclarations(): Declaration[]; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineStarts(): number[]; diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index b8908315d6d..73c1c529627 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -5042,17 +5042,6 @@ declare module "typescript" { interface SourceFile { >SourceFile : SourceFile - version: string; ->version : string - - scriptSnapshot: IScriptSnapshot; ->scriptSnapshot : IScriptSnapshot ->IScriptSnapshot : IScriptSnapshot - - nameTable: Map; ->nameTable : Map ->Map : Map - getNamedDeclarations(): Declaration[]; >getNamedDeclarations : () => Declaration[] >Declaration : Declaration diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 92d19b46e39..ba7e4a195d8 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -1550,9 +1550,6 @@ declare module "typescript" { getDocumentationComment(): SymbolDisplayPart[]; } interface SourceFile { - version: string; - scriptSnapshot: IScriptSnapshot; - nameTable: Map; getNamedDeclarations(): Declaration[]; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineStarts(): number[]; diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index a6c77fc7f05..6d28f9194ed 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -4992,17 +4992,6 @@ declare module "typescript" { interface SourceFile { >SourceFile : SourceFile - version: string; ->version : string - - scriptSnapshot: IScriptSnapshot; ->scriptSnapshot : IScriptSnapshot ->IScriptSnapshot : IScriptSnapshot - - nameTable: Map; ->nameTable : Map ->Map : Map - getNamedDeclarations(): Declaration[]; >getNamedDeclarations : () => Declaration[] >Declaration : Declaration diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 1528b0331c1..3d4c3308b8c 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -1587,9 +1587,6 @@ declare module "typescript" { getDocumentationComment(): SymbolDisplayPart[]; } interface SourceFile { - version: string; - scriptSnapshot: IScriptSnapshot; - nameTable: Map; getNamedDeclarations(): Declaration[]; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineStarts(): number[]; diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 9a245522156..f7d9c0e283e 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -5165,17 +5165,6 @@ declare module "typescript" { interface SourceFile { >SourceFile : SourceFile - version: string; ->version : string - - scriptSnapshot: IScriptSnapshot; ->scriptSnapshot : IScriptSnapshot ->IScriptSnapshot : IScriptSnapshot - - nameTable: Map; ->nameTable : Map ->Map : Map - getNamedDeclarations(): Declaration[]; >getNamedDeclarations : () => Declaration[] >Declaration : Declaration From 3b1a390d7c617759851cd4564b3e29cda0c528a5 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 2 Mar 2015 14:38:24 -0800 Subject: [PATCH 94/96] Use CRLF, not LF. --- .editorconfig | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.editorconfig b/.editorconfig index 8ed330c4a24..de6d5c49a72 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,10 +1,10 @@ - -root = true - -[{src,scripts}/**.{ts,json,js}] -end_of_line = crlf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true -indent_style = space -indent_size = 4 + +root = true + +[{src,scripts}/**.{ts,json,js}] +end_of_line = crlf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 From 0afdedd4ec8f0ce22068fa6229a665f9ab8e130d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 2 Mar 2015 14:41:44 -0800 Subject: [PATCH 95/96] Use CRLF for line endings. --- tests/cases/fourslash/addDeclareToModule.ts | 16 +- tests/cases/fourslash/addDuplicateSetter.ts | 20 +- ...unctionInDuplicatedConstructorClassBody.ts | 24 +- .../fourslash/addInterfaceMemberAboveClass.ts | 40 +- .../addInterfaceToNotSatisfyConstraint.ts | 28 +- tests/cases/fourslash/addMemberToInterface.ts | 40 +- .../cases/fourslash/addMethodToInterface1.ts | 28 +- tests/cases/fourslash/addVarToConstructor1.ts | 48 +- ...gOnMultilineExpressionAndParametersList.ts | 50 +- ...tsAreAvailableAfterEditsAtEndOfFunction.ts | 28 +- .../fourslash/argumentsIndexExpression.ts | 16 +- .../cases/fourslash/arrayConcatTypeCheck0.ts | 32 +- .../cases/fourslash/arrayConcatTypeCheck1.ts | 52 +- .../fourslash/autoFormattingOnPasting.ts | 54 +- .../fourslash/breakpointValidationClass.ts | 6 +- .../breakpointValidationClassAmbient.ts | 2 +- .../fourslash/breakpointValidationClasses.ts | 32 +- .../fourslash/brokenClassErrorRecovery.ts | 20 +- .../classExtendsInterfaceSigHelp1.ts | 8 +- .../fourslash/classRenamingErrorRecovery.ts | 16 +- .../fourslash/closedCommentsInConstructor.ts | 14 +- .../completionListAfterClassExtends.ts | 30 +- ...mpletionListAndMemberListOnCommentedDot.ts | 34 +- ...pletionListAndMemberListOnCommentedLine.ts | 12 +- ...nListAndMemberListOnCommentedWhiteSpace.ts | 34 +- ...pletionListAtDeclarationOfParameterType.ts | 26 +- ...tifierDefinitionLocations_destructuring.ts | 44 +- ...stBuilderLocations_VariableDeclarations.ts | 68 +- .../cases/fourslash/completionListCladule.ts | 2 +- .../fourslash/completionListErrorRecovery.ts | 22 +- .../fourslash/completionListErrorRecovery2.ts | 22 +- .../completionListFunctionMembers.ts | 20 +- .../completionListInstanceProtectedMembers.ts | 124 +-- ...completionListInstanceProtectedMembers2.ts | 152 ++-- ...completionListInstanceProtectedMembers3.ts | 92 +-- ...completionListInstanceProtectedMembers4.ts | 68 +- .../completionListInvalidMemberNames2.ts | 2 +- .../fourslash/completionListObjectMembers.ts | 10 +- ...completionListOnPrivateVariableInModule.ts | 10 +- .../completionListStaticProtectedMembers.ts | 116 +-- .../completionListStaticProtectedMembers2.ts | 138 ++-- .../completionListStaticProtectedMembers3.ts | 88 +-- .../completionListStaticProtectedMembers4.ts | 98 +-- .../completionListWithAmbientDeclaration.ts | 30 +- .../completionListWithModulesFromModule.ts | 650 ++++++++-------- ...pletionListWithModulesInsideModuleScope.ts | 726 +++++++++--------- ...letionListWithModulesOutsideModuleScope.ts | 580 +++++++------- ...etionListWithModulesOutsideModuleScope2.ts | 548 ++++++------- ...tenceOnIndentionsOfChainedFunctionCalls.ts | 40 +- ...dentionsOfObjectsInAListAfterFormatting.ts | 20 +- ...onsistentContextualTypeErrorsAfterEdits.ts | 4 +- .../contextualTypingGenericFunction1.ts | 8 +- tests/cases/fourslash/definition.ts | 2 +- .../deleteExtensionInReopenedInterface.ts | 46 +- .../deleteModifierBeforeVarStatement1.ts | 128 +-- tests/cases/fourslash/deleteTypeParameter.ts | 6 +- .../fourslash/duplicateClassModuleError0.ts | 50 +- .../fourslash/duplicateTypeParameters.ts | 12 +- tests/cases/fourslash/eval.ts | 28 +- .../fourslash/exportClauseErrorReporting0.ts | 32 +- .../fourslash/failureToImplementClass.ts | 16 +- .../findAllRefsWithLeadingUnderscoreNames7.ts | 2 +- .../findAllRefsWithLeadingUnderscoreNames8.ts | 2 +- .../findAllRefsWithLeadingUnderscoreNames9.ts | 2 +- ...rmatArrayOrObjectLiteralsInVariableList.ts | 12 +- tests/cases/fourslash/formatColonAndQMark.ts | 30 +- .../fourslash/formatControlFlowConstructs.ts | 10 +- .../fourslash/formatDebuggerStatement.ts | 18 +- tests/cases/fourslash/formatEmptyBlock.ts | 14 +- tests/cases/fourslash/formatEmptyParamList.ts | 8 +- tests/cases/fourslash/formatImplicitModule.ts | 20 +- .../fourslash/formatImportDeclaration.ts | 34 +- ...ormatNestedClassWithOpenBraceOnNewLines.ts | 40 +- .../fourslash/formatSelectionWithTrivia.ts | 22 +- .../formatVariableDeclarationList.ts | 80 +- tests/cases/fourslash/formatWithStatement.ts | 46 +- .../fourslash/formattingFatArrowFunctions.ts | 580 +++++++------- .../formattingKeywordAsIdentifier.ts | 12 +- .../cases/fourslash/formattingNestedScopes.ts | 2 +- tests/cases/fourslash/formattingOnClasses.ts | 412 +++++----- .../fourslash/formattingOnClosingBracket.ts | 180 ++--- .../fourslash/formattingOnCommaOperator.ts | 24 +- .../formattingOnDoWhileNoSemicolon.ts | 36 +- .../formattingOnDocumentReadyFunction.ts | 22 +- .../formattingOnEmptyInterfaceLiteral.ts | 48 +- .../fourslash/formattingOnInvalidCodes.ts | 544 ++++++------- .../formattingOnModuleIndentation.ts | 24 +- .../formattingOnNestedDoWhileByEnter.ts | 44 +- .../fourslash/formattingOnNestedStatements.ts | 26 +- .../fourslash/formattingOnObjectLiteral.ts | 168 ++-- .../formattingOnOpenBraceOfFunctions.ts | 18 +- .../cases/fourslash/formattingOnSemiColon.ts | 12 +- .../fourslash/formattingOnSingleLineBlocks.ts | 30 +- .../formattingOnStatementsWithNoSemicolon.ts | 340 ++++---- .../formattingOnTabAfterCloseCurly.ts | 62 +- .../fourslash/formattingSkippedTokens.ts | 2 +- .../formattingSpacesAfterConstructor.ts | 10 +- ...formattingWithEnterAfterMultilineString.ts | 28 +- .../cases/fourslash/functionOverloadCount.ts | 6 +- .../functionRenamingErrorRecovery.ts | 16 +- .../genericArityEnforcementAfterEdit.ts | 20 +- .../fourslash/genericRespecialization1.ts | 148 ++-- .../fourslash/getDeclarationDiagnostics.ts | 38 +- .../getEmitOutputDeclarationMultiFiles.ts | 42 +- .../getEmitOutputDeclarationSingleFile.ts | 42 +- .../fourslash/getEmitOutputExternalModule.ts | 36 +- .../fourslash/getEmitOutputExternalModule2.ts | 50 +- tests/cases/fourslash/getEmitOutputMapRoot.ts | 32 +- .../cases/fourslash/getEmitOutputNoErrors.ts | 22 +- .../fourslash/getEmitOutputOnlyOneFile.ts | 38 +- .../fourslash/getEmitOutputSingleFile.ts | 40 +- .../fourslash/getEmitOutputSingleFile2.ts | 54 +- .../cases/fourslash/getEmitOutputSourceMap.ts | 28 +- .../fourslash/getEmitOutputSourceMap2.ts | 44 +- .../fourslash/getEmitOutputSourceRoot.ts | 30 +- .../getEmitOutputSourceRootMultiFiles.ts | 46 +- .../getEmitOutputWithDeclarationFile.ts | 32 +- .../getEmitOutputWithDeclarationFile2.ts | 34 +- .../getEmitOutputWithDeclarationFile3.ts | 42 +- .../getEmitOutputWithEarlySemanticErrors.ts | 18 +- .../getEmitOutputWithEmitterErrors.ts | 28 +- .../getEmitOutputWithEmitterErrors2.ts | 26 +- .../getEmitOutputWithSemanticErrors.ts | 16 +- .../getEmitOutputWithSemanticErrors2.ts | 18 +- ...utputWithSemanticErrorsForMultipleFiles.ts | 30 +- ...tputWithSemanticErrorsForMultipleFiles2.ts | 32 +- ...tputWithSyntacticErrorsForMultipleFiles.ts | 28 +- ...putWithSyntacticErrorsForMultipleFiles2.ts | 30 +- .../getEmitOutputWithSyntaxErrors.ts | 16 +- .../getMatchingBracesAdjacentBraces.ts | 2 +- .../getOccurrencesModifiersNegatives1.ts | 2 +- ...etOccurrencesPropertyInAliasedInterface.ts | 2 +- .../fourslash/getOccurrencesSetAndGet.ts | 68 +- .../fourslash/getOccurrencesSetAndGet2.ts | 68 +- .../fourslash/getOccurrencesSetAndGet3.ts | 68 +- tests/cases/fourslash/getOccurrencesThrow.ts | 116 +-- tests/cases/fourslash/getOccurrencesThrow2.ts | 116 +-- tests/cases/fourslash/getOccurrencesThrow3.ts | 116 +-- tests/cases/fourslash/getOccurrencesThrow4.ts | 116 +-- tests/cases/fourslash/getOccurrencesThrow5.ts | 116 +-- tests/cases/fourslash/getOccurrencesThrow6.ts | 56 +- tests/cases/fourslash/getOccurrencesThrow7.ts | 62 +- tests/cases/fourslash/getOccurrencesThrow8.ts | 62 +- .../getSemanticDiagnosticForDeclaration.ts | 22 +- .../getSemanticDiagnosticForNoDeclaration.ts | 20 +- ...lobalCompletionListInsideObjectLiterals.ts | 96 +-- .../goToDefinitionConstructorOverloads.ts | 44 +- .../fourslash/goToDefinitionDifferentFile.ts | 58 +- .../goToDefinitionDifferentFileIndirectly.ts | 70 +- .../goToDefinitionExternamModuleName.ts | 2 +- .../goToDefinitionExternamModuleName2.ts | 2 +- .../goToDefinitionExternamModuleName3.ts | 2 +- .../goToDefinitionInterfaceAfterImplement.ts | 30 +- ...oToDefinitionShadowVariableInsideModule.ts | 18 +- .../goToDefinitionShorthandProperty.ts | 2 +- .../fourslash/goToDefinitionSourceUnit.ts | 48 +- tests/cases/fourslash/importDeclPaste0.ts | 36 +- .../cases/fourslash/importValueUsedAsType.ts | 24 +- ...alUpdateToClassImplementingGenericClass.ts | 2 +- ...indentionsOfCommentBlockAfterFormatting.ts | 84 +- .../indexSignatureWithoutAnnotation.ts | 10 +- ...sertArgumentBeforeOverloadedConstructor.ts | 22 +- ...insertInterfaceAndCheckTypeLiteralField.ts | 22 +- .../fourslash/insertMethodCallAboveOthers.ts | 16 +- .../fourslash/insertPublicBeforeSetter.ts | 18 +- .../fourslash/insertSecondTryCatchBlock.ts | 14 +- tests/cases/fourslash/localGetReferences.ts | 474 ++++++------ .../cases/fourslash/malformedObjectLiteral.ts | 20 +- .../memberCompletionFromFunctionCall.ts | 22 +- .../cases/fourslash/memberConstructorEdits.ts | 50 +- .../fourslash/memberListAfterSingleDot.ts | 10 +- .../fourslash/memberListErrorRecovery.ts | 18 +- .../memberListInsideObjectLiterals.ts | 80 +- tests/cases/fourslash/memberListOfClass.ts | 28 +- .../fourslash/memberListOfEnumInModule.ts | 24 +- .../fourslash/memberListOfExportedClass.ts | 28 +- tests/cases/fourslash/memberListOfModule.ts | 36 +- .../memberListOfModuleAfterInvalidCharater.ts | 18 +- .../memberListOfModuleBeforeKeyword.ts | 46 +- .../memberListOfModuleInAnotherModule.ts | 72 +- .../fourslash/memberListOnConstructorType.ts | 14 +- .../memberListOnFunctionParameter.ts | 24 +- .../memberListOnThisInClassWithPrivates.ts | 24 +- tests/cases/fourslash/memberOverloadEdits.ts | 34 +- .../mispeltVariableForInLoopErrorRecovery.ts | 16 +- .../fourslash/moduleRenamingErrorRecovery.ts | 16 +- .../multipleExportAssignmentsErrorList0.ts | 54 +- .../fourslash/nameOfRetypedClassInModule.ts | 64 +- .../fourslash/nameOrDottedNameClasses.ts | 32 +- tests/cases/fourslash/navigateItemsConst.ts | 8 +- .../fourslash/navigationItemsExactMatch.ts | 54 +- .../fourslash/navigationItemsExactMatch2.ts | 54 +- ...navigationItemsInConstructorsExactMatch.ts | 24 +- .../fourslash/navigationItemsOverloads1.ts | 60 +- .../fourslash/navigationItemsOverloads2.ts | 24 +- .../navigationItemsOverloadsBroken1.ts | 56 +- .../navigationItemsOverloadsBroken2.ts | 44 +- .../fourslash/navigationItemsPrefixMatch.ts | 58 +- .../fourslash/navigationItemsPrefixMatch2.ts | 62 +- .../navigationItemsSubStringMatch.ts | 50 +- .../navigationItemsSubStringMatch2.ts | 70 +- ...etionListOnCommentsInsideObjectLiterals.ts | 34 +- .../fourslash/noSignatureHelpOnNewKeyword.ts | 2 +- .../noSmartIndentInsideMultilineString.ts | 20 +- .../fourslash/overloadObjectLiteralCrash.ts | 24 +- tests/cases/fourslash/parenthesisFatArrows.ts | 20 +- tests/cases/fourslash/publicBreak.ts | 14 +- ...-declaration-with-variable-entity-names.ts | 30 +- ...ntextuallyTypedArrowFunctionInSuperCall.ts | 2 +- .../quickInfoForShorthandProperty.ts | 2 +- .../quickInfoInInvalidIndexSignature.ts | 12 +- .../quickInfoOfLablledForStatementIterator.ts | 10 +- .../fourslash/quickInfoOnCatchVariable.ts | 18 +- tests/cases/fourslash/recursiveGenerics2.ts | 4 +- .../recursiveInternalModuleImport.ts | 22 +- tests/cases/fourslash/referenceToClass.ts | 70 +- .../cases/fourslash/referencesBloomFilters.ts | 38 +- .../fourslash/referencesBloomFilters2.ts | 38 +- .../fourslash/referencesBloomFilters3.ts | 30 +- .../fourslash/referencesForClassParameter.ts | 50 +- .../referencesForFunctionOverloads.ts | 32 +- .../referencesForFunctionParameter.ts | 28 +- .../referencesForGlobalsInExternalModule.ts | 46 +- .../referencesForIllegalAssignment.ts | 40 +- .../fourslash/referencesForIndexProperty.ts | 36 +- .../fourslash/referencesForIndexProperty2.ts | 16 +- .../fourslash/referencesForIndexProperty3.ts | 38 +- tests/cases/fourslash/referencesForLabel.ts | 44 +- tests/cases/fourslash/referencesForLabel2.ts | 24 +- tests/cases/fourslash/referencesForLabel3.ts | 20 +- tests/cases/fourslash/referencesForLabel4.ts | 30 +- tests/cases/fourslash/referencesForLabel5.ts | 56 +- tests/cases/fourslash/referencesForLabel6.ts | 26 +- .../referencesForMergedDeclarations.ts | 18 +- .../referencesForMergedDeclarations3.ts | 38 +- .../referencesForMergedDeclarations4.ts | 16 +- .../referencesForMergedDeclarations5.ts | 18 +- .../referencesForMergedDeclarations7.ts | 20 +- .../cases/fourslash/referencesForNoContext.ts | 68 +- .../referencesForObjectLiteralProperties.ts | 20 +- .../cases/fourslash/referencesForOverrides.ts | 168 ++-- .../referencesForPropertiesOfGenericType.ts | 12 +- tests/cases/fourslash/referencesForStatic.ts | 78 +- ...rencesForStaticsAndMembersWithSameNames.ts | 96 +-- ...eferencesForStringLiteralPropertyNames2.ts | 18 +- ...eferencesForStringLiteralPropertyNames3.ts | 16 +- ...eferencesForStringLiteralPropertyNames4.ts | 14 +- .../fourslash/referencesForUnionProperties.ts | 16 +- tests/cases/fourslash/referencesInComment.ts | 34 +- tests/cases/fourslash/regexDetection.ts | 28 +- tests/cases/fourslash/regexErrorRecovery.ts | 24 +- tests/cases/fourslash/remoteGetReferences.ts | 402 +++++----- .../removeDeclareParamTypeAnnotation.ts | 16 +- .../removeExportFromInterfaceError0.ts | 30 +- .../removeExportFromInterfaceError1.ts | 30 +- .../removeExportedClassFromReopenedModule.ts | 32 +- ...emoveInterfaceUsedAsGenericTypeArgument.ts | 16 +- ...moveParameterBetweenCommentAndParameter.ts | 12 +- .../removeVarFromModuleWithReopenedEnums.ts | 32 +- .../fourslash/renameCommentsAndStrings1.ts | 4 +- ...scriptLexicalStructureEmptyConstructors.ts | 22 +- .../scriptLexicalStructureExports.ts | 36 +- .../scriptLexicalStructureImports.ts | 50 +- .../fourslash/scriptLexicalStructureItems.ts | 104 +-- .../fourslash/scriptLexicalStructureItems2.ts | 24 +- ...uctureItemsContainsNoAnonymousFunctions.ts | 86 +-- .../scriptLexicalStructureMissingName1.ts | 2 +- .../scriptLexicalStructureMissingName2.ts | 2 +- .../scriptLexicalStructureModules.ts | 2 +- ...icalStructureMultilineStringIdentifiers.ts | 2 +- ...tructurePropertiesDefinedInConstructors.ts | 28 +- ...nticClassificationInTemplateExpressions.ts | 2 +- ...stantiatedModuleWithVariableOfSameName1.ts | 2 +- ...stantiatedModuleWithVariableOfSameName2.ts | 2 +- .../semanticClassificationModules.ts | 2 +- ...stantiatedModuleWithVariableOfSameName1.ts | 2 +- ...stantiatedModuleWithVariableOfSameName2.ts | 2 +- .../semanticClassificationWithUnionTypes.ts | 2 +- tests/cases/fourslash/server/definition.ts | 2 +- tests/cases/fourslash/server/navbar.ts | 104 +-- tests/cases/fourslash/server/navto.ts | 54 +- .../shims/getDefinitionAtPosition.ts | 58 +- tests/cases/fourslash/shims/getEmitOutput.ts | 42 +- .../shims/getIndentationAtPosition.ts | 36 +- .../fourslash/shims/getNavigateToItems.ts | 54 +- tests/cases/fourslash/shims/getRenameInfo.ts | 4 +- .../fourslash/shims/getSemanticDiagnostics.ts | 22 +- .../fourslash/signatureHelpCallExpression.ts | 32 +- .../signatureHelpConstructExpression.ts | 34 +- .../signatureHelpConstructorInheritance.ts | 44 +- .../signatureHelpConstructorOverload.ts | 30 +- .../signatureHelpFunctionOverload.ts | 34 +- .../signatureHelpFunctionParameter.ts | 24 +- .../signatureHelpImplicitConstructor.ts | 12 +- .../fourslash/signatureHelpInFunctionCall.ts | 8 +- .../fourslash/signatureHelpNegativeTests2.ts | 18 +- ...ctCreationExpressionNoArgs_NotAvailable.ts | 14 +- .../signatureHelpOnOverloadsDifferentArity.ts | 2 +- ...signatureHelpOnOverloadsDifferentArity2.ts | 2 +- ...signatureHelpOnOverloadsDifferentArity3.ts | 2 +- .../signatureHelpSimpleConstructorCall.ts | 16 +- .../signatureHelpSimpleFunctionCall.ts | 16 +- .../signatureHelpSuperConstructorOverload.ts | 54 +- .../signatureHelpWithInterfaceAsIdentifier.ts | 10 +- .../fourslash/signatureHelpWithUnknown.ts | 12 +- .../fourslash/smartIndentActualIndentation.ts | 34 +- ...smartIndentAfterAlignedFunctionArgument.ts | 20 +- tests/cases/fourslash/smartIndentClass.ts | 36 +- .../cases/fourslash/smartIndentCloseBrace.ts | 18 +- .../cases/fourslash/smartIndentDoStatement.ts | 28 +- .../cases/fourslash/smartIndentIfStatement.ts | 38 +- .../fourslash/smartIndentInCallExpressions.ts | 2 +- .../smartIndentInsideBlockInsideCase.ts | 36 +- tests/cases/fourslash/smartIndentInterface.ts | 22 +- tests/cases/fourslash/smartIndentModule.ts | 24 +- ...artIndentNonterminatedArgumentListAtEOF.ts | 14 +- ...martIndentNonterminatedIfStatementAtEOF.ts | 14 +- .../smartIndentOnFunctionParameters.ts | 62 +- .../fourslash/smartIndentStartLineInLists.ts | 6 +- .../fourslash/smartIndentStatementFor.ts | 28 +- .../fourslash/smartIndentStatementForIn.ts | 30 +- .../fourslash/smartIndentStatementSwitch.ts | 36 +- .../smartIndentStatementTryCatchFinally.ts | 84 +- .../fourslash/smartIndentStatementWith.ts | 30 +- tests/cases/fourslash/spaceAfterReturn.ts | 28 +- .../fourslash/squiggleFunctionExpression.ts | 18 +- .../squiggleIllegalClassExtension.ts | 12 +- .../squiggleIllegalInterfaceExtension.ts | 16 +- .../squiggleIllegalSubclassOverride.ts | 22 +- .../squiggleUnclosedStringLiteral.ts | 22 +- ...symbolNameAtUnparseableFunctionOverload.ts | 24 +- .../syntacticClassificationsObjectLiteral.ts | 2 +- .../syntacticClassificationsTemplates1.ts | 2 +- .../syntacticClassificationsTemplates2.ts | 2 +- .../toggleDuplicateFunctionDeclaration.ts | 24 +- ...peAboveNumberLiteralExpressionStatement.ts | 18 +- .../typeCheckAfterAddingGenericParameter.ts | 44 +- .../typeCheckObjectInArrayLiteral.ts | 14 +- .../typeParameterListInQuickInfoAfterEdit.ts | 40 +- .../fourslash/unclosedArrayErrorRecovery.ts | 10 +- .../unclosedCommentsInConstructor.ts | 14 +- .../unclosedFunctionErrorRecovery.ts | 14 +- .../unclosedFunctionErrorRecovery3.ts | 10 +- ...osedMultilineStringLiteralErrorRecovery.ts | 18 +- .../unclosedStringLiteralAutoformating.ts | 18 +- .../unclosedStringLiteralErrorRecovery2.ts | 24 +- .../unclosedStringLiteralErrorRecovery3.ts | 20 +- .../unclosedStringLiteralErrorRecovery4.ts | 16 +- tests/cases/fourslash/underscoreTyping1.ts | 4 +- .../fourslash/unknownVariableErrorRecovery.ts | 18 +- tests/cases/fourslash/whiteSpaceTrimming.ts | 16 +- 351 files changed, 8227 insertions(+), 8227 deletions(-) diff --git a/tests/cases/fourslash/addDeclareToModule.ts b/tests/cases/fourslash/addDeclareToModule.ts index 428ee468411..3be95a03eea 100644 --- a/tests/cases/fourslash/addDeclareToModule.ts +++ b/tests/cases/fourslash/addDeclareToModule.ts @@ -1,8 +1,8 @@ -/// - -//// /**/module mAmbient { -//// module m3 { } -//// } - -goTo.marker(''); -edit.insert("declare "); +/// + +//// /**/module mAmbient { +//// module m3 { } +//// } + +goTo.marker(''); +edit.insert("declare "); diff --git a/tests/cases/fourslash/addDuplicateSetter.ts b/tests/cases/fourslash/addDuplicateSetter.ts index 0f3ed110f3b..339c30d68a1 100644 --- a/tests/cases/fourslash/addDuplicateSetter.ts +++ b/tests/cases/fourslash/addDuplicateSetter.ts @@ -1,10 +1,10 @@ -/// - -//// class C { -//// set foo(value) { } -//// /**/ -//// } - -goTo.marker(); -edit.insert("set foo(value) { }"); - +/// + +//// class C { +//// set foo(value) { } +//// /**/ +//// } + +goTo.marker(); +edit.insert("set foo(value) { }"); + diff --git a/tests/cases/fourslash/addFunctionInDuplicatedConstructorClassBody.ts b/tests/cases/fourslash/addFunctionInDuplicatedConstructorClassBody.ts index adbdd4820a0..383f96b4f28 100644 --- a/tests/cases/fourslash/addFunctionInDuplicatedConstructorClassBody.ts +++ b/tests/cases/fourslash/addFunctionInDuplicatedConstructorClassBody.ts @@ -1,12 +1,12 @@ -/// - -//// class Foo { -//// constructor() { } -//// constructor() { } -//// /**/ -//// } - -goTo.marker(); -var func = 'fn() { }'; -edit.insert(func); -verify.numberOfErrorsInCurrentFile(2); +/// + +//// class Foo { +//// constructor() { } +//// constructor() { } +//// /**/ +//// } + +goTo.marker(); +var func = 'fn() { }'; +edit.insert(func); +verify.numberOfErrorsInCurrentFile(2); diff --git a/tests/cases/fourslash/addInterfaceMemberAboveClass.ts b/tests/cases/fourslash/addInterfaceMemberAboveClass.ts index 7da128c02be..0f131d0c925 100644 --- a/tests/cases/fourslash/addInterfaceMemberAboveClass.ts +++ b/tests/cases/fourslash/addInterfaceMemberAboveClass.ts @@ -1,21 +1,21 @@ -/// - -//// -//// interface Intersection { -//// /*insertHere*/ -//// } -//// interface Scene { } -//// class /*className*/Sphere { -//// constructor() { -//// } -//// } - -goTo.marker('className'); -verify.quickInfoIs('class Sphere'); - -goTo.marker('insertHere'); -edit.insert("ray: Ray;"); - -goTo.marker('className'); - +/// + +//// +//// interface Intersection { +//// /*insertHere*/ +//// } +//// interface Scene { } +//// class /*className*/Sphere { +//// constructor() { +//// } +//// } + +goTo.marker('className'); +verify.quickInfoIs('class Sphere'); + +goTo.marker('insertHere'); +edit.insert("ray: Ray;"); + +goTo.marker('className'); + verify.quickInfoIs('class Sphere'); \ No newline at end of file diff --git a/tests/cases/fourslash/addInterfaceToNotSatisfyConstraint.ts b/tests/cases/fourslash/addInterfaceToNotSatisfyConstraint.ts index bafc8cf3049..a04ba99b654 100644 --- a/tests/cases/fourslash/addInterfaceToNotSatisfyConstraint.ts +++ b/tests/cases/fourslash/addInterfaceToNotSatisfyConstraint.ts @@ -1,14 +1,14 @@ -/// - -//// interface A { -//// a: number; -//// } -//// /**/ -//// interface C { -//// x: T; -//// } -//// -//// var v2: C; // should not work - -goTo.marker(); -edit.insert("interface B { b: string; }"); +/// + +//// interface A { +//// a: number; +//// } +//// /**/ +//// interface C { +//// x: T; +//// } +//// +//// var v2: C; // should not work + +goTo.marker(); +edit.insert("interface B { b: string; }"); diff --git a/tests/cases/fourslash/addMemberToInterface.ts b/tests/cases/fourslash/addMemberToInterface.ts index cc0ecbdb361..ab0f99e4683 100644 --- a/tests/cases/fourslash/addMemberToInterface.ts +++ b/tests/cases/fourslash/addMemberToInterface.ts @@ -1,20 +1,20 @@ -/// - -//// -//// module /*check*/Mod{ -//// } -//// -//// interface MyInterface { -//// /*insert*/ -//// } - -edit.disableFormatting(); - -goTo.marker('check'); -verify.quickInfoIs('module Mod'); - -goTo.marker('insert'); -edit.insert("x: number;\n"); - -goTo.marker('check'); -verify.quickInfoIs('module Mod'); +/// + +//// +//// module /*check*/Mod{ +//// } +//// +//// interface MyInterface { +//// /*insert*/ +//// } + +edit.disableFormatting(); + +goTo.marker('check'); +verify.quickInfoIs('module Mod'); + +goTo.marker('insert'); +edit.insert("x: number;\n"); + +goTo.marker('check'); +verify.quickInfoIs('module Mod'); diff --git a/tests/cases/fourslash/addMethodToInterface1.ts b/tests/cases/fourslash/addMethodToInterface1.ts index 07cd4700583..0bedbe634fb 100644 --- a/tests/cases/fourslash/addMethodToInterface1.ts +++ b/tests/cases/fourslash/addMethodToInterface1.ts @@ -1,14 +1,14 @@ -/// - -//// interface Comparable { -//// /*1*/} -//// interface Comparer { -//// } -//// var max2: Comparer = (x, y) => { return (x.compareTo(y) > 0) ? x : y }; -//// var maxResult = max2(1); - -edit.disableFormatting(); - -goTo.marker('1'); - -edit.insert(" compareTo(): number;\n"); +/// + +//// interface Comparable { +//// /*1*/} +//// interface Comparer { +//// } +//// var max2: Comparer = (x, y) => { return (x.compareTo(y) > 0) ? x : y }; +//// var maxResult = max2(1); + +edit.disableFormatting(); + +goTo.marker('1'); + +edit.insert(" compareTo(): number;\n"); diff --git a/tests/cases/fourslash/addVarToConstructor1.ts b/tests/cases/fourslash/addVarToConstructor1.ts index 986de53f009..31eedf88be5 100644 --- a/tests/cases/fourslash/addVarToConstructor1.ts +++ b/tests/cases/fourslash/addVarToConstructor1.ts @@ -1,24 +1,24 @@ -/// - -//// -//// //_modes. // produces an internal error - please implement in derived class -//// -//// module editor { -//// import modes = _modes; -//// -//// var i : modes.IMode; -//// -//// // If you just use p1:modes, the compiler accepts it - should be an error -//// class Bg { -//// constructor(p1: modes, p2: modes.Mode) {// should be an error on p2 - it's not exported -//// /*1*/} -//// -//// } -//// } -//// - -edit.disableFormatting(); - -goTo.marker('1'); - -edit.insert(" var x:modes.Mode;\n"); +/// + +//// +//// //_modes. // produces an internal error - please implement in derived class +//// +//// module editor { +//// import modes = _modes; +//// +//// var i : modes.IMode; +//// +//// // If you just use p1:modes, the compiler accepts it - should be an error +//// class Bg { +//// constructor(p1: modes, p2: modes.Mode) {// should be an error on p2 - it's not exported +//// /*1*/} +//// +//// } +//// } +//// + +edit.disableFormatting(); + +goTo.marker('1'); + +edit.insert(" var x:modes.Mode;\n"); diff --git a/tests/cases/fourslash/alignmentAfterFormattingOnMultilineExpressionAndParametersList.ts b/tests/cases/fourslash/alignmentAfterFormattingOnMultilineExpressionAndParametersList.ts index 0b50612d454..c202aa00a53 100644 --- a/tests/cases/fourslash/alignmentAfterFormattingOnMultilineExpressionAndParametersList.ts +++ b/tests/cases/fourslash/alignmentAfterFormattingOnMultilineExpressionAndParametersList.ts @@ -1,25 +1,25 @@ -/// - -////class TestClass { -//// private testMethod1(param1: boolean, -//// param2/*1*/: boolean) { -//// } -//// -//// public testMethod2(a: number, b: number, c: number) { -//// if (a === b) { -//// } -//// else if (a != c && -//// a/*2*/ > b && -//// b/*3*/ < c) { -//// } -//// -//// } -////} - -format.document(); -goTo.marker("1"); -verify.indentationIs(8); -goTo.marker("2"); -verify.indentationIs(12); -goTo.marker("3"); -verify.indentationIs(12); +/// + +////class TestClass { +//// private testMethod1(param1: boolean, +//// param2/*1*/: boolean) { +//// } +//// +//// public testMethod2(a: number, b: number, c: number) { +//// if (a === b) { +//// } +//// else if (a != c && +//// a/*2*/ > b && +//// b/*3*/ < c) { +//// } +//// +//// } +////} + +format.document(); +goTo.marker("1"); +verify.indentationIs(8); +goTo.marker("2"); +verify.indentationIs(12); +goTo.marker("3"); +verify.indentationIs(12); diff --git a/tests/cases/fourslash/argumentsAreAvailableAfterEditsAtEndOfFunction.ts b/tests/cases/fourslash/argumentsAreAvailableAfterEditsAtEndOfFunction.ts index e3ab1388514..8a1efef397e 100644 --- a/tests/cases/fourslash/argumentsAreAvailableAfterEditsAtEndOfFunction.ts +++ b/tests/cases/fourslash/argumentsAreAvailableAfterEditsAtEndOfFunction.ts @@ -1,15 +1,15 @@ -/// - -////module Test1 { -//// class Person { -//// children: string[]; -//// constructor(public name: string, children: string[]) { -//// /**/ -//// } -//// } -////} - -goTo.marker(); -var text = "this.children = ch"; -edit.insert(text); +/// + +////module Test1 { +//// class Person { +//// children: string[]; +//// constructor(public name: string, children: string[]) { +//// /**/ +//// } +//// } +////} + +goTo.marker(); +var text = "this.children = ch"; +edit.insert(text); verify.completionListContains("children", "(parameter) children: string[]"); \ No newline at end of file diff --git a/tests/cases/fourslash/argumentsIndexExpression.ts b/tests/cases/fourslash/argumentsIndexExpression.ts index 6f54a766764..bda0c23e488 100644 --- a/tests/cases/fourslash/argumentsIndexExpression.ts +++ b/tests/cases/fourslash/argumentsIndexExpression.ts @@ -1,8 +1,8 @@ -/// - -//// function f() { -//// var x = /**/arguments[0]; -//// } - -goTo.marker(); -verify.quickInfoExists(); +/// + +//// function f() { +//// var x = /**/arguments[0]; +//// } + +goTo.marker(); +verify.quickInfoExists(); diff --git a/tests/cases/fourslash/arrayConcatTypeCheck0.ts b/tests/cases/fourslash/arrayConcatTypeCheck0.ts index 9250eb5b6fd..7361f3c9e84 100644 --- a/tests/cases/fourslash/arrayConcatTypeCheck0.ts +++ b/tests/cases/fourslash/arrayConcatTypeCheck0.ts @@ -1,16 +1,16 @@ -/// - -//// var a = []; -//// a.concat("hello"/*1*/); -//// -//// a.concat('Hello'); -//// -//// var b = new Array(); -//// b.concat('hello'); -//// - -edit.disableFormatting(); - -goTo.marker('1'); - -edit.insert(", 'world'"); +/// + +//// var a = []; +//// a.concat("hello"/*1*/); +//// +//// a.concat('Hello'); +//// +//// var b = new Array(); +//// b.concat('hello'); +//// + +edit.disableFormatting(); + +goTo.marker('1'); + +edit.insert(", 'world'"); diff --git a/tests/cases/fourslash/arrayConcatTypeCheck1.ts b/tests/cases/fourslash/arrayConcatTypeCheck1.ts index c62bd5b7f14..9d7de1704ab 100644 --- a/tests/cases/fourslash/arrayConcatTypeCheck1.ts +++ b/tests/cases/fourslash/arrayConcatTypeCheck1.ts @@ -1,26 +1,26 @@ -/// - -//// a.concat(/*2*/"hello"/*1*/, 'world'); -//// -//// a.concat(/*3*/'Hello'); -//// -//// var b = new Array/*4*/<>(); -//// b.concat('hello'); -//// - -edit.disableFormatting(); - -goTo.marker('1'); - -edit.deleteAtCaret(9); - -goTo.marker('3'); - -edit.deleteAtCaret(7); - -goTo.marker('2'); - -edit.deleteAtCaret(7); - -goTo.marker('4'); - +/// + +//// a.concat(/*2*/"hello"/*1*/, 'world'); +//// +//// a.concat(/*3*/'Hello'); +//// +//// var b = new Array/*4*/<>(); +//// b.concat('hello'); +//// + +edit.disableFormatting(); + +goTo.marker('1'); + +edit.deleteAtCaret(9); + +goTo.marker('3'); + +edit.deleteAtCaret(7); + +goTo.marker('2'); + +edit.deleteAtCaret(7); + +goTo.marker('4'); + diff --git a/tests/cases/fourslash/autoFormattingOnPasting.ts b/tests/cases/fourslash/autoFormattingOnPasting.ts index cee2be4bec8..0c7f471d43d 100644 --- a/tests/cases/fourslash/autoFormattingOnPasting.ts +++ b/tests/cases/fourslash/autoFormattingOnPasting.ts @@ -1,28 +1,28 @@ -/// - -////module TestModule { -/////**/ -////} -goTo.marker(""); -edit.paste(" class TestClass{\r\n\ -private foo;\r\n\ -public testMethod( )\r\n\ -{}\r\n\ -}"); -// We're missing scenarios of formatting option settings due to bug 693273 - [TypeScript] Need to improve fourslash support for formatting options. -// Missing scenario ** Uncheck Tools->Options->Text Editor->TypeScript->Formatting->General->Format on paste ** -//verify.currentFileContentIs("module TestModule {\r\n\ -// class TestClass{\r\n\ -//private foo;\r\n\ -//public testMethod( )\r\n\ -//{}\r\n\ -//}\r\n\ -//}"); -// Missing scenario ** Check Tools->Options->Text Editor->TypeScript->Formatting->General->Format on paste ** -verify.currentFileContentIs("module TestModule {\r\n\ - class TestClass {\r\n\ - private foo;\r\n\ - public testMethod()\r\n\ - { }\r\n\ - }\r\n\ +/// + +////module TestModule { +/////**/ +////} +goTo.marker(""); +edit.paste(" class TestClass{\r\n\ +private foo;\r\n\ +public testMethod( )\r\n\ +{}\r\n\ +}"); +// We're missing scenarios of formatting option settings due to bug 693273 - [TypeScript] Need to improve fourslash support for formatting options. +// Missing scenario ** Uncheck Tools->Options->Text Editor->TypeScript->Formatting->General->Format on paste ** +//verify.currentFileContentIs("module TestModule {\r\n\ +// class TestClass{\r\n\ +//private foo;\r\n\ +//public testMethod( )\r\n\ +//{}\r\n\ +//}\r\n\ +//}"); +// Missing scenario ** Check Tools->Options->Text Editor->TypeScript->Formatting->General->Format on paste ** +verify.currentFileContentIs("module TestModule {\r\n\ + class TestClass {\r\n\ + private foo;\r\n\ + public testMethod()\r\n\ + { }\r\n\ + }\r\n\ }"); \ No newline at end of file diff --git a/tests/cases/fourslash/breakpointValidationClass.ts b/tests/cases/fourslash/breakpointValidationClass.ts index 99209c465b2..112c89dbb7c 100644 --- a/tests/cases/fourslash/breakpointValidationClass.ts +++ b/tests/cases/fourslash/breakpointValidationClass.ts @@ -19,7 +19,7 @@ //// set greetings(greetings: string) { //// this.greeting = greetings; //// } -////} +////} ////class Greeter2 { ////} ////class Greeter1 @@ -45,9 +45,9 @@ //// { //// this.greeting = greetings; //// } -////} +////} ////class Greeter12 ////{ ////} - + verify.baselineCurrentFileBreakpointLocations(); \ No newline at end of file diff --git a/tests/cases/fourslash/breakpointValidationClassAmbient.ts b/tests/cases/fourslash/breakpointValidationClassAmbient.ts index ab0b78003ac..4e6d0bb0afe 100644 --- a/tests/cases/fourslash/breakpointValidationClassAmbient.ts +++ b/tests/cases/fourslash/breakpointValidationClassAmbient.ts @@ -9,6 +9,6 @@ //// private val; //// static x: number; //// static fn(a: number, ...b:string[]); -////} +////} verify.baselineCurrentFileBreakpointLocations(); \ No newline at end of file diff --git a/tests/cases/fourslash/breakpointValidationClasses.ts b/tests/cases/fourslash/breakpointValidationClasses.ts index 286001cfee6..8ffe62e30e7 100644 --- a/tests/cases/fourslash/breakpointValidationClasses.ts +++ b/tests/cases/fourslash/breakpointValidationClasses.ts @@ -3,37 +3,37 @@ // @BaselineFile: bpSpan_classes.baseline // @Filename: bpSpan_classes.ts ////module Foo.Bar { -//// "use strict"; -//// +//// "use strict"; +//// //// class Greeter { //// constructor(public greeting: string) { //// } -//// +//// //// greet() { //// return "

" + this.greeting + "

"; //// } -//// } -//// -//// +//// } +//// +//// //// function foo(greeting: string): Greeter { //// return new Greeter(greeting); -//// } -//// -//// var greeter = new Greeter("Hello, world!"); -//// var str = greeter.greet(); -//// +//// } +//// +//// var greeter = new Greeter("Hello, world!"); +//// var str = greeter.greet(); +//// //// function foo2(greeting: string, ...restGreetings /* more greeting */: string[]) { //// var greeters: Greeter[] = []; /* inline block comment */ //// greeters[0] = new Greeter(greeting); //// for (var i = 0; i < restGreetings.length; i++) { //// greeters.push(new Greeter(restGreetings[i])); //// } -//// +//// //// return greeters; -//// } -//// -//// var b = foo2("Hello", "World", "!"); -//// // This is simple signle line comment +//// } +//// +//// var b = foo2("Hello", "World", "!"); +//// // This is simple signle line comment //// for (var j = 0; j < b.length; j++) { //// b[j].greet(); //// } diff --git a/tests/cases/fourslash/brokenClassErrorRecovery.ts b/tests/cases/fourslash/brokenClassErrorRecovery.ts index f5badafaef2..7dafaafeb06 100644 --- a/tests/cases/fourslash/brokenClassErrorRecovery.ts +++ b/tests/cases/fourslash/brokenClassErrorRecovery.ts @@ -1,10 +1,10 @@ -/// - -////class Foo { -//// constructor() { var x = [1, 2, 3 } -////} -/////**/ -////var bar = new Foo(); - -verify.not.errorExistsAfterMarker(); - +/// + +////class Foo { +//// constructor() { var x = [1, 2, 3 } +////} +/////**/ +////var bar = new Foo(); + +verify.not.errorExistsAfterMarker(); + diff --git a/tests/cases/fourslash/classExtendsInterfaceSigHelp1.ts b/tests/cases/fourslash/classExtendsInterfaceSigHelp1.ts index ebdccef485f..c2b4d5e70a0 100644 --- a/tests/cases/fourslash/classExtendsInterfaceSigHelp1.ts +++ b/tests/cases/fourslash/classExtendsInterfaceSigHelp1.ts @@ -11,8 +11,8 @@ ////} ////var i: I; -////i.foo(/**/ - -goTo.marker(); -verify.signatureHelpCountIs(2); +////i.foo(/**/ + +goTo.marker(); +verify.signatureHelpCountIs(2); verify.currentParameterSpanIs('x: string'); \ No newline at end of file diff --git a/tests/cases/fourslash/classRenamingErrorRecovery.ts b/tests/cases/fourslash/classRenamingErrorRecovery.ts index eabc9c748a6..c95d112cdc5 100644 --- a/tests/cases/fourslash/classRenamingErrorRecovery.ts +++ b/tests/cases/fourslash/classRenamingErrorRecovery.ts @@ -1,9 +1,9 @@ -/// - -////class Foo/*1*//*2*/ { public Bar() { } } - -goTo.marker("1"); -edit.backspace(3); -edit.insert("Pizza"); -verify.currentLineContentIs("class Pizza { public Bar() { } }"); +/// + +////class Foo/*1*//*2*/ { public Bar() { } } + +goTo.marker("1"); +edit.backspace(3); +edit.insert("Pizza"); +verify.currentLineContentIs("class Pizza { public Bar() { } }"); verify.not.errorExistsAfterMarker("2"); \ No newline at end of file diff --git a/tests/cases/fourslash/closedCommentsInConstructor.ts b/tests/cases/fourslash/closedCommentsInConstructor.ts index 6ab5c4b9811..8a168a58354 100644 --- a/tests/cases/fourslash/closedCommentsInConstructor.ts +++ b/tests/cases/fourslash/closedCommentsInConstructor.ts @@ -1,8 +1,8 @@ -/// - -////class Foo { -//// constructor(/* /**/ */) { } -////} - -goTo.marker(); +/// + +////class Foo { +//// constructor(/* /**/ */) { } +////} + +goTo.marker(); verify.completionListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListAfterClassExtends.ts b/tests/cases/fourslash/completionListAfterClassExtends.ts index 37eb476eff1..15a3e261768 100644 --- a/tests/cases/fourslash/completionListAfterClassExtends.ts +++ b/tests/cases/fourslash/completionListAfterClassExtends.ts @@ -1,16 +1,16 @@ -/// - -////module Bar { -//// export class Bleah { -//// } -//// export class Foo extends /**/Bleah { -//// } -////} -//// -////function Blah(x: Bar.Bleah) { -////} - -goTo.marker(); -verify.completionListContains("Bar"); -verify.completionListContains("Bleah"); +/// + +////module Bar { +//// export class Bleah { +//// } +//// export class Foo extends /**/Bleah { +//// } +////} +//// +////function Blah(x: Bar.Bleah) { +////} + +goTo.marker(); +verify.completionListContains("Bar"); +verify.completionListContains("Bleah"); verify.completionListContains("Foo"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts b/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts index 6c2288afb68..c3ee033bf54 100644 --- a/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts +++ b/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts @@ -1,18 +1,18 @@ -/// - -////module M { -//// export class C { public pub = 0; private priv = 1; } -//// export var V = 0; -////} -//// -//// -////var c = new M.C(); -//// -////c. // test on c. -//// -//////Test for comment -//////c./**/ - -goTo.marker(); -verify.completionListIsEmpty(); +/// + +////module M { +//// export class C { public pub = 0; private priv = 1; } +//// export var V = 0; +////} +//// +//// +////var c = new M.C(); +//// +////c. // test on c. +//// +//////Test for comment +//////c./**/ + +goTo.marker(); +verify.completionListIsEmpty(); verify.memberListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListAndMemberListOnCommentedLine.ts b/tests/cases/fourslash/completionListAndMemberListOnCommentedLine.ts index 500f0bc8585..96eac09b6ff 100644 --- a/tests/cases/fourslash/completionListAndMemberListOnCommentedLine.ts +++ b/tests/cases/fourslash/completionListAndMemberListOnCommentedLine.ts @@ -1,7 +1,7 @@ -/// - -////// /**/ -////var - -goTo.marker(); +/// + +////// /**/ +////var + +goTo.marker(); verify.completionListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListAndMemberListOnCommentedWhiteSpace.ts b/tests/cases/fourslash/completionListAndMemberListOnCommentedWhiteSpace.ts index 2e30851ea1f..f0287a0baea 100644 --- a/tests/cases/fourslash/completionListAndMemberListOnCommentedWhiteSpace.ts +++ b/tests/cases/fourslash/completionListAndMemberListOnCommentedWhiteSpace.ts @@ -1,18 +1,18 @@ -/// - -////module M { -//// export class C { public pub = 0; private priv = 1; } -//// export var V = 0; -////} -//// -//// -////var c = new M.C(); -//// -////c. // test on c. -//// -//////Test for comment -//////c. /**/ - -goTo.marker(); -verify.completionListIsEmpty(); +/// + +////module M { +//// export class C { public pub = 0; private priv = 1; } +//// export var V = 0; +////} +//// +//// +////var c = new M.C(); +//// +////c. // test on c. +//// +//////Test for comment +//////c. /**/ + +goTo.marker(); +verify.completionListIsEmpty(); verify.memberListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListAtDeclarationOfParameterType.ts b/tests/cases/fourslash/completionListAtDeclarationOfParameterType.ts index fcc40d8ee5d..94de51cc9a3 100644 --- a/tests/cases/fourslash/completionListAtDeclarationOfParameterType.ts +++ b/tests/cases/fourslash/completionListAtDeclarationOfParameterType.ts @@ -1,14 +1,14 @@ -/// - -////module Bar { -//// export class Bleah { -//// } -//// export class Foo extends Bleah { -//// } -////} -//// -////function Blah(x: /**/Bar.Bleah) { -////} - -goTo.marker(); +/// + +////module Bar { +//// export class Bleah { +//// } +//// export class Foo extends Bleah { +//// } +////} +//// +////function Blah(x: /**/Bar.Bleah) { +////} + +goTo.marker(); verify.completionListContains("Bar"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts index 143c884e177..0812cb138d2 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts @@ -1,22 +1,22 @@ -/// - -//// var [x/*variable1*/ - -//// var [x, y/*variable2*/ - -//// var [./*variable3*/ - -//// var [x, ...z/*variable4*/ - -//// var {x/*variable5*/ - -//// var {x, y/*variable6*/ - -//// function func1({ a/*parameter1*/ - -//// function func2({ a, b/*parameter2*/ - -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListIsEmpty(); -}); +/// + +//// var [x/*variable1*/ + +//// var [x, y/*variable2*/ + +//// var [./*variable3*/ + +//// var [x, ...z/*variable4*/ + +//// var {x/*variable5*/ + +//// var {x, y/*variable6*/ + +//// function func1({ a/*parameter1*/ + +//// function func2({ a, b/*parameter2*/ + +test.markers().forEach((m) => { + goTo.position(m.position, m.fileName); + verify.completionListIsEmpty(); +}); diff --git a/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts b/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts index 45f16090fd8..d069b9a722e 100644 --- a/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts +++ b/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts @@ -1,34 +1,34 @@ -/// - -////var x = a/*var1*/ - -////var x = (b/*var2*/ - -////var x = (c, d/*var3*/ - -//// var y : any = "", x = a/*var4*/ - -//// var y : any = "", x = (a/*var5*/ - -////class C{} -////var y = new C( - -//// class C{} -//// var y = new C(0, /*var7*/ - -////var y = [/*var8*/ - -////var y = [0, /*var9*/ - -////var y = `${/*var10*/ - -////var y = `${10} dd ${ /*var11*/ - -////var y = 10; y=/*var12*/ - -test.markers().forEach((m) => { - goTo.position(m.position, m.fileName); - verify.completionListAllowsNewIdentifier(); -}); - - +/// + +////var x = a/*var1*/ + +////var x = (b/*var2*/ + +////var x = (c, d/*var3*/ + +//// var y : any = "", x = a/*var4*/ + +//// var y : any = "", x = (a/*var5*/ + +////class C{} +////var y = new C( + +//// class C{} +//// var y = new C(0, /*var7*/ + +////var y = [/*var8*/ + +////var y = [0, /*var9*/ + +////var y = `${/*var10*/ + +////var y = `${10} dd ${ /*var11*/ + +////var y = 10; y=/*var12*/ + +test.markers().forEach((m) => { + goTo.position(m.position, m.fileName); + verify.completionListAllowsNewIdentifier(); +}); + + diff --git a/tests/cases/fourslash/completionListCladule.ts b/tests/cases/fourslash/completionListCladule.ts index 372e5efa219..79c2e8aea6d 100644 --- a/tests/cases/fourslash/completionListCladule.ts +++ b/tests/cases/fourslash/completionListCladule.ts @@ -1,4 +1,4 @@ -/// +/// ////class Foo { //// doStuff(): number { return 0; } diff --git a/tests/cases/fourslash/completionListErrorRecovery.ts b/tests/cases/fourslash/completionListErrorRecovery.ts index b71212061cf..7a7b9f81ca1 100644 --- a/tests/cases/fourslash/completionListErrorRecovery.ts +++ b/tests/cases/fourslash/completionListErrorRecovery.ts @@ -1,13 +1,13 @@ -/// - -////class Foo { static fun() { }; } - -////Foo./**/; -/////*1*/var bar; - +/// + +////class Foo { static fun() { }; } + +////Foo./**/; +/////*1*/var bar; + // this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - -goTo.marker(); -verify.memberListContains("fun"); +edit.insert(''); + +goTo.marker(); +verify.memberListContains("fun"); verify.not.errorExistsAfterMarker("1"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListErrorRecovery2.ts b/tests/cases/fourslash/completionListErrorRecovery2.ts index d2411dfd90c..8a368ba4466 100644 --- a/tests/cases/fourslash/completionListErrorRecovery2.ts +++ b/tests/cases/fourslash/completionListErrorRecovery2.ts @@ -1,12 +1,12 @@ -/// - -////class Foo { static bar() { return "x"; } } -////var baz = Foo/**/; -/////*1*/baz.concat("y"); - +/// + +////class Foo { static bar() { return "x"; } } +////var baz = Foo/**/; +/////*1*/baz.concat("y"); + // this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - -goTo.marker(); -edit.insert(".b"); -verify.not.errorExistsAfterMarker("1"); +edit.insert(''); + +goTo.marker(); +edit.insert(".b"); +verify.not.errorExistsAfterMarker("1"); diff --git a/tests/cases/fourslash/completionListFunctionMembers.ts b/tests/cases/fourslash/completionListFunctionMembers.ts index 6f4e2bf6069..c24dff1bee2 100644 --- a/tests/cases/fourslash/completionListFunctionMembers.ts +++ b/tests/cases/fourslash/completionListFunctionMembers.ts @@ -1,11 +1,11 @@ -/// - -////function fnc1() { -//// var bar = 1; -//// function foob(){ } -////} -//// -////fnc1./**/ - -goTo.marker(); +/// + +////function fnc1() { +//// var bar = 1; +//// function foob(){ } +////} +//// +////fnc1./**/ + +goTo.marker(); verify.memberListContains('arguments', '(property) Function.arguments: any'); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInstanceProtectedMembers.ts b/tests/cases/fourslash/completionListInstanceProtectedMembers.ts index de09f059680..996bef7077b 100644 --- a/tests/cases/fourslash/completionListInstanceProtectedMembers.ts +++ b/tests/cases/fourslash/completionListInstanceProtectedMembers.ts @@ -1,63 +1,63 @@ -/// - -////class Base { -//// private privateMethod() { } -//// private privateProperty; -//// -//// protected protectedMethod() { } -//// protected protectedProperty; -//// -//// public publicMethod() { } -//// public publicProperty; -//// -//// protected protectedOverriddenMethod() { } -//// protected protectedOverriddenProperty; -//// -//// test() { -//// this./*1*/; -//// -//// var b: Base; -//// var c: C1; -//// -//// b./*2*/; -//// c./*3*/; -//// } -////} -//// -////class C1 extends Base { -//// protected protectedOverriddenMethod() { } -//// protected protectedOverriddenProperty; -////} - - -// Same class, everything is visible -goTo.marker("1"); -verify.memberListContains('privateMethod'); -verify.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); -verify.memberListContains('protectedOverriddenProperty'); - -goTo.marker("2"); -verify.memberListContains('privateMethod'); -verify.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); -verify.memberListContains('protectedOverriddenProperty'); - -// Can not access protected properties overridden in subclass -goTo.marker("3"); -verify.memberListContains('privateMethod'); -verify.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.not.memberListContains('protectedOverriddenMethod'); +/// + +////class Base { +//// private privateMethod() { } +//// private privateProperty; +//// +//// protected protectedMethod() { } +//// protected protectedProperty; +//// +//// public publicMethod() { } +//// public publicProperty; +//// +//// protected protectedOverriddenMethod() { } +//// protected protectedOverriddenProperty; +//// +//// test() { +//// this./*1*/; +//// +//// var b: Base; +//// var c: C1; +//// +//// b./*2*/; +//// c./*3*/; +//// } +////} +//// +////class C1 extends Base { +//// protected protectedOverriddenMethod() { } +//// protected protectedOverriddenProperty; +////} + + +// Same class, everything is visible +goTo.marker("1"); +verify.memberListContains('privateMethod'); +verify.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); +verify.memberListContains('protectedOverriddenProperty'); + +goTo.marker("2"); +verify.memberListContains('privateMethod'); +verify.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); +verify.memberListContains('protectedOverriddenProperty'); + +// Can not access protected properties overridden in subclass +goTo.marker("3"); +verify.memberListContains('privateMethod'); +verify.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.not.memberListContains('protectedOverriddenMethod'); verify.not.memberListContains('protectedOverriddenProperty'); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInstanceProtectedMembers2.ts b/tests/cases/fourslash/completionListInstanceProtectedMembers2.ts index 72b6f3a1f7b..c074bc06314 100644 --- a/tests/cases/fourslash/completionListInstanceProtectedMembers2.ts +++ b/tests/cases/fourslash/completionListInstanceProtectedMembers2.ts @@ -1,76 +1,76 @@ -/// - -////class Base { -//// private privateMethod() { } -//// private privateProperty; -//// -//// protected protectedMethod() { } -//// protected protectedProperty; -//// -//// public publicMethod() { } -//// public publicProperty; -//// -//// protected protectedOverriddenMethod() { } -//// protected protectedOverriddenProperty; -////} -//// -////class C1 extends Base { -//// protected protectedOverriddenMethod() { } -//// protected protectedOverriddenProperty; -//// -//// test() { -//// this./*1*/; -//// super./*2*/; -//// -//// var b: Base; -//// var c: C1; -//// -//// b./*3*/; -//// c./*4*/; -//// } -////} - - -// Same class, everything is visible -goTo.marker("1"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); -verify.memberListContains('protectedOverriddenProperty'); - -// Can not access properties on super -goTo.marker("2"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.not.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.not.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); -verify.not.memberListContains('protectedOverriddenProperty'); - -// Can not access protected properties through base class -goTo.marker("3"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.not.memberListContains('protectedMethod'); -verify.not.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.not.memberListContains('protectedOverriddenMethod'); -verify.not.memberListContains('protectedOverriddenProperty'); - -// Same class, everything is visible -goTo.marker("4"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); -verify.memberListContains('protectedOverriddenProperty'); +/// + +////class Base { +//// private privateMethod() { } +//// private privateProperty; +//// +//// protected protectedMethod() { } +//// protected protectedProperty; +//// +//// public publicMethod() { } +//// public publicProperty; +//// +//// protected protectedOverriddenMethod() { } +//// protected protectedOverriddenProperty; +////} +//// +////class C1 extends Base { +//// protected protectedOverriddenMethod() { } +//// protected protectedOverriddenProperty; +//// +//// test() { +//// this./*1*/; +//// super./*2*/; +//// +//// var b: Base; +//// var c: C1; +//// +//// b./*3*/; +//// c./*4*/; +//// } +////} + + +// Same class, everything is visible +goTo.marker("1"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); +verify.memberListContains('protectedOverriddenProperty'); + +// Can not access properties on super +goTo.marker("2"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.not.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.not.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); +verify.not.memberListContains('protectedOverriddenProperty'); + +// Can not access protected properties through base class +goTo.marker("3"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.not.memberListContains('protectedMethod'); +verify.not.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.not.memberListContains('protectedOverriddenMethod'); +verify.not.memberListContains('protectedOverriddenProperty'); + +// Same class, everything is visible +goTo.marker("4"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); +verify.memberListContains('protectedOverriddenProperty'); diff --git a/tests/cases/fourslash/completionListInstanceProtectedMembers3.ts b/tests/cases/fourslash/completionListInstanceProtectedMembers3.ts index 2b3bf2ac2d9..c2956da8a40 100644 --- a/tests/cases/fourslash/completionListInstanceProtectedMembers3.ts +++ b/tests/cases/fourslash/completionListInstanceProtectedMembers3.ts @@ -1,46 +1,46 @@ -/// - -////class Base { -//// private privateMethod() { } -//// private privateProperty; -//// -//// protected protectedMethod() { } -//// protected protectedProperty; -//// -//// public publicMethod() { } -//// public publicProperty; -//// -//// protected protectedOverriddenMethod() { } -//// protected protectedOverriddenProperty; -////} -//// -////class C1 extends Base { -//// protected protectedOverriddenMethod() { } -//// protected protectedOverriddenProperty; -////} -//// -//// var b: Base; -//// var c: C1; -//// b./*1*/; -//// c./*2*/; - -// Only public properties are visible outside the class -goTo.marker("1"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.not.memberListContains('protectedMethod'); -verify.not.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.not.memberListContains('protectedOverriddenMethod'); -verify.not.memberListContains('protectedOverriddenProperty'); - -goTo.marker("2"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.not.memberListContains('protectedMethod'); -verify.not.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.not.memberListContains('protectedOverriddenMethod'); -verify.not.memberListContains('protectedOverriddenProperty'); +/// + +////class Base { +//// private privateMethod() { } +//// private privateProperty; +//// +//// protected protectedMethod() { } +//// protected protectedProperty; +//// +//// public publicMethod() { } +//// public publicProperty; +//// +//// protected protectedOverriddenMethod() { } +//// protected protectedOverriddenProperty; +////} +//// +////class C1 extends Base { +//// protected protectedOverriddenMethod() { } +//// protected protectedOverriddenProperty; +////} +//// +//// var b: Base; +//// var c: C1; +//// b./*1*/; +//// c./*2*/; + +// Only public properties are visible outside the class +goTo.marker("1"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.not.memberListContains('protectedMethod'); +verify.not.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.not.memberListContains('protectedOverriddenMethod'); +verify.not.memberListContains('protectedOverriddenProperty'); + +goTo.marker("2"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.not.memberListContains('protectedMethod'); +verify.not.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.not.memberListContains('protectedOverriddenMethod'); +verify.not.memberListContains('protectedOverriddenProperty'); diff --git a/tests/cases/fourslash/completionListInstanceProtectedMembers4.ts b/tests/cases/fourslash/completionListInstanceProtectedMembers4.ts index 27f9bb5a1cf..82593391fa1 100644 --- a/tests/cases/fourslash/completionListInstanceProtectedMembers4.ts +++ b/tests/cases/fourslash/completionListInstanceProtectedMembers4.ts @@ -1,34 +1,34 @@ -/// - -////class Base { -//// private privateMethod() { } -//// private privateProperty; -//// -//// protected protectedMethod() { } -//// protected protectedProperty; -//// -//// public publicMethod() { } -//// public publicProperty; -//// -//// protected protectedOverriddenMethod() { } -//// protected protectedOverriddenProperty; -////} -//// -////class C1 extends Base { -//// public protectedOverriddenMethod() { } -//// public protectedOverriddenProperty; -////} -//// -//// var c: C1; -//// c./*1*/ - - -goTo.marker("1"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.not.memberListContains('protectedMethod'); -verify.not.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); -verify.memberListContains('protectedOverriddenProperty'); +/// + +////class Base { +//// private privateMethod() { } +//// private privateProperty; +//// +//// protected protectedMethod() { } +//// protected protectedProperty; +//// +//// public publicMethod() { } +//// public publicProperty; +//// +//// protected protectedOverriddenMethod() { } +//// protected protectedOverriddenProperty; +////} +//// +////class C1 extends Base { +//// public protectedOverriddenMethod() { } +//// public protectedOverriddenProperty; +////} +//// +//// var c: C1; +//// c./*1*/ + + +goTo.marker("1"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.not.memberListContains('protectedMethod'); +verify.not.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); +verify.memberListContains('protectedOverriddenProperty'); diff --git a/tests/cases/fourslash/completionListInvalidMemberNames2.ts b/tests/cases/fourslash/completionListInvalidMemberNames2.ts index cd8ff00df4a..b261f718480 100644 --- a/tests/cases/fourslash/completionListInvalidMemberNames2.ts +++ b/tests/cases/fourslash/completionListInvalidMemberNames2.ts @@ -1,4 +1,4 @@ -/// +/// ////enum Foo { //// X, Y, '☆' diff --git a/tests/cases/fourslash/completionListObjectMembers.ts b/tests/cases/fourslash/completionListObjectMembers.ts index cbddba61be5..5d66b31fa5d 100644 --- a/tests/cases/fourslash/completionListObjectMembers.ts +++ b/tests/cases/fourslash/completionListObjectMembers.ts @@ -7,8 +7,8 @@ //// bar: any; //// foo(bar: any): any; //// }; -////object./**/ - -goTo.marker(); -verify.memberListContains("bar", '(property) bar: any'); -verify.memberListContains("foo", '(method) foo(bar: any): any'); +////object./**/ + +goTo.marker(); +verify.memberListContains("bar", '(property) bar: any'); +verify.memberListContains("foo", '(method) foo(bar: any): any'); diff --git a/tests/cases/fourslash/completionListOnPrivateVariableInModule.ts b/tests/cases/fourslash/completionListOnPrivateVariableInModule.ts index 8eeee08767b..eecb5724d10 100644 --- a/tests/cases/fourslash/completionListOnPrivateVariableInModule.ts +++ b/tests/cases/fourslash/completionListOnPrivateVariableInModule.ts @@ -1,6 +1,6 @@ -/// - -//// module Foo { var testing = ""; test/**/ } - -goTo.marker(); +/// + +//// module Foo { var testing = ""; test/**/ } + +goTo.marker(); verify.completionListContains('testing', '(var) testing: string'); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListStaticProtectedMembers.ts b/tests/cases/fourslash/completionListStaticProtectedMembers.ts index af56f28ef06..d72859570aa 100644 --- a/tests/cases/fourslash/completionListStaticProtectedMembers.ts +++ b/tests/cases/fourslash/completionListStaticProtectedMembers.ts @@ -1,59 +1,59 @@ -/// - -////class Base { -//// private static privateMethod() { } -//// private static privateProperty; -//// -//// protected static protectedMethod() { } -//// protected static protectedProperty; -//// -//// public static publicMethod() { } -//// public static publicProperty; -//// -//// protected static protectedOverriddenMethod() { } -//// protected static protectedOverriddenProperty; -//// -//// static test() { -//// Base./*1*/; -//// this./*2*/; -//// C1./*3*/; -//// } -////} -//// -////class C1 extends Base { -//// protected static protectedOverriddenMethod() { } -//// protected static protectedOverriddenProperty; -////} - - -// Same class, everything is visible -goTo.marker("1"); -verify.memberListContains('privateMethod'); -verify.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); -verify.memberListContains('protectedOverriddenProperty'); - -goTo.marker("2"); -verify.memberListContains('privateMethod'); -verify.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); -verify.memberListContains('protectedOverriddenProperty'); - -// Can not access protected properties overridden in subclass -goTo.marker("3"); -verify.memberListContains('privateMethod'); -verify.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.not.memberListContains('protectedOverriddenMethod'); +/// + +////class Base { +//// private static privateMethod() { } +//// private static privateProperty; +//// +//// protected static protectedMethod() { } +//// protected static protectedProperty; +//// +//// public static publicMethod() { } +//// public static publicProperty; +//// +//// protected static protectedOverriddenMethod() { } +//// protected static protectedOverriddenProperty; +//// +//// static test() { +//// Base./*1*/; +//// this./*2*/; +//// C1./*3*/; +//// } +////} +//// +////class C1 extends Base { +//// protected static protectedOverriddenMethod() { } +//// protected static protectedOverriddenProperty; +////} + + +// Same class, everything is visible +goTo.marker("1"); +verify.memberListContains('privateMethod'); +verify.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); +verify.memberListContains('protectedOverriddenProperty'); + +goTo.marker("2"); +verify.memberListContains('privateMethod'); +verify.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); +verify.memberListContains('protectedOverriddenProperty'); + +// Can not access protected properties overridden in subclass +goTo.marker("3"); +verify.memberListContains('privateMethod'); +verify.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.not.memberListContains('protectedOverriddenMethod'); verify.not.memberListContains('protectedOverriddenProperty'); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListStaticProtectedMembers2.ts b/tests/cases/fourslash/completionListStaticProtectedMembers2.ts index 9964a91d21b..44cf9f73fd5 100644 --- a/tests/cases/fourslash/completionListStaticProtectedMembers2.ts +++ b/tests/cases/fourslash/completionListStaticProtectedMembers2.ts @@ -1,70 +1,70 @@ -/// - -////class Base { -//// private static privateMethod() { } -//// private static privateProperty; -//// -//// protected static protectedMethod() { } -//// protected static protectedProperty; -//// -//// public static publicMethod() { } -//// public static publicProperty; -//// -//// protected static protectedOverriddenMethod() { } -//// protected static protectedOverriddenProperty; -////} -//// -////class C2 extends Base { -//// protected static protectedOverriddenMethod() { } -//// protected static protectedOverriddenProperty; -//// -//// static test() { -//// Base./*1*/; -//// C2./*2*/; -//// this./*3*/; -//// super./*4*/; -//// } -////} - - -// Same class, everything is visible -goTo.marker("1"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); -verify.memberListContains('protectedOverriddenProperty'); - -goTo.marker("2"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); -verify.memberListContains('protectedOverriddenProperty'); - -goTo.marker("3"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); -verify.memberListContains('protectedOverriddenProperty'); - -// only public and protected methods of the base class are accessible through super -goTo.marker("4"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.not.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.not.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); +/// + +////class Base { +//// private static privateMethod() { } +//// private static privateProperty; +//// +//// protected static protectedMethod() { } +//// protected static protectedProperty; +//// +//// public static publicMethod() { } +//// public static publicProperty; +//// +//// protected static protectedOverriddenMethod() { } +//// protected static protectedOverriddenProperty; +////} +//// +////class C2 extends Base { +//// protected static protectedOverriddenMethod() { } +//// protected static protectedOverriddenProperty; +//// +//// static test() { +//// Base./*1*/; +//// C2./*2*/; +//// this./*3*/; +//// super./*4*/; +//// } +////} + + +// Same class, everything is visible +goTo.marker("1"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); +verify.memberListContains('protectedOverriddenProperty'); + +goTo.marker("2"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); +verify.memberListContains('protectedOverriddenProperty'); + +goTo.marker("3"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); +verify.memberListContains('protectedOverriddenProperty'); + +// only public and protected methods of the base class are accessible through super +goTo.marker("4"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.not.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.not.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); verify.not.memberListContains('protectedOverriddenProperty'); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListStaticProtectedMembers3.ts b/tests/cases/fourslash/completionListStaticProtectedMembers3.ts index f80186c93c0..c955f23fa32 100644 --- a/tests/cases/fourslash/completionListStaticProtectedMembers3.ts +++ b/tests/cases/fourslash/completionListStaticProtectedMembers3.ts @@ -1,45 +1,45 @@ -/// - -////class Base { -//// private static privateMethod() { } -//// private static privateProperty; -//// -//// protected static protectedMethod() { } -//// protected static protectedProperty; -//// -//// public static publicMethod() { } -//// public static publicProperty; -//// -//// protected static protectedOverriddenMethod() { } -//// protected static protectedOverriddenProperty; -////} -//// -////class C3 extends Base { -//// protected static protectedOverriddenMethod() { } -//// protected static protectedOverriddenProperty; -////} -//// -////Base./*1*/; -////C3./*2*/; - - -// Only public properties are visible outside the class -goTo.marker("1"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.not.memberListContains('protectedMethod'); -verify.not.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.not.memberListContains('protectedOverriddenMethod'); -verify.not.memberListContains('protectedOverriddenProperty'); - -goTo.marker("2"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.not.memberListContains('protectedMethod'); -verify.not.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.not.memberListContains('protectedOverriddenMethod'); +/// + +////class Base { +//// private static privateMethod() { } +//// private static privateProperty; +//// +//// protected static protectedMethod() { } +//// protected static protectedProperty; +//// +//// public static publicMethod() { } +//// public static publicProperty; +//// +//// protected static protectedOverriddenMethod() { } +//// protected static protectedOverriddenProperty; +////} +//// +////class C3 extends Base { +//// protected static protectedOverriddenMethod() { } +//// protected static protectedOverriddenProperty; +////} +//// +////Base./*1*/; +////C3./*2*/; + + +// Only public properties are visible outside the class +goTo.marker("1"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.not.memberListContains('protectedMethod'); +verify.not.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.not.memberListContains('protectedOverriddenMethod'); +verify.not.memberListContains('protectedOverriddenProperty'); + +goTo.marker("2"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.not.memberListContains('protectedMethod'); +verify.not.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.not.memberListContains('protectedOverriddenMethod'); verify.not.memberListContains('protectedOverriddenProperty'); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListStaticProtectedMembers4.ts b/tests/cases/fourslash/completionListStaticProtectedMembers4.ts index 72cc081f2fc..817d2c4829c 100644 --- a/tests/cases/fourslash/completionListStaticProtectedMembers4.ts +++ b/tests/cases/fourslash/completionListStaticProtectedMembers4.ts @@ -1,49 +1,49 @@ -/// - -////class Base { -//// private static privateMethod() { } -//// private static privateProperty; -//// -//// protected static protectedMethod() { } -//// protected static protectedProperty; -//// -//// public static publicMethod() { } -//// public static publicProperty; -//// -//// protected static protectedOverriddenMethod() { } -//// protected static protectedOverriddenProperty; -////} -//// -/////// Make the protected members public -////class C4 extends Base { -//// public static protectedOverriddenMethod() { } -//// public static protectedOverriddenProperty; -////} -////class Derived extends C4 { -//// test() { -//// Derived./*1*/ -//// } -////} -//// Derived./*2*/ - -// Sub class, everything but private is visible -goTo.marker("1"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.memberListContains('protectedMethod'); -verify.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); -verify.memberListContains('protectedOverriddenProperty'); - -// Can see protected methods elevated to public -goTo.marker("2"); -verify.not.memberListContains('privateMethod'); -verify.not.memberListContains('privateProperty'); -verify.not.memberListContains('protectedMethod'); -verify.not.memberListContains('protectedProperty'); -verify.memberListContains('publicMethod'); -verify.memberListContains('publicProperty'); -verify.memberListContains('protectedOverriddenMethod'); -verify.memberListContains('protectedOverriddenProperty'); +/// + +////class Base { +//// private static privateMethod() { } +//// private static privateProperty; +//// +//// protected static protectedMethod() { } +//// protected static protectedProperty; +//// +//// public static publicMethod() { } +//// public static publicProperty; +//// +//// protected static protectedOverriddenMethod() { } +//// protected static protectedOverriddenProperty; +////} +//// +/////// Make the protected members public +////class C4 extends Base { +//// public static protectedOverriddenMethod() { } +//// public static protectedOverriddenProperty; +////} +////class Derived extends C4 { +//// test() { +//// Derived./*1*/ +//// } +////} +//// Derived./*2*/ + +// Sub class, everything but private is visible +goTo.marker("1"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.memberListContains('protectedMethod'); +verify.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); +verify.memberListContains('protectedOverriddenProperty'); + +// Can see protected methods elevated to public +goTo.marker("2"); +verify.not.memberListContains('privateMethod'); +verify.not.memberListContains('privateProperty'); +verify.not.memberListContains('protectedMethod'); +verify.not.memberListContains('protectedProperty'); +verify.memberListContains('publicMethod'); +verify.memberListContains('publicProperty'); +verify.memberListContains('protectedOverriddenMethod'); +verify.memberListContains('protectedOverriddenProperty'); diff --git a/tests/cases/fourslash/completionListWithAmbientDeclaration.ts b/tests/cases/fourslash/completionListWithAmbientDeclaration.ts index afb5d96fbb7..7cfac28fb24 100644 --- a/tests/cases/fourslash/completionListWithAmbientDeclaration.ts +++ b/tests/cases/fourslash/completionListWithAmbientDeclaration.ts @@ -1,15 +1,15 @@ -/// - -//// declare module "http" { -//// var x; -//// /*1*/ -//// } -//// declare module 'https' { -//// } -//// /*2*/ - -goTo.marker("1"); -verify.not.completionListContains("http"); -goTo.marker("2"); -verify.not.completionListContains("http"); -verify.not.completionListContains("https"); +/// + +//// declare module "http" { +//// var x; +//// /*1*/ +//// } +//// declare module 'https' { +//// } +//// /*2*/ + +goTo.marker("1"); +verify.not.completionListContains("http"); +goTo.marker("2"); +verify.not.completionListContains("http"); +verify.not.completionListContains("https"); diff --git a/tests/cases/fourslash/completionListWithModulesFromModule.ts b/tests/cases/fourslash/completionListWithModulesFromModule.ts index a8d99a47853..96610b203a1 100644 --- a/tests/cases/fourslash/completionListWithModulesFromModule.ts +++ b/tests/cases/fourslash/completionListWithModulesFromModule.ts @@ -1,326 +1,326 @@ -/// - -////module mod1 { -//// var mod1var = 1; -//// function mod1fn() { -//// var bar = 1; -//// function foob() { } -//// } -//// class mod1cls { -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface mod1int { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// module mod1mod { -//// var m1X = 1; -//// function m1Func() { -//// var bar = 1; -//// function foob() { } -//// } -//// class m1Class { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface m1Int { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export var m1eX = 1; -//// export function m1eFunc() { -//// } -//// export class m1eClass { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface m1eInt { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// module m1Mod { } -//// export module m1eMod { } -//// } -//// export var mod1evar = 1; -//// export function mod1efn() { -//// var bar = 1; -//// function foob() { } -//// } -//// export class mod1ecls { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface mod1eint { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export module mod1emod { -//// var mX = 1; -//// function mFunc() { -//// var bar = 1; -//// function foob() { } -//// } -//// class mClass { -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface mInt { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export var meX = 1; -//// export function meFunc() { -//// } -//// export class meClass { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface meInt { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// module mMod { } -//// export module meMod { } -//// } -////} -//// -////// EXTENDING MODULE 1 -////module mod1 { -//// export var mod1eexvar = 1; -//// var mod1exvar = 2; -////} -//// -////module mod2 { -//// var mod2var = "shadow"; -//// function mod2fn() { -//// var bar = 1; -//// function foob() { } -//// } -//// class mod2cls { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// module mod2mod { } -//// interface mod2int { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export var mod2evar = 1; -//// export function mod2efn() { -//// } -//// export class mod2ecls { -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface mod2eint { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export module mod2emod { } -////} -//// -////module mod2 { -//// export var mod2eexvar = 1; -////} -//// -////module mod3 { -//// var shwvar = "shadow"; -//// function shwfn(shadow: any) { -//// var bar = 1; -//// function foob() { } -//// } -//// class shwcls { -//// constructor(public shadow: any) { } -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface shwint { -//// (bar: any): any; -//// new (bar: any): any; -//// sivar: string; -//// sifn(shadow: any): any; -//// } -//// /*shadowModuleWithNoExport*/ -////} -//// -////module mod4 { -//// export var shwvar = "shadow"; -//// export function shwfn(shadow: any) { -//// var bar = 1; -//// function foob(){ } -//// } -//// export class shwcls { -//// constructor(shadow: any) { } -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface shwint { -//// (bar: any): any; -//// new (bar: any): any; -//// sivar: string; -//// sifn(shadow: any): any; -//// } -//// /*shadowModuleWithExport*/ -////} -//// -////module mod5 { -//// import Mod1 = mod1; -//// import iMod1 = mod1.mod1emod; -//// /*moduleWithImport*/ -////} -//// -////function shwfn() { -//// var sfvar = 1; -//// function sffn() { } -////} -//// -////class shwcls { -//// private scvar = 1; -//// private scfn() { } -//// public scpfn() { } -//// public scpvar = 1; -//// static scsvar = 1; -//// static scsfn() { } -////} -//// -////interface shwint { -//// (bar: any): any; -//// new (bar: any): any; -//// sivar: any; -//// sifn(bar: any): any; -////} -//// -////var shwvar = 1; - -function sharedNegativeVerify() -{ - verify.not.completionListContains('sfvar'); - verify.not.completionListContains('sffn'); - verify.not.completionListContains('scvar'); - verify.not.completionListContains('scfn'); - verify.not.completionListContains('scpfn'); - verify.not.completionListContains('scpvar'); - verify.not.completionListContains('scsvar'); - verify.not.completionListContains('scsfn'); - verify.not.completionListContains('sivar'); - verify.not.completionListContains('sifn'); - verify.not.completionListContains('mod1exvar'); - verify.not.completionListContains('mod2eexvar'); -} - -function goToMarkAndVerifyShadow() -{ - sharedNegativeVerify(); - verify.not.completionListContains('mod2var'); - verify.not.completionListContains('mod2fn'); - verify.not.completionListContains('mod2cls'); - verify.not.completionListContains('mod2int'); - verify.not.completionListContains('mod2mod'); - verify.not.completionListContains('mod2evar'); - verify.not.completionListContains('mod2efn'); - verify.not.completionListContains('mod2ecls'); - verify.not.completionListContains('mod2eint'); - verify.not.completionListContains('mod2emod'); -} - -// from a shadow module with no export -goTo.marker('shadowModuleWithNoExport'); -verify.completionListContains('shwvar', '(var) shwvar: string'); -verify.completionListContains('shwfn', '(function) shwfn(shadow: any): void'); -verify.completionListContains('shwcls', 'class shwcls'); -verify.completionListContains('shwint', 'interface shwint'); -goToMarkAndVerifyShadow(); - -// from a shadow module with export -goTo.marker('shadowModuleWithExport'); -verify.completionListContains('shwvar', '(var) mod4.shwvar: string'); -verify.completionListContains('shwfn', '(function) mod4.shwfn(shadow: any): void'); -verify.completionListContains('shwcls', 'class mod4.shwcls'); -verify.completionListContains('shwint', 'interface mod4.shwint'); -goToMarkAndVerifyShadow(); - -// from a modlue with import -goTo.marker('moduleWithImport'); -verify.completionListContains('mod1', 'module mod1'); -verify.completionListContains('mod2', 'module mod2'); -verify.completionListContains('mod3', 'module mod3'); -verify.completionListContains('shwvar', '(var) shwvar: number'); -verify.completionListContains('shwfn', '(function) shwfn(): void'); -verify.completionListContains('shwcls', 'class shwcls'); -verify.completionListContains('shwint', 'interface shwint'); - -sharedNegativeVerify(); - -verify.not.completionListContains('mod1var'); -verify.not.completionListContains('mod1fn'); -verify.not.completionListContains('mod1cls'); -verify.not.completionListContains('mod1int'); -verify.not.completionListContains('mod1mod'); -verify.not.completionListContains('mod1evar'); -verify.not.completionListContains('mod1efn'); -verify.not.completionListContains('mod1ecls'); -verify.not.completionListContains('mod1eint'); -verify.not.completionListContains('mod1emod'); -verify.not.completionListContains('mX'); -verify.not.completionListContains('mFunc'); -verify.not.completionListContains('mClass'); -verify.not.completionListContains('mInt'); -verify.not.completionListContains('mMod'); -verify.not.completionListContains('meX'); -verify.not.completionListContains('meFunc'); -verify.not.completionListContains('meClass'); -verify.not.completionListContains('meInt'); +/// + +////module mod1 { +//// var mod1var = 1; +//// function mod1fn() { +//// var bar = 1; +//// function foob() { } +//// } +//// class mod1cls { +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface mod1int { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// module mod1mod { +//// var m1X = 1; +//// function m1Func() { +//// var bar = 1; +//// function foob() { } +//// } +//// class m1Class { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface m1Int { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export var m1eX = 1; +//// export function m1eFunc() { +//// } +//// export class m1eClass { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface m1eInt { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// module m1Mod { } +//// export module m1eMod { } +//// } +//// export var mod1evar = 1; +//// export function mod1efn() { +//// var bar = 1; +//// function foob() { } +//// } +//// export class mod1ecls { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface mod1eint { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export module mod1emod { +//// var mX = 1; +//// function mFunc() { +//// var bar = 1; +//// function foob() { } +//// } +//// class mClass { +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface mInt { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export var meX = 1; +//// export function meFunc() { +//// } +//// export class meClass { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface meInt { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// module mMod { } +//// export module meMod { } +//// } +////} +//// +////// EXTENDING MODULE 1 +////module mod1 { +//// export var mod1eexvar = 1; +//// var mod1exvar = 2; +////} +//// +////module mod2 { +//// var mod2var = "shadow"; +//// function mod2fn() { +//// var bar = 1; +//// function foob() { } +//// } +//// class mod2cls { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// module mod2mod { } +//// interface mod2int { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export var mod2evar = 1; +//// export function mod2efn() { +//// } +//// export class mod2ecls { +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface mod2eint { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export module mod2emod { } +////} +//// +////module mod2 { +//// export var mod2eexvar = 1; +////} +//// +////module mod3 { +//// var shwvar = "shadow"; +//// function shwfn(shadow: any) { +//// var bar = 1; +//// function foob() { } +//// } +//// class shwcls { +//// constructor(public shadow: any) { } +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface shwint { +//// (bar: any): any; +//// new (bar: any): any; +//// sivar: string; +//// sifn(shadow: any): any; +//// } +//// /*shadowModuleWithNoExport*/ +////} +//// +////module mod4 { +//// export var shwvar = "shadow"; +//// export function shwfn(shadow: any) { +//// var bar = 1; +//// function foob(){ } +//// } +//// export class shwcls { +//// constructor(shadow: any) { } +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface shwint { +//// (bar: any): any; +//// new (bar: any): any; +//// sivar: string; +//// sifn(shadow: any): any; +//// } +//// /*shadowModuleWithExport*/ +////} +//// +////module mod5 { +//// import Mod1 = mod1; +//// import iMod1 = mod1.mod1emod; +//// /*moduleWithImport*/ +////} +//// +////function shwfn() { +//// var sfvar = 1; +//// function sffn() { } +////} +//// +////class shwcls { +//// private scvar = 1; +//// private scfn() { } +//// public scpfn() { } +//// public scpvar = 1; +//// static scsvar = 1; +//// static scsfn() { } +////} +//// +////interface shwint { +//// (bar: any): any; +//// new (bar: any): any; +//// sivar: any; +//// sifn(bar: any): any; +////} +//// +////var shwvar = 1; + +function sharedNegativeVerify() +{ + verify.not.completionListContains('sfvar'); + verify.not.completionListContains('sffn'); + verify.not.completionListContains('scvar'); + verify.not.completionListContains('scfn'); + verify.not.completionListContains('scpfn'); + verify.not.completionListContains('scpvar'); + verify.not.completionListContains('scsvar'); + verify.not.completionListContains('scsfn'); + verify.not.completionListContains('sivar'); + verify.not.completionListContains('sifn'); + verify.not.completionListContains('mod1exvar'); + verify.not.completionListContains('mod2eexvar'); +} + +function goToMarkAndVerifyShadow() +{ + sharedNegativeVerify(); + verify.not.completionListContains('mod2var'); + verify.not.completionListContains('mod2fn'); + verify.not.completionListContains('mod2cls'); + verify.not.completionListContains('mod2int'); + verify.not.completionListContains('mod2mod'); + verify.not.completionListContains('mod2evar'); + verify.not.completionListContains('mod2efn'); + verify.not.completionListContains('mod2ecls'); + verify.not.completionListContains('mod2eint'); + verify.not.completionListContains('mod2emod'); +} + +// from a shadow module with no export +goTo.marker('shadowModuleWithNoExport'); +verify.completionListContains('shwvar', '(var) shwvar: string'); +verify.completionListContains('shwfn', '(function) shwfn(shadow: any): void'); +verify.completionListContains('shwcls', 'class shwcls'); +verify.completionListContains('shwint', 'interface shwint'); +goToMarkAndVerifyShadow(); + +// from a shadow module with export +goTo.marker('shadowModuleWithExport'); +verify.completionListContains('shwvar', '(var) mod4.shwvar: string'); +verify.completionListContains('shwfn', '(function) mod4.shwfn(shadow: any): void'); +verify.completionListContains('shwcls', 'class mod4.shwcls'); +verify.completionListContains('shwint', 'interface mod4.shwint'); +goToMarkAndVerifyShadow(); + +// from a modlue with import +goTo.marker('moduleWithImport'); +verify.completionListContains('mod1', 'module mod1'); +verify.completionListContains('mod2', 'module mod2'); +verify.completionListContains('mod3', 'module mod3'); +verify.completionListContains('shwvar', '(var) shwvar: number'); +verify.completionListContains('shwfn', '(function) shwfn(): void'); +verify.completionListContains('shwcls', 'class shwcls'); +verify.completionListContains('shwint', 'interface shwint'); + +sharedNegativeVerify(); + +verify.not.completionListContains('mod1var'); +verify.not.completionListContains('mod1fn'); +verify.not.completionListContains('mod1cls'); +verify.not.completionListContains('mod1int'); +verify.not.completionListContains('mod1mod'); +verify.not.completionListContains('mod1evar'); +verify.not.completionListContains('mod1efn'); +verify.not.completionListContains('mod1ecls'); +verify.not.completionListContains('mod1eint'); +verify.not.completionListContains('mod1emod'); +verify.not.completionListContains('mX'); +verify.not.completionListContains('mFunc'); +verify.not.completionListContains('mClass'); +verify.not.completionListContains('mInt'); +verify.not.completionListContains('mMod'); +verify.not.completionListContains('meX'); +verify.not.completionListContains('meFunc'); +verify.not.completionListContains('meClass'); +verify.not.completionListContains('meInt'); verify.not.completionListContains('meMod'); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts b/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts index 920ba030264..49180cb95d5 100644 --- a/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts +++ b/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts @@ -1,364 +1,364 @@ -/// - -////module mod1 { -//// var mod1var = 1; -//// function mod1fn() { -//// var bar = 1; -//// function foob() { } -//// /*function*/ -//// } -//// class mod1cls { -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// /*class*/ -//// } -//// interface mod1int { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// /*interface*/ -//// } -//// module mod1mod { -//// var m1X = 1; -//// function m1Func() { -//// var bar = 1; -//// function foob() { } -//// } -//// class m1Class { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface m1Int { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export var m1eX = 1; -//// export function m1eFunc() { -//// } -//// export class m1eClass { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface m1eInt { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// module m1Mod { } -//// export module m1eMod { } -//// /*module*/ -//// } -//// export var mod1evar = 1; -//// export function mod1efn() { -//// var bar = 1; -//// function foob() { } -//// /*exportedFunction*/ -//// } -//// export class mod1ecls { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// /*exportedClass*/ -//// } -//// export interface mod1eint { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// /*exportedInterface*/ -//// } -//// export module mod1emod { -//// var mX = 1; -//// function mFunc() { -//// var bar = 1; -//// function foob() { } -//// } -//// class mClass { -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface mInt { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export var meX = 1; -//// export function meFunc() { -//// } -//// export class meClass { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface meInt { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// module mMod { } -//// export module meMod { } -//// /*exportedModule*/ -//// } -//// /*mod1*/ -////} -//// -////// EXTENDING MODULE 1 -////module mod1 { -//// export var mod1eexvar = 1; -//// var mod1exvar = 2; -//// /*extendedModule*/ -////} -//// -////module mod2 { -//// var mod2var = "shadow"; -//// function mod2fn() { -//// var bar = 1; -//// function foob() { } -//// } -//// class mod2cls { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// module mod2mod { } -//// interface mod2int { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export var mod2evar = 1; -//// export function mod2efn() { -//// } -//// export class mod2ecls { -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface mod2eint { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export module mod2emod { } -////} -//// -////module mod2 { -//// export var mod2eexvar = 1; -////} -//// -////module mod3 { -//// var shwvar = "shadow"; -//// function shwfn() { -//// var bar = 1; -//// function foob() { } -//// } -//// class shwcls { -//// constructor(public shadow: any) { } -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface shwint { -//// (bar: any): any; -//// new (bar: any): any; -//// sivar: string; -//// sifn(shadow: any): any; -//// } -////} -//// -////function shwfn() { -//// var sfvar = 1; -//// function sffn() { } -////} -//// -////class shwcls { -//// private scvar = 1; -//// private scfn() { } -//// public scpfn() { } -//// public scpvar = 1; -//// static scsvar = 1; -//// static scsfn() { } -////} -//// -////interface shwint { -//// (bar: any): any; -//// new (bar: any): any; -//// sivar: any; -//// sifn(bar: any): any; -////} -//// -////var shwvar = 1; - -function goToMarkAndGeneralVerify(marker: string) -{ - goTo.marker(marker); - - verify.completionListContains('mod1var', '(var) mod1var: number'); - verify.completionListContains('mod1fn', '(function) mod1fn(): void'); - verify.completionListContains('mod1cls', 'class mod1cls'); - verify.completionListContains('mod1int', 'interface mod1int'); - verify.completionListContains('mod1mod', 'module mod1mod'); - verify.completionListContains('mod1evar', '(var) mod1.mod1evar: number'); - verify.completionListContains('mod1efn', '(function) mod1.mod1efn(): void'); - verify.completionListContains('mod1ecls', 'class mod1.mod1ecls'); - verify.completionListContains('mod1eint', 'interface mod1.mod1eint'); - verify.completionListContains('mod1emod', 'module mod1.mod1emod'); - verify.completionListContains('mod1eexvar', '(var) mod1.mod1eexvar: number'); - verify.completionListContains('mod2', 'module mod2'); - verify.completionListContains('mod3', 'module mod3'); - verify.completionListContains('shwvar', '(var) shwvar: number'); - verify.completionListContains('shwfn', '(function) shwfn(): void'); - verify.completionListContains('shwcls', 'class shwcls'); - verify.completionListContains('shwint', 'interface shwint'); - - verify.not.completionListContains('mod2var'); - verify.not.completionListContains('mod2fn'); - verify.not.completionListContains('mod2cls'); - verify.not.completionListContains('mod2int'); - verify.not.completionListContains('mod2mod'); - verify.not.completionListContains('mod2evar'); - verify.not.completionListContains('mod2efn'); - verify.not.completionListContains('mod2ecls'); - verify.not.completionListContains('mod2eint'); - verify.not.completionListContains('mod2emod'); - verify.not.completionListContains('sfvar'); - verify.not.completionListContains('sffn'); - verify.not.completionListContains('scvar'); - verify.not.completionListContains('scfn'); - verify.not.completionListContains('scpfn'); - verify.not.completionListContains('scpvar'); - verify.not.completionListContains('scsvar'); - verify.not.completionListContains('scsfn'); - verify.not.completionListContains('sivar'); - verify.not.completionListContains('sifn'); - verify.not.completionListContains('mod1exvar'); - verify.not.completionListContains('mod2eexvar'); -} - -// from mod1 -goToMarkAndGeneralVerify('mod1'); - -// from function in mod1 -goToMarkAndGeneralVerify('function'); -verify.completionListContains('bar', '(local var) bar: number'); -verify.completionListContains('foob', '(local function) foob(): void'); - -// from class in mod1 -goToMarkAndGeneralVerify('class'); -//verify.not.completionListContains('ceFunc'); -//verify.not.completionListContains('ceVar'); - -// from interface in mod1 -goToMarkAndGeneralVerify('interface'); - -// from module in mod1 -goToMarkAndGeneralVerify('module'); -verify.completionListContains('m1X', '(var) m1X: number'); -verify.completionListContains('m1Func', '(function) m1Func(): void'); -verify.completionListContains('m1Class', 'class m1Class'); -verify.completionListContains('m1Int', 'interface m1Int'); -verify.completionListContains('m1Mod', 'module m1Mod'); -verify.completionListContains('m1eX', '(var) mod1mod.m1eX: number'); -verify.completionListContains('m1eFunc', '(function) mod1mod.m1eFunc(): void'); -verify.completionListContains('m1eClass', 'class mod1mod.m1eClass'); -verify.completionListContains('m1eInt', 'interface mod1mod.m1eInt'); -verify.completionListContains('m1eMod', 'module mod1mod.m1eMod'); - -// from exported function in mod1 -goToMarkAndGeneralVerify('exportedFunction'); -verify.completionListContains('bar', '(local var) bar: number'); -verify.completionListContains('foob', '(local function) foob(): void'); - -// from exported class in mod1 -goToMarkAndGeneralVerify('exportedClass'); -//verify.not.completionListContains('ceFunc'); -//verify.not.completionListContains('ceVar'); - -// from exported interface in mod1 -goToMarkAndGeneralVerify('exportedInterface'); - -// from exported module in mod1 -goToMarkAndGeneralVerify('exportedModule'); -verify.completionListContains('mX', '(var) mX: number'); -verify.completionListContains('mFunc', '(function) mFunc(): void'); -verify.completionListContains('mClass', 'class mClass'); -verify.completionListContains('mInt', 'interface mInt'); -verify.completionListContains('mMod', 'module mMod'); -verify.completionListContains('meX', '(var) mod1.mod1emod.meX: number'); -verify.completionListContains('meFunc', '(function) mod1.mod1emod.meFunc(): void'); -verify.completionListContains('meClass', 'class mod1.mod1emod.meClass'); -verify.completionListContains('meInt', 'interface mod1.mod1emod.meInt'); -verify.completionListContains('meMod', 'module mod1.mod1emod.meMod'); - -// from extended module -goTo.marker('extendedModule'); -verify.completionListContains('mod1evar', '(var) mod1.mod1evar: number'); -verify.completionListContains('mod1efn', '(function) mod1.mod1efn(): void'); -verify.completionListContains('mod1ecls', 'class mod1.mod1ecls'); -verify.completionListContains('mod1eint', 'interface mod1.mod1eint'); -verify.completionListContains('mod1emod', 'module mod1.mod1emod'); -verify.completionListContains('mod1eexvar', '(var) mod1.mod1eexvar: number'); -verify.completionListContains('mod2', 'module mod2'); -verify.completionListContains('mod3', 'module mod3'); -verify.completionListContains('shwvar', '(var) shwvar: number'); -verify.completionListContains('shwfn', '(function) shwfn(): void'); -verify.completionListContains('shwcls', 'class shwcls'); -verify.completionListContains('shwint', 'interface shwint'); - -verify.not.completionListContains('mod2var'); -verify.not.completionListContains('mod2fn'); -verify.not.completionListContains('mod2cls'); -verify.not.completionListContains('mod2int'); -verify.not.completionListContains('mod2mod'); -verify.not.completionListContains('mod2evar'); -verify.not.completionListContains('mod2efn'); -verify.not.completionListContains('mod2ecls'); -verify.not.completionListContains('mod2eint'); -verify.not.completionListContains('mod2emod'); -verify.not.completionListContains('sfvar'); -verify.not.completionListContains('sffn'); -verify.not.completionListContains('scvar'); -verify.not.completionListContains('scfn'); -verify.not.completionListContains('scpfn'); -verify.not.completionListContains('scpvar'); -verify.not.completionListContains('scsvar'); -verify.not.completionListContains('scsfn'); -verify.not.completionListContains('sivar'); -verify.not.completionListContains('sifn'); +/// + +////module mod1 { +//// var mod1var = 1; +//// function mod1fn() { +//// var bar = 1; +//// function foob() { } +//// /*function*/ +//// } +//// class mod1cls { +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// /*class*/ +//// } +//// interface mod1int { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// /*interface*/ +//// } +//// module mod1mod { +//// var m1X = 1; +//// function m1Func() { +//// var bar = 1; +//// function foob() { } +//// } +//// class m1Class { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface m1Int { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export var m1eX = 1; +//// export function m1eFunc() { +//// } +//// export class m1eClass { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface m1eInt { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// module m1Mod { } +//// export module m1eMod { } +//// /*module*/ +//// } +//// export var mod1evar = 1; +//// export function mod1efn() { +//// var bar = 1; +//// function foob() { } +//// /*exportedFunction*/ +//// } +//// export class mod1ecls { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// /*exportedClass*/ +//// } +//// export interface mod1eint { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// /*exportedInterface*/ +//// } +//// export module mod1emod { +//// var mX = 1; +//// function mFunc() { +//// var bar = 1; +//// function foob() { } +//// } +//// class mClass { +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface mInt { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export var meX = 1; +//// export function meFunc() { +//// } +//// export class meClass { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface meInt { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// module mMod { } +//// export module meMod { } +//// /*exportedModule*/ +//// } +//// /*mod1*/ +////} +//// +////// EXTENDING MODULE 1 +////module mod1 { +//// export var mod1eexvar = 1; +//// var mod1exvar = 2; +//// /*extendedModule*/ +////} +//// +////module mod2 { +//// var mod2var = "shadow"; +//// function mod2fn() { +//// var bar = 1; +//// function foob() { } +//// } +//// class mod2cls { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// module mod2mod { } +//// interface mod2int { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export var mod2evar = 1; +//// export function mod2efn() { +//// } +//// export class mod2ecls { +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface mod2eint { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export module mod2emod { } +////} +//// +////module mod2 { +//// export var mod2eexvar = 1; +////} +//// +////module mod3 { +//// var shwvar = "shadow"; +//// function shwfn() { +//// var bar = 1; +//// function foob() { } +//// } +//// class shwcls { +//// constructor(public shadow: any) { } +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface shwint { +//// (bar: any): any; +//// new (bar: any): any; +//// sivar: string; +//// sifn(shadow: any): any; +//// } +////} +//// +////function shwfn() { +//// var sfvar = 1; +//// function sffn() { } +////} +//// +////class shwcls { +//// private scvar = 1; +//// private scfn() { } +//// public scpfn() { } +//// public scpvar = 1; +//// static scsvar = 1; +//// static scsfn() { } +////} +//// +////interface shwint { +//// (bar: any): any; +//// new (bar: any): any; +//// sivar: any; +//// sifn(bar: any): any; +////} +//// +////var shwvar = 1; + +function goToMarkAndGeneralVerify(marker: string) +{ + goTo.marker(marker); + + verify.completionListContains('mod1var', '(var) mod1var: number'); + verify.completionListContains('mod1fn', '(function) mod1fn(): void'); + verify.completionListContains('mod1cls', 'class mod1cls'); + verify.completionListContains('mod1int', 'interface mod1int'); + verify.completionListContains('mod1mod', 'module mod1mod'); + verify.completionListContains('mod1evar', '(var) mod1.mod1evar: number'); + verify.completionListContains('mod1efn', '(function) mod1.mod1efn(): void'); + verify.completionListContains('mod1ecls', 'class mod1.mod1ecls'); + verify.completionListContains('mod1eint', 'interface mod1.mod1eint'); + verify.completionListContains('mod1emod', 'module mod1.mod1emod'); + verify.completionListContains('mod1eexvar', '(var) mod1.mod1eexvar: number'); + verify.completionListContains('mod2', 'module mod2'); + verify.completionListContains('mod3', 'module mod3'); + verify.completionListContains('shwvar', '(var) shwvar: number'); + verify.completionListContains('shwfn', '(function) shwfn(): void'); + verify.completionListContains('shwcls', 'class shwcls'); + verify.completionListContains('shwint', 'interface shwint'); + + verify.not.completionListContains('mod2var'); + verify.not.completionListContains('mod2fn'); + verify.not.completionListContains('mod2cls'); + verify.not.completionListContains('mod2int'); + verify.not.completionListContains('mod2mod'); + verify.not.completionListContains('mod2evar'); + verify.not.completionListContains('mod2efn'); + verify.not.completionListContains('mod2ecls'); + verify.not.completionListContains('mod2eint'); + verify.not.completionListContains('mod2emod'); + verify.not.completionListContains('sfvar'); + verify.not.completionListContains('sffn'); + verify.not.completionListContains('scvar'); + verify.not.completionListContains('scfn'); + verify.not.completionListContains('scpfn'); + verify.not.completionListContains('scpvar'); + verify.not.completionListContains('scsvar'); + verify.not.completionListContains('scsfn'); + verify.not.completionListContains('sivar'); + verify.not.completionListContains('sifn'); + verify.not.completionListContains('mod1exvar'); + verify.not.completionListContains('mod2eexvar'); +} + +// from mod1 +goToMarkAndGeneralVerify('mod1'); + +// from function in mod1 +goToMarkAndGeneralVerify('function'); +verify.completionListContains('bar', '(local var) bar: number'); +verify.completionListContains('foob', '(local function) foob(): void'); + +// from class in mod1 +goToMarkAndGeneralVerify('class'); +//verify.not.completionListContains('ceFunc'); +//verify.not.completionListContains('ceVar'); + +// from interface in mod1 +goToMarkAndGeneralVerify('interface'); + +// from module in mod1 +goToMarkAndGeneralVerify('module'); +verify.completionListContains('m1X', '(var) m1X: number'); +verify.completionListContains('m1Func', '(function) m1Func(): void'); +verify.completionListContains('m1Class', 'class m1Class'); +verify.completionListContains('m1Int', 'interface m1Int'); +verify.completionListContains('m1Mod', 'module m1Mod'); +verify.completionListContains('m1eX', '(var) mod1mod.m1eX: number'); +verify.completionListContains('m1eFunc', '(function) mod1mod.m1eFunc(): void'); +verify.completionListContains('m1eClass', 'class mod1mod.m1eClass'); +verify.completionListContains('m1eInt', 'interface mod1mod.m1eInt'); +verify.completionListContains('m1eMod', 'module mod1mod.m1eMod'); + +// from exported function in mod1 +goToMarkAndGeneralVerify('exportedFunction'); +verify.completionListContains('bar', '(local var) bar: number'); +verify.completionListContains('foob', '(local function) foob(): void'); + +// from exported class in mod1 +goToMarkAndGeneralVerify('exportedClass'); +//verify.not.completionListContains('ceFunc'); +//verify.not.completionListContains('ceVar'); + +// from exported interface in mod1 +goToMarkAndGeneralVerify('exportedInterface'); + +// from exported module in mod1 +goToMarkAndGeneralVerify('exportedModule'); +verify.completionListContains('mX', '(var) mX: number'); +verify.completionListContains('mFunc', '(function) mFunc(): void'); +verify.completionListContains('mClass', 'class mClass'); +verify.completionListContains('mInt', 'interface mInt'); +verify.completionListContains('mMod', 'module mMod'); +verify.completionListContains('meX', '(var) mod1.mod1emod.meX: number'); +verify.completionListContains('meFunc', '(function) mod1.mod1emod.meFunc(): void'); +verify.completionListContains('meClass', 'class mod1.mod1emod.meClass'); +verify.completionListContains('meInt', 'interface mod1.mod1emod.meInt'); +verify.completionListContains('meMod', 'module mod1.mod1emod.meMod'); + +// from extended module +goTo.marker('extendedModule'); +verify.completionListContains('mod1evar', '(var) mod1.mod1evar: number'); +verify.completionListContains('mod1efn', '(function) mod1.mod1efn(): void'); +verify.completionListContains('mod1ecls', 'class mod1.mod1ecls'); +verify.completionListContains('mod1eint', 'interface mod1.mod1eint'); +verify.completionListContains('mod1emod', 'module mod1.mod1emod'); +verify.completionListContains('mod1eexvar', '(var) mod1.mod1eexvar: number'); +verify.completionListContains('mod2', 'module mod2'); +verify.completionListContains('mod3', 'module mod3'); +verify.completionListContains('shwvar', '(var) shwvar: number'); +verify.completionListContains('shwfn', '(function) shwfn(): void'); +verify.completionListContains('shwcls', 'class shwcls'); +verify.completionListContains('shwint', 'interface shwint'); + +verify.not.completionListContains('mod2var'); +verify.not.completionListContains('mod2fn'); +verify.not.completionListContains('mod2cls'); +verify.not.completionListContains('mod2int'); +verify.not.completionListContains('mod2mod'); +verify.not.completionListContains('mod2evar'); +verify.not.completionListContains('mod2efn'); +verify.not.completionListContains('mod2ecls'); +verify.not.completionListContains('mod2eint'); +verify.not.completionListContains('mod2emod'); +verify.not.completionListContains('sfvar'); +verify.not.completionListContains('sffn'); +verify.not.completionListContains('scvar'); +verify.not.completionListContains('scfn'); +verify.not.completionListContains('scpfn'); +verify.not.completionListContains('scpvar'); +verify.not.completionListContains('scsvar'); +verify.not.completionListContains('scsfn'); +verify.not.completionListContains('sivar'); +verify.not.completionListContains('sifn'); verify.not.completionListContains('mod2eexvar'); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListWithModulesOutsideModuleScope.ts b/tests/cases/fourslash/completionListWithModulesOutsideModuleScope.ts index 43314b45d7f..b228b244fee 100644 --- a/tests/cases/fourslash/completionListWithModulesOutsideModuleScope.ts +++ b/tests/cases/fourslash/completionListWithModulesOutsideModuleScope.ts @@ -1,291 +1,291 @@ -/// - -////module mod1 { -//// var mod1var = 1; -//// function mod1fn() { -//// var bar = 1; -//// function foob() { } -//// } -//// class mod1cls { -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface mod1int { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// module mod1mod { -//// var m1X = 1; -//// function m1Func() { -//// var bar = 1; -//// function foob() { } -//// } -//// class m1Class { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface m1Int { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export var m1eX = 1; -//// export function m1eFunc() { -//// } -//// export class m1eClass { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface m1eInt { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// module m1Mod { } -//// export module m1eMod { } -//// } -//// export var mod1evar = 1; -//// export function mod1efn() { -//// var bar = 1; -//// function foob() { } -//// } -//// export class mod1ecls { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface mod1eint { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export module mod1emod { -//// var mX = 1; -//// function mFunc() { -//// var bar = 1; -//// function foob() { } -//// } -//// class mClass { -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface mInt { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export var meX = 1; -//// export function meFunc() { -//// } -//// export class meClass { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface meInt { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// module mMod { } -//// export module meMod { } -//// } -////} -//// -////// EXTENDING MODULE 1 -////module mod1 { -//// export var mod1eexvar = 1; -//// var mod1exvar = 2; -////} -//// -////module mod2 { -//// var mod2var = "shadow"; -//// function mod2fn() { -//// var bar = 1; -//// function foob() { } -//// } -//// class mod2cls { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// module mod2mod { } -//// interface mod2int { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export var mod2evar = 1; -//// export function mod2efn() { -//// } -//// export class mod2ecls { -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface mod2eint { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export module mod2emod { } -////} -//// -////module mod2 { -//// export var mod2eexvar = 1; -////} -//// -////module mod3 { -//// var shwvar = "shadow"; -//// function shwfn() { -//// var bar = 1; -//// function foob() { } -//// } -//// class shwcls { -//// constructor(public shadow: any) { } -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface shwint { -//// (bar: any): any; -//// new (bar: any): any; -//// sivar: string; -//// sifn(shadow: any): any; -//// } -////} -//// -////function shwfn() { -//// var sfvar = 1; -//// function sffn() { } -//// /*function*/ -////} -//// -////class shwcls { -//// private scvar = 1; -//// private scfn() { } -//// public scpfn() { } -//// public scpvar = 1; -//// static scsvar = 1; -//// static scsfn() { } -//// /*class*/ -////} -//// -////interface shwint { -//// (bar: any): any; -//// new (bar: any): any; -//// sivar: any; -//// sifn(bar: any): any; -//// /*interface*/ -////} -//// -////var shwvar = 1; -/////*global*/ - -function verifyNotContainFunctionMembers() -{ - verify.not.completionListContains('sfvar'); - verify.not.completionListContains('sffn'); -} - -function verifyNotContainClassMembers() -{ - verify.not.completionListContains('scvar'); - verify.not.completionListContains('scfn'); - verify.not.completionListContains('scpfn'); - verify.not.completionListContains('scpvar'); - verify.not.completionListContains('scsvar'); - verify.not.completionListContains('scsfn'); -} - -function verifyNotContainInterfaceMembers() -{ - verify.not.completionListContains('sivar'); - verify.not.completionListContains('sifn'); -} - -function goToMarkAndGeneralVerify(marker: string) -{ - goTo.marker(marker); - - verify.not.completionListContains('mod1var'); - verify.not.completionListContains('mod1fn'); - verify.not.completionListContains('mod1cls'); - verify.not.completionListContains('mod1int'); - verify.not.completionListContains('mod1mod'); - verify.not.completionListContains('mod1evar'); - verify.not.completionListContains('mod1efn'); - verify.not.completionListContains('mod1ecls'); - verify.not.completionListContains('mod1eint'); - verify.not.completionListContains('mod1emod'); - verify.not.completionListContains('mod1eexvar'); -} - -// from global scope -goToMarkAndGeneralVerify('global'); -verify.completionListContains('mod1', 'module mod1'); -verify.completionListContains('mod2', 'module mod2'); -verify.completionListContains('mod3', 'module mod3'); -verify.completionListContains('shwvar', '(var) shwvar: number'); -verify.completionListContains('shwfn', '(function) shwfn(): void'); -verify.completionListContains('shwcls', 'class shwcls'); -verify.completionListContains('shwint', 'interface shwint'); - -verifyNotContainFunctionMembers(); -verifyNotContainClassMembers(); -verifyNotContainInterfaceMembers(); - -// from function scope -goToMarkAndGeneralVerify('function'); -verify.completionListContains('sfvar', '(local var) sfvar: number'); -verify.completionListContains('sffn', '(local function) sffn(): void'); - -verifyNotContainClassMembers(); -verifyNotContainInterfaceMembers(); - -// from class scope -goToMarkAndGeneralVerify('class'); -verifyNotContainFunctionMembers(); -verifyNotContainInterfaceMembers(); - -// from interface scope -goToMarkAndGeneralVerify('interface'); -verifyNotContainClassMembers(); +/// + +////module mod1 { +//// var mod1var = 1; +//// function mod1fn() { +//// var bar = 1; +//// function foob() { } +//// } +//// class mod1cls { +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface mod1int { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// module mod1mod { +//// var m1X = 1; +//// function m1Func() { +//// var bar = 1; +//// function foob() { } +//// } +//// class m1Class { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface m1Int { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export var m1eX = 1; +//// export function m1eFunc() { +//// } +//// export class m1eClass { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface m1eInt { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// module m1Mod { } +//// export module m1eMod { } +//// } +//// export var mod1evar = 1; +//// export function mod1efn() { +//// var bar = 1; +//// function foob() { } +//// } +//// export class mod1ecls { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface mod1eint { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export module mod1emod { +//// var mX = 1; +//// function mFunc() { +//// var bar = 1; +//// function foob() { } +//// } +//// class mClass { +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface mInt { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export var meX = 1; +//// export function meFunc() { +//// } +//// export class meClass { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface meInt { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// module mMod { } +//// export module meMod { } +//// } +////} +//// +////// EXTENDING MODULE 1 +////module mod1 { +//// export var mod1eexvar = 1; +//// var mod1exvar = 2; +////} +//// +////module mod2 { +//// var mod2var = "shadow"; +//// function mod2fn() { +//// var bar = 1; +//// function foob() { } +//// } +//// class mod2cls { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// module mod2mod { } +//// interface mod2int { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export var mod2evar = 1; +//// export function mod2efn() { +//// } +//// export class mod2ecls { +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface mod2eint { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export module mod2emod { } +////} +//// +////module mod2 { +//// export var mod2eexvar = 1; +////} +//// +////module mod3 { +//// var shwvar = "shadow"; +//// function shwfn() { +//// var bar = 1; +//// function foob() { } +//// } +//// class shwcls { +//// constructor(public shadow: any) { } +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface shwint { +//// (bar: any): any; +//// new (bar: any): any; +//// sivar: string; +//// sifn(shadow: any): any; +//// } +////} +//// +////function shwfn() { +//// var sfvar = 1; +//// function sffn() { } +//// /*function*/ +////} +//// +////class shwcls { +//// private scvar = 1; +//// private scfn() { } +//// public scpfn() { } +//// public scpvar = 1; +//// static scsvar = 1; +//// static scsfn() { } +//// /*class*/ +////} +//// +////interface shwint { +//// (bar: any): any; +//// new (bar: any): any; +//// sivar: any; +//// sifn(bar: any): any; +//// /*interface*/ +////} +//// +////var shwvar = 1; +/////*global*/ + +function verifyNotContainFunctionMembers() +{ + verify.not.completionListContains('sfvar'); + verify.not.completionListContains('sffn'); +} + +function verifyNotContainClassMembers() +{ + verify.not.completionListContains('scvar'); + verify.not.completionListContains('scfn'); + verify.not.completionListContains('scpfn'); + verify.not.completionListContains('scpvar'); + verify.not.completionListContains('scsvar'); + verify.not.completionListContains('scsfn'); +} + +function verifyNotContainInterfaceMembers() +{ + verify.not.completionListContains('sivar'); + verify.not.completionListContains('sifn'); +} + +function goToMarkAndGeneralVerify(marker: string) +{ + goTo.marker(marker); + + verify.not.completionListContains('mod1var'); + verify.not.completionListContains('mod1fn'); + verify.not.completionListContains('mod1cls'); + verify.not.completionListContains('mod1int'); + verify.not.completionListContains('mod1mod'); + verify.not.completionListContains('mod1evar'); + verify.not.completionListContains('mod1efn'); + verify.not.completionListContains('mod1ecls'); + verify.not.completionListContains('mod1eint'); + verify.not.completionListContains('mod1emod'); + verify.not.completionListContains('mod1eexvar'); +} + +// from global scope +goToMarkAndGeneralVerify('global'); +verify.completionListContains('mod1', 'module mod1'); +verify.completionListContains('mod2', 'module mod2'); +verify.completionListContains('mod3', 'module mod3'); +verify.completionListContains('shwvar', '(var) shwvar: number'); +verify.completionListContains('shwfn', '(function) shwfn(): void'); +verify.completionListContains('shwcls', 'class shwcls'); +verify.completionListContains('shwint', 'interface shwint'); + +verifyNotContainFunctionMembers(); +verifyNotContainClassMembers(); +verifyNotContainInterfaceMembers(); + +// from function scope +goToMarkAndGeneralVerify('function'); +verify.completionListContains('sfvar', '(local var) sfvar: number'); +verify.completionListContains('sffn', '(local function) sffn(): void'); + +verifyNotContainClassMembers(); +verifyNotContainInterfaceMembers(); + +// from class scope +goToMarkAndGeneralVerify('class'); +verifyNotContainFunctionMembers(); +verifyNotContainInterfaceMembers(); + +// from interface scope +goToMarkAndGeneralVerify('interface'); +verifyNotContainClassMembers(); verifyNotContainFunctionMembers(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListWithModulesOutsideModuleScope2.ts b/tests/cases/fourslash/completionListWithModulesOutsideModuleScope2.ts index 04bf7bf26d5..aed914657ae 100644 --- a/tests/cases/fourslash/completionListWithModulesOutsideModuleScope2.ts +++ b/tests/cases/fourslash/completionListWithModulesOutsideModuleScope2.ts @@ -1,275 +1,275 @@ -/// - -////module mod1 { -//// var mod1var = 1; -//// function mod1fn() { -//// var bar = 1; -//// function foob() { } -//// } -//// class mod1cls { -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface mod1int { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// module mod1mod { -//// var m1X = 1; -//// function m1Func() { -//// var bar = 1; -//// function foob() { } -//// } -//// class m1Class { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface m1Int { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export var m1eX = 1; -//// export function m1eFunc() { -//// } -//// export class m1eClass { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface m1eInt { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// module m1Mod { } -//// export module m1eMod { } -//// } -//// export var mod1evar = 1; -//// export function mod1efn() { -//// var bar = 1; -//// function foob() { } -//// } -//// export class mod1ecls { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface mod1eint { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export module mod1emod { -//// var mX = 1; -//// function mFunc() { -//// var bar = 1; -//// function foob() { } -//// } -//// class mClass { -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface mInt { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export var meX = 1; -//// export function meFunc() { -//// } -//// export class meClass { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface meInt { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// module mMod { } -//// export module meMod { } -//// } -////} -//// -////// EXTENDING MODULE 1 -////module mod1 { -//// export var mod1eexvar = 1; -//// var mod1exvar = 2; -////} -//// -////module mod2 { -//// var mod2var = "shadow"; -//// function mod2fn() { -//// var bar = 1; -//// function foob() { } -//// } -//// class mod2cls { -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// module mod2mod { } -//// interface mod2int { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export var mod2evar = 1; -//// export function mod2efn() { -//// } -//// export class mod2ecls { -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// export interface mod2eint { -//// (bar: any): any; -//// new (bar: any): any; -//// bar: any; -//// foob(bar: any): any; -//// } -//// export module mod2emod { } -////} -//// -////module mod2 { -//// export var mod2eexvar = 1; -////} -//// -////module mod3 { -//// var shwvar = "shadow"; -//// function shwfn() { -//// var bar = 1; -//// function foob() { } -//// } -//// class shwcls { -//// constructor(public shadow: any) { } -//// private cVar = 1; -//// public cFunc() { } -//// public ceFunc() { } -//// public ceVar = 1; -//// static csVar = 1; -//// static csFunc() { } -//// } -//// interface shwint { -//// (bar: any): any; -//// new (bar: any): any; -//// sivar: string; -//// sifn(shadow: any): any; -//// } -////} -//// -////function shwfn() { -//// var sfvar = 1; -//// function sffn() { } -////} -//// -////class shwcls { -//// private scvar = 1; -//// private scfn() { } -//// public scpfn() { } -//// public scpvar = 1; -//// static scsvar = 1; -//// static scsfn() { } -////} -//// -////interface shwint { -//// (bar: any): any; -//// new (bar: any): any; -//// sivar: any; -//// sifn(bar: any): any; -////} -//// -////var shwvar = 1; -//// -////class extCls extends shwcls { -//// /*extendedClass*/ -////} -//// -////function shwFnTest() { -//// function shwFnTest { -//// -//// } -//// var shwvar = "1"; -//// /*localVar*/ -////} -//// -////var obj = { -//// x: /*objectLiteral*/ -////} - -function goToMarkerAndVerify(marker: string) -{ - goTo.marker(marker); - - verify.completionListContains('mod1'); - verify.completionListContains('mod2'); - verify.completionListContains('mod3'); - verify.completionListContains('shwvar', '(var) shwvar: number'); - verify.completionListContains('shwfn', '(function) shwfn(): void'); - verify.completionListContains('shwcls', 'class shwcls'); - verify.completionListContains('shwint', 'interface shwint'); - - verify.not.completionListContains('mod2var'); - verify.not.completionListContains('mod2fn'); - verify.not.completionListContains('mod2cls'); - verify.not.completionListContains('mod2int'); - verify.not.completionListContains('mod2mod'); - verify.not.completionListContains('mod2evar'); - verify.not.completionListContains('mod2efn'); - verify.not.completionListContains('mod2ecls'); - verify.not.completionListContains('mod2eint'); - verify.not.completionListContains('mod2emod'); - verify.not.completionListContains('sfvar'); - verify.not.completionListContains('sffn'); - verify.not.completionListContains('scvar'); - verify.not.completionListContains('scfn'); - verify.not.completionListContains('scpfn'); - verify.not.completionListContains('scpvar'); - verify.not.completionListContains('scsvar'); - verify.not.completionListContains('scsfn'); - verify.not.completionListContains('sivar'); - verify.not.completionListContains('sifn'); - verify.not.completionListContains('mod1exvar'); - verify.not.completionListContains('mod2eexvar'); -} - -goToMarkerAndVerify('extendedClass'); - -goToMarkerAndVerify('objectLiteral'); - -goTo.marker('localVar'); +/// + +////module mod1 { +//// var mod1var = 1; +//// function mod1fn() { +//// var bar = 1; +//// function foob() { } +//// } +//// class mod1cls { +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface mod1int { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// module mod1mod { +//// var m1X = 1; +//// function m1Func() { +//// var bar = 1; +//// function foob() { } +//// } +//// class m1Class { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface m1Int { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export var m1eX = 1; +//// export function m1eFunc() { +//// } +//// export class m1eClass { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface m1eInt { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// module m1Mod { } +//// export module m1eMod { } +//// } +//// export var mod1evar = 1; +//// export function mod1efn() { +//// var bar = 1; +//// function foob() { } +//// } +//// export class mod1ecls { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface mod1eint { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export module mod1emod { +//// var mX = 1; +//// function mFunc() { +//// var bar = 1; +//// function foob() { } +//// } +//// class mClass { +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface mInt { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export var meX = 1; +//// export function meFunc() { +//// } +//// export class meClass { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface meInt { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// module mMod { } +//// export module meMod { } +//// } +////} +//// +////// EXTENDING MODULE 1 +////module mod1 { +//// export var mod1eexvar = 1; +//// var mod1exvar = 2; +////} +//// +////module mod2 { +//// var mod2var = "shadow"; +//// function mod2fn() { +//// var bar = 1; +//// function foob() { } +//// } +//// class mod2cls { +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// module mod2mod { } +//// interface mod2int { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export var mod2evar = 1; +//// export function mod2efn() { +//// } +//// export class mod2ecls { +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// export interface mod2eint { +//// (bar: any): any; +//// new (bar: any): any; +//// bar: any; +//// foob(bar: any): any; +//// } +//// export module mod2emod { } +////} +//// +////module mod2 { +//// export var mod2eexvar = 1; +////} +//// +////module mod3 { +//// var shwvar = "shadow"; +//// function shwfn() { +//// var bar = 1; +//// function foob() { } +//// } +//// class shwcls { +//// constructor(public shadow: any) { } +//// private cVar = 1; +//// public cFunc() { } +//// public ceFunc() { } +//// public ceVar = 1; +//// static csVar = 1; +//// static csFunc() { } +//// } +//// interface shwint { +//// (bar: any): any; +//// new (bar: any): any; +//// sivar: string; +//// sifn(shadow: any): any; +//// } +////} +//// +////function shwfn() { +//// var sfvar = 1; +//// function sffn() { } +////} +//// +////class shwcls { +//// private scvar = 1; +//// private scfn() { } +//// public scpfn() { } +//// public scpvar = 1; +//// static scsvar = 1; +//// static scsfn() { } +////} +//// +////interface shwint { +//// (bar: any): any; +//// new (bar: any): any; +//// sivar: any; +//// sifn(bar: any): any; +////} +//// +////var shwvar = 1; +//// +////class extCls extends shwcls { +//// /*extendedClass*/ +////} +//// +////function shwFnTest() { +//// function shwFnTest { +//// +//// } +//// var shwvar = "1"; +//// /*localVar*/ +////} +//// +////var obj = { +//// x: /*objectLiteral*/ +////} + +function goToMarkerAndVerify(marker: string) +{ + goTo.marker(marker); + + verify.completionListContains('mod1'); + verify.completionListContains('mod2'); + verify.completionListContains('mod3'); + verify.completionListContains('shwvar', '(var) shwvar: number'); + verify.completionListContains('shwfn', '(function) shwfn(): void'); + verify.completionListContains('shwcls', 'class shwcls'); + verify.completionListContains('shwint', 'interface shwint'); + + verify.not.completionListContains('mod2var'); + verify.not.completionListContains('mod2fn'); + verify.not.completionListContains('mod2cls'); + verify.not.completionListContains('mod2int'); + verify.not.completionListContains('mod2mod'); + verify.not.completionListContains('mod2evar'); + verify.not.completionListContains('mod2efn'); + verify.not.completionListContains('mod2ecls'); + verify.not.completionListContains('mod2eint'); + verify.not.completionListContains('mod2emod'); + verify.not.completionListContains('sfvar'); + verify.not.completionListContains('sffn'); + verify.not.completionListContains('scvar'); + verify.not.completionListContains('scfn'); + verify.not.completionListContains('scpfn'); + verify.not.completionListContains('scpvar'); + verify.not.completionListContains('scsvar'); + verify.not.completionListContains('scsfn'); + verify.not.completionListContains('sivar'); + verify.not.completionListContains('sifn'); + verify.not.completionListContains('mod1exvar'); + verify.not.completionListContains('mod2eexvar'); +} + +goToMarkerAndVerify('extendedClass'); + +goToMarkerAndVerify('objectLiteral'); + +goTo.marker('localVar'); verify.completionListContains('shwvar', '(local var) shwvar: string'); \ No newline at end of file diff --git a/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts b/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts index 693f9698da1..ec2ae9b3c22 100644 --- a/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts +++ b/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts @@ -1,21 +1,21 @@ -/// - -////interface ig { -//// module(data): ig; -//// requires(data): ig; -//// defines(data): ig; -////} -//// -////var ig: ig; -////ig.module( -//// 'mything' -////).requires( -//// 'otherstuff' -////).defines(/*0*//*1*/ -////}); - -goTo.marker("1"); -edit.insert("\r\n"); -goTo.marker("0"); -// Won't-fixed: Smart indent during chained function calls +/// + +////interface ig { +//// module(data): ig; +//// requires(data): ig; +//// defines(data): ig; +////} +//// +////var ig: ig; +////ig.module( +//// 'mything' +////).requires( +//// 'otherstuff' +////).defines(/*0*//*1*/ +////}); + +goTo.marker("1"); +edit.insert("\r\n"); +goTo.marker("0"); +// Won't-fixed: Smart indent during chained function calls verify.indentationIs(4); \ No newline at end of file diff --git a/tests/cases/fourslash/consistenceOnIndentionsOfObjectsInAListAfterFormatting.ts b/tests/cases/fourslash/consistenceOnIndentionsOfObjectsInAListAfterFormatting.ts index 310f91915db..14ada206026 100644 --- a/tests/cases/fourslash/consistenceOnIndentionsOfObjectsInAListAfterFormatting.ts +++ b/tests/cases/fourslash/consistenceOnIndentionsOfObjectsInAListAfterFormatting.ts @@ -1,11 +1,11 @@ -/// - -////foo({ -////}, {/*1*/ -////});/*2*/ - -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("}, {"); -goTo.marker("2"); +/// + +////foo({ +////}, {/*1*/ +////});/*2*/ + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("}, {"); +goTo.marker("2"); verify.currentLineContentIs(" });"); \ No newline at end of file diff --git a/tests/cases/fourslash/consistentContextualTypeErrorsAfterEdits.ts b/tests/cases/fourslash/consistentContextualTypeErrorsAfterEdits.ts index 7e434c6bb89..03024ce0020 100644 --- a/tests/cases/fourslash/consistentContextualTypeErrorsAfterEdits.ts +++ b/tests/cases/fourslash/consistentContextualTypeErrorsAfterEdits.ts @@ -1,5 +1,5 @@ -/// - +/// + //// class A { //// foo: string; //// } diff --git a/tests/cases/fourslash/contextualTypingGenericFunction1.ts b/tests/cases/fourslash/contextualTypingGenericFunction1.ts index c7e409820d4..0216f713cf7 100644 --- a/tests/cases/fourslash/contextualTypingGenericFunction1.ts +++ b/tests/cases/fourslash/contextualTypingGenericFunction1.ts @@ -4,10 +4,10 @@ ////var obj: { f(x: T): T } = { f: (/*1*/x) => x }; ////var obj2: (x: T) => T = (/*2*/x) => x; //// -////class C { -//// obj: (x: T) => T -////} -////var c = new C(); +////class C { +//// obj: (x: T) => T +////} +////var c = new C(); ////c.obj = (/*3*/x) => x; goTo.marker('1'); diff --git a/tests/cases/fourslash/definition.ts b/tests/cases/fourslash/definition.ts index 531e4562843..f403965fe12 100644 --- a/tests/cases/fourslash/definition.ts +++ b/tests/cases/fourslash/definition.ts @@ -1,4 +1,4 @@ -/// +/// // @Filename: b.ts ////import n = require('a/*1*/'); diff --git a/tests/cases/fourslash/deleteExtensionInReopenedInterface.ts b/tests/cases/fourslash/deleteExtensionInReopenedInterface.ts index 13c3498e71e..1fd0a99e0ac 100644 --- a/tests/cases/fourslash/deleteExtensionInReopenedInterface.ts +++ b/tests/cases/fourslash/deleteExtensionInReopenedInterface.ts @@ -1,24 +1,24 @@ -/// - -//// interface A { a: number; } -//// interface B { b: number; } -//// -//// interface I /*del*/extends A { } -//// interface I extends B { } -//// -//// var i: I; -//// class C /*delImplements*/implements A { } -//// var c: C; -//// c.a; - -goTo.marker('del'); -edit.deleteAtCaret('extends A'.length); - -goTo.eof(); -edit.insert("var a = i.a;"); - -goTo.marker('delImplements'); -edit.deleteAtCaret('implements A'.length); - -goTo.marker('del'); +/// + +//// interface A { a: number; } +//// interface B { b: number; } +//// +//// interface I /*del*/extends A { } +//// interface I extends B { } +//// +//// var i: I; +//// class C /*delImplements*/implements A { } +//// var c: C; +//// c.a; + +goTo.marker('del'); +edit.deleteAtCaret('extends A'.length); + +goTo.eof(); +edit.insert("var a = i.a;"); + +goTo.marker('delImplements'); +edit.deleteAtCaret('implements A'.length); + +goTo.marker('del'); edit.insert('extends A'); \ No newline at end of file diff --git a/tests/cases/fourslash/deleteModifierBeforeVarStatement1.ts b/tests/cases/fourslash/deleteModifierBeforeVarStatement1.ts index 803d6bf66ce..a929e67687f 100644 --- a/tests/cases/fourslash/deleteModifierBeforeVarStatement1.ts +++ b/tests/cases/fourslash/deleteModifierBeforeVarStatement1.ts @@ -1,64 +1,64 @@ -/// - -//// -//// -//// ///////////////////////////// -//// /// Windows Script Host APIS -//// ///////////////////////////// -//// -//// declare var ActiveXObject: { new (s: string): any; }; -//// -//// interface ITextWriter { -//// WriteLine(s): void; -//// } -//// -//// declare var WScript: { -//// Echo(s): void; -//// StdErr: ITextWriter; -//// Arguments: { length: number; Item(): string; }; -//// ScriptFullName: string; -//// Quit(): number; -//// } -//// - - -goTo.file(0); - -// : -// : |--- go here -// 1: -// 2: -goTo.position(0); - -// : -// : |--- delete "\n\n///..." -// 1: -// 2: -debugger; -edit.deleteAtCaret(100); - - -// 12: -// : |--- go here -// 13: declare var WScript: { -// 14: Echo(s): void; -goTo.position(198); - -// 12: -// : |--- delete "declare..." -// 13: declare var WScript: { -// 14: Echo(s): void; -edit.deleteAtCaret(16); - - -// 9: StdErr: ITextWriter; -// : |--- go here -// 10: Arguments: { length: number; Item(): string; }; -// 11: ScriptFullName: string; -goTo.position(198); - -// 9: StdErr: ITextWriter; -// : |--- insert "Item(): string; " -// 10: Arguments: { length: number; Item(): string; }; -// 11: ScriptFullName: string; -edit.insert("Item(): string; "); +/// + +//// +//// +//// ///////////////////////////// +//// /// Windows Script Host APIS +//// ///////////////////////////// +//// +//// declare var ActiveXObject: { new (s: string): any; }; +//// +//// interface ITextWriter { +//// WriteLine(s): void; +//// } +//// +//// declare var WScript: { +//// Echo(s): void; +//// StdErr: ITextWriter; +//// Arguments: { length: number; Item(): string; }; +//// ScriptFullName: string; +//// Quit(): number; +//// } +//// + + +goTo.file(0); + +// : +// : |--- go here +// 1: +// 2: +goTo.position(0); + +// : +// : |--- delete "\n\n///..." +// 1: +// 2: +debugger; +edit.deleteAtCaret(100); + + +// 12: +// : |--- go here +// 13: declare var WScript: { +// 14: Echo(s): void; +goTo.position(198); + +// 12: +// : |--- delete "declare..." +// 13: declare var WScript: { +// 14: Echo(s): void; +edit.deleteAtCaret(16); + + +// 9: StdErr: ITextWriter; +// : |--- go here +// 10: Arguments: { length: number; Item(): string; }; +// 11: ScriptFullName: string; +goTo.position(198); + +// 9: StdErr: ITextWriter; +// : |--- insert "Item(): string; " +// 10: Arguments: { length: number; Item(): string; }; +// 11: ScriptFullName: string; +edit.insert("Item(): string; "); diff --git a/tests/cases/fourslash/deleteTypeParameter.ts b/tests/cases/fourslash/deleteTypeParameter.ts index c3d2236813c..4c70d61580a 100644 --- a/tests/cases/fourslash/deleteTypeParameter.ts +++ b/tests/cases/fourslash/deleteTypeParameter.ts @@ -9,6 +9,6 @@ //// var q1: Query; //// var q2: Query2; //// q1 = q2; - -goTo.marker(); -edit.deleteAtCaret(1); + +goTo.marker(); +edit.deleteAtCaret(1); diff --git a/tests/cases/fourslash/duplicateClassModuleError0.ts b/tests/cases/fourslash/duplicateClassModuleError0.ts index e133ba70e93..a6d63ba5277 100644 --- a/tests/cases/fourslash/duplicateClassModuleError0.ts +++ b/tests/cases/fourslash/duplicateClassModuleError0.ts @@ -1,25 +1,25 @@ -/// - -//// module A -//// { -//// class B -//// { -//// public Hello(): string -//// { -//// return "from private B"; -//// } -//// } -//// } -//// -//// module A -//// { -//// /*1*/ -//// } - -edit.disableFormatting(); - -goTo.marker("1"); - -edit.insert(" export class B\n {\n public Hello(): string\n {\n return \"from export B\";\n }\n }\n"); - -edit.insert("\n"); +/// + +//// module A +//// { +//// class B +//// { +//// public Hello(): string +//// { +//// return "from private B"; +//// } +//// } +//// } +//// +//// module A +//// { +//// /*1*/ +//// } + +edit.disableFormatting(); + +goTo.marker("1"); + +edit.insert(" export class B\n {\n public Hello(): string\n {\n return \"from export B\";\n }\n }\n"); + +edit.insert("\n"); diff --git a/tests/cases/fourslash/duplicateTypeParameters.ts b/tests/cases/fourslash/duplicateTypeParameters.ts index 40b0441606e..a7cdebe1153 100644 --- a/tests/cases/fourslash/duplicateTypeParameters.ts +++ b/tests/cases/fourslash/duplicateTypeParameters.ts @@ -1,7 +1,7 @@ -/// - +/// + //// class A { } - -goTo.marker(); -verify.quickInfoExists(); - + +goTo.marker(); +verify.quickInfoExists(); + diff --git a/tests/cases/fourslash/eval.ts b/tests/cases/fourslash/eval.ts index e9ee90b768b..db1077a0b10 100644 --- a/tests/cases/fourslash/eval.ts +++ b/tests/cases/fourslash/eval.ts @@ -1,14 +1,14 @@ -/// - -////class SomeObj { -//// public n = 5; -//// -//// public getCallback() { -//// return () => this.n; -//// } -////} -//// -////var x = new SomeObj(); -////var y = x.getCallback()(); - -verify.eval('y', 5); +/// + +////class SomeObj { +//// public n = 5; +//// +//// public getCallback() { +//// return () => this.n; +//// } +////} +//// +////var x = new SomeObj(); +////var y = x.getCallback()(); + +verify.eval('y', 5); diff --git a/tests/cases/fourslash/exportClauseErrorReporting0.ts b/tests/cases/fourslash/exportClauseErrorReporting0.ts index 75490500d87..a931c3ff130 100644 --- a/tests/cases/fourslash/exportClauseErrorReporting0.ts +++ b/tests/cases/fourslash/exportClauseErrorReporting0.ts @@ -1,16 +1,16 @@ -/// - -//// module M { -//// /*1*/class C { } -//// } -//// -//// var x = new M.C(); -//// - -edit.disableFormatting(); - -goTo.marker("1"); -edit.insert("export "); -goTo.marker("1"); - -edit.deleteAtCaret(8); +/// + +//// module M { +//// /*1*/class C { } +//// } +//// +//// var x = new M.C(); +//// + +edit.disableFormatting(); + +goTo.marker("1"); +edit.insert("export "); +goTo.marker("1"); + +edit.deleteAtCaret(8); diff --git a/tests/cases/fourslash/failureToImplementClass.ts b/tests/cases/fourslash/failureToImplementClass.ts index d6942f87117..345a8d94111 100644 --- a/tests/cases/fourslash/failureToImplementClass.ts +++ b/tests/cases/fourslash/failureToImplementClass.ts @@ -1,9 +1,9 @@ -/// - -////interface IExec { -//// exec: (filename: string, cmdLine: string) => boolean; -////} -////class /*1*/NodeExec/*2*/ implements IExec { } - -verify.errorExistsBetweenMarkers("1", "2"); +/// + +////interface IExec { +//// exec: (filename: string, cmdLine: string) => boolean; +////} +////class /*1*/NodeExec/*2*/ implements IExec { } + +verify.errorExistsBetweenMarkers("1", "2"); verify.numberOfErrorsInCurrentFile(1); \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts index 76adc714b2c..afcaf625ede 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts @@ -1,4 +1,4 @@ -/// +/// ////function [|__foo|]() { //// [|__foo|](); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts index d25d6335f2b..08ed3414366 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts @@ -1,4 +1,4 @@ -/// +/// ////(function [|__foo|]() { //// [|__foo|](); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts index 295344d23f9..a3923783c46 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts @@ -1,4 +1,4 @@ -/// +/// ////(function [|___foo|]() { //// [|___foo|](); diff --git a/tests/cases/fourslash/formatArrayOrObjectLiteralsInVariableList.ts b/tests/cases/fourslash/formatArrayOrObjectLiteralsInVariableList.ts index 8de0a6a2458..40ad89c4203 100644 --- a/tests/cases/fourslash/formatArrayOrObjectLiteralsInVariableList.ts +++ b/tests/cases/fourslash/formatArrayOrObjectLiteralsInVariableList.ts @@ -1,7 +1,7 @@ -/// - -////var v30 = [1, 2], v31, v32, v33 = [0], v34 = {'a': true}, v35;/**/ - -format.document(); -goTo.marker(""); +/// + +////var v30 = [1, 2], v31, v32, v33 = [0], v34 = {'a': true}, v35;/**/ + +format.document(); +goTo.marker(""); verify.currentLineContentIs("var v30 = [1, 2], v31, v32, v33 = [0], v34 = { 'a': true }, v35;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatColonAndQMark.ts b/tests/cases/fourslash/formatColonAndQMark.ts index 4a2b956ee1d..856c9941117 100644 --- a/tests/cases/fourslash/formatColonAndQMark.ts +++ b/tests/cases/fourslash/formatColonAndQMark.ts @@ -1,16 +1,16 @@ -/// - -////class foo {/*1*/ -//// constructor (n?: number, m = 5, o?: string) { }/*2*/ -//// x:number = 1?2:3;/*3*/ -////}/*4*/ - -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("class foo {"); -goTo.marker("2"); -verify.currentLineContentIs(" constructor(n?: number, m = 5, o?: string) { }"); -goTo.marker("3"); -verify.currentLineContentIs(" x: number = 1 ? 2 : 3;"); -goTo.marker("4"); +/// + +////class foo {/*1*/ +//// constructor (n?: number, m = 5, o?: string) { }/*2*/ +//// x:number = 1?2:3;/*3*/ +////}/*4*/ + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("class foo {"); +goTo.marker("2"); +verify.currentLineContentIs(" constructor(n?: number, m = 5, o?: string) { }"); +goTo.marker("3"); +verify.currentLineContentIs(" x: number = 1 ? 2 : 3;"); +goTo.marker("4"); verify.currentLineContentIs("}"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatControlFlowConstructs.ts b/tests/cases/fourslash/formatControlFlowConstructs.ts index 853df75115a..001a708c649 100644 --- a/tests/cases/fourslash/formatControlFlowConstructs.ts +++ b/tests/cases/fourslash/formatControlFlowConstructs.ts @@ -1,9 +1,9 @@ -/// +/// ////if (true)/**/ ////{ -////} - -format.document(); -goTo.marker(); +////} + +format.document(); +goTo.marker(); verify.currentLineContentIs("if (true) {"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatDebuggerStatement.ts b/tests/cases/fourslash/formatDebuggerStatement.ts index 82175ef3f94..f91359f76f6 100644 --- a/tests/cases/fourslash/formatDebuggerStatement.ts +++ b/tests/cases/fourslash/formatDebuggerStatement.ts @@ -1,10 +1,10 @@ -/// - -////if(false){debugger;} -//// if ( false ) { debugger ; } - -format.document(); -goTo.bof(); -verify.currentLineContentIs("if (false) { debugger; }"); -goTo.eof(); +/// + +////if(false){debugger;} +//// if ( false ) { debugger ; } + +format.document(); +goTo.bof(); +verify.currentLineContentIs("if (false) { debugger; }"); +goTo.eof(); verify.currentLineContentIs("if (false) { debugger; }"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatEmptyBlock.ts b/tests/cases/fourslash/formatEmptyBlock.ts index c65a2d607d0..565dbc6257c 100644 --- a/tests/cases/fourslash/formatEmptyBlock.ts +++ b/tests/cases/fourslash/formatEmptyBlock.ts @@ -1,8 +1,8 @@ -/// - -////{} - -goTo.eof(); -edit.insert("\r\n"); -goTo.bof(); +/// + +////{} + +goTo.eof(); +edit.insert("\r\n"); +goTo.bof(); verify.currentLineContentIs("{ }"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatEmptyParamList.ts b/tests/cases/fourslash/formatEmptyParamList.ts index 5b207581d61..a5372010baa 100644 --- a/tests/cases/fourslash/formatEmptyParamList.ts +++ b/tests/cases/fourslash/formatEmptyParamList.ts @@ -1,5 +1,5 @@ -/// -////function f( f: function){/*1*/ -goTo.marker("1"); -edit.insert("}"); +/// +////function f( f: function){/*1*/ +goTo.marker("1"); +edit.insert("}"); verify.currentLineContentIs("function f(f: function){ }") \ No newline at end of file diff --git a/tests/cases/fourslash/formatImplicitModule.ts b/tests/cases/fourslash/formatImplicitModule.ts index 22583940d6e..22a933ce031 100644 --- a/tests/cases/fourslash/formatImplicitModule.ts +++ b/tests/cases/fourslash/formatImplicitModule.ts @@ -1,11 +1,11 @@ -/// - -//// export class A { -//// -//// } - -format.document(); -goTo.bof(); -verify.currentLineContentIs("export class A {"); -goTo.eof(); +/// + +//// export class A { +//// +//// } + +format.document(); +goTo.bof(); +verify.currentLineContentIs("export class A {"); +goTo.eof(); verify.currentLineContentIs("}"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatImportDeclaration.ts b/tests/cases/fourslash/formatImportDeclaration.ts index 4dc26fd5bc6..09c3e95964c 100644 --- a/tests/cases/fourslash/formatImportDeclaration.ts +++ b/tests/cases/fourslash/formatImportDeclaration.ts @@ -1,18 +1,18 @@ -/// - -////module Foo {/*1*/ -////}/*2*/ -//// -////import bar = Foo;/*3*/ -//// -////import bar2=Foo;/*4*/ - -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("module Foo {"); -goTo.marker("2"); -verify.currentLineContentIs("}"); -goTo.marker("3"); -verify.currentLineContentIs("import bar = Foo;"); -goTo.marker("4"); +/// + +////module Foo {/*1*/ +////}/*2*/ +//// +////import bar = Foo;/*3*/ +//// +////import bar2=Foo;/*4*/ + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("module Foo {"); +goTo.marker("2"); +verify.currentLineContentIs("}"); +goTo.marker("3"); +verify.currentLineContentIs("import bar = Foo;"); +goTo.marker("4"); verify.currentLineContentIs("import bar2 = Foo;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatNestedClassWithOpenBraceOnNewLines.ts b/tests/cases/fourslash/formatNestedClassWithOpenBraceOnNewLines.ts index 2f3157a2833..028fc349b39 100644 --- a/tests/cases/fourslash/formatNestedClassWithOpenBraceOnNewLines.ts +++ b/tests/cases/fourslash/formatNestedClassWithOpenBraceOnNewLines.ts @@ -1,21 +1,21 @@ -/// - -////module A -////{ -//// class B { -//// /*1*/ -////} - -format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", true); -format.setOption("PlaceOpenBraceOnNewLineForFunctions", true); -goTo.marker("1"); -edit.insert("}"); - -verify.currentFileContentIs( -"module A\n\ -{\n\ - class B\n\ - {\n\ - }\n\ -}" +/// + +////module A +////{ +//// class B { +//// /*1*/ +////} + +format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", true); +format.setOption("PlaceOpenBraceOnNewLineForFunctions", true); +goTo.marker("1"); +edit.insert("}"); + +verify.currentFileContentIs( +"module A\n\ +{\n\ + class B\n\ + {\n\ + }\n\ +}" ); \ No newline at end of file diff --git a/tests/cases/fourslash/formatSelectionWithTrivia.ts b/tests/cases/fourslash/formatSelectionWithTrivia.ts index 3aae18d9204..ff399642745 100644 --- a/tests/cases/fourslash/formatSelectionWithTrivia.ts +++ b/tests/cases/fourslash/formatSelectionWithTrivia.ts @@ -1,13 +1,13 @@ -/// +/// ////if (true) { -//// // -//// /*begin*/ -//// // -//// ; -//// -//// }/*end*/ - -format.selection('begin', 'end'); - -verify.currentFileContentIs("if (true) { \n // \n\n // \n ;\n\n}"); +//// // +//// /*begin*/ +//// // +//// ; +//// +//// }/*end*/ + +format.selection('begin', 'end'); + +verify.currentFileContentIs("if (true) { \n // \n\n // \n ;\n\n}"); diff --git a/tests/cases/fourslash/formatVariableDeclarationList.ts b/tests/cases/fourslash/formatVariableDeclarationList.ts index 6d1b6e0ac5a..37392d38c62 100644 --- a/tests/cases/fourslash/formatVariableDeclarationList.ts +++ b/tests/cases/fourslash/formatVariableDeclarationList.ts @@ -1,40 +1,40 @@ -/// - -/////*1*/var fun1 = function ( ) { -/////*2*/ var x = 'foo' , -/////*3*/ z = 'bar' ; -/////*4*/ return x ; -/////*5*/}, -//// -/////*6*/fun2 = ( function ( f ) { -/////*7*/ var fun = function ( ) { -/////*8*/ console . log ( f ( ) ) ; -/////*9*/ }, -/////*10*/ x = 'Foo' ; -/////*11*/ return fun ; -/////*12*/} ( fun1 ) ) ; -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("var fun1 = function() {"); -goTo.marker("2"); -verify.currentLineContentIs(" var x = 'foo',"); -goTo.marker("3"); -verify.currentLineContentIs(" z = 'bar';"); -goTo.marker("4"); -verify.currentLineContentIs(" return x;"); -goTo.marker("5"); -verify.currentLineContentIs("},"); -goTo.marker("6"); -verify.currentLineContentIs(" fun2 = (function(f) {"); -goTo.marker("7"); -verify.currentLineContentIs(" var fun = function() {"); -goTo.marker("8"); -verify.currentLineContentIs(" console.log(f());"); -goTo.marker("9"); -verify.currentLineContentIs(" },"); -goTo.marker("10"); -verify.currentLineContentIs(" x = 'Foo';"); -goTo.marker("11"); -verify.currentLineContentIs(" return fun;"); -goTo.marker("12"); -verify.currentLineContentIs(" } (fun1));"); +/// + +/////*1*/var fun1 = function ( ) { +/////*2*/ var x = 'foo' , +/////*3*/ z = 'bar' ; +/////*4*/ return x ; +/////*5*/}, +//// +/////*6*/fun2 = ( function ( f ) { +/////*7*/ var fun = function ( ) { +/////*8*/ console . log ( f ( ) ) ; +/////*9*/ }, +/////*10*/ x = 'Foo' ; +/////*11*/ return fun ; +/////*12*/} ( fun1 ) ) ; +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("var fun1 = function() {"); +goTo.marker("2"); +verify.currentLineContentIs(" var x = 'foo',"); +goTo.marker("3"); +verify.currentLineContentIs(" z = 'bar';"); +goTo.marker("4"); +verify.currentLineContentIs(" return x;"); +goTo.marker("5"); +verify.currentLineContentIs("},"); +goTo.marker("6"); +verify.currentLineContentIs(" fun2 = (function(f) {"); +goTo.marker("7"); +verify.currentLineContentIs(" var fun = function() {"); +goTo.marker("8"); +verify.currentLineContentIs(" console.log(f());"); +goTo.marker("9"); +verify.currentLineContentIs(" },"); +goTo.marker("10"); +verify.currentLineContentIs(" x = 'Foo';"); +goTo.marker("11"); +verify.currentLineContentIs(" return fun;"); +goTo.marker("12"); +verify.currentLineContentIs(" } (fun1));"); diff --git a/tests/cases/fourslash/formatWithStatement.ts b/tests/cases/fourslash/formatWithStatement.ts index 410b8f5601f..bc5ddf38443 100644 --- a/tests/cases/fourslash/formatWithStatement.ts +++ b/tests/cases/fourslash/formatWithStatement.ts @@ -1,15 +1,15 @@ -/// - -////with /*1*/(foo.bar) -//// -//// {/*2*/ -//// -//// }/*3*/ -//// -////with (bar.blah)/*4*/ -////{/*5*/ -////}/*6*/ - +/// + +////with /*1*/(foo.bar) +//// +//// {/*2*/ +//// +//// }/*3*/ +//// +////with (bar.blah)/*4*/ +////{/*5*/ +////}/*6*/ + format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", false); format.document(); goTo.marker("1"); @@ -19,15 +19,15 @@ verify.currentLineContentIs("}"); goTo.marker("4"); verify.currentLineContentIs("with (bar.blah) {"); goTo.marker("6"); -verify.currentLineContentIs("}"); - -format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", true); -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("with (foo.bar)"); -goTo.marker("2"); -verify.currentLineContentIs("{"); -goTo.marker("4"); -verify.currentLineContentIs("with (bar.blah)"); -goTo.marker("5"); +verify.currentLineContentIs("}"); + +format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", true); +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("with (foo.bar)"); +goTo.marker("2"); +verify.currentLineContentIs("{"); +goTo.marker("4"); +verify.currentLineContentIs("with (bar.blah)"); +goTo.marker("5"); verify.currentLineContentIs("{"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingFatArrowFunctions.ts b/tests/cases/fourslash/formattingFatArrowFunctions.ts index 73463852a67..c540c2837e1 100644 --- a/tests/cases/fourslash/formattingFatArrowFunctions.ts +++ b/tests/cases/fourslash/formattingFatArrowFunctions.ts @@ -1,290 +1,290 @@ -/// - -////// valid -//// ( ) => 1 ;/*1*/ -//// ( arg ) => 2 ;/*2*/ -//// arg => 2 ;/*3*/ -//// ( arg = 1 ) => 3 ;/*4*/ -//// ( arg ? ) => 4 ;/*5*/ -//// ( arg : number ) => 5 ;/*6*/ -//// ( arg : number = 0 ) => 6 ;/*7*/ -//// ( arg ? : number ) => 7 ;/*8*/ -//// ( ... arg : number [ ] ) => 8 ;/*9*/ -//// ( arg1 , arg2 ) => 12 ;/*10*/ -//// ( arg1 = 1 , arg2 =3 ) => 13 ;/*11*/ -//// ( arg1 ? , arg2 ? ) => 14 ;/*12*/ -//// ( arg1 : number , arg2 : number ) => 15 ;/*13*/ -//// ( arg1 : number = 0 , arg2 : number = 1 ) => 16 ;/*14*/ -//// ( arg1 ? : number , arg2 ? : number ) => 17 ;/*15*/ -//// ( arg1 , ... arg2 : number [ ] ) => 18 ;/*16*/ -//// ( arg1 , arg2 ? : number ) => 19 ;/*17*/ -//// -////// in paren -//// ( ( ) => 21 ) ;/*18*/ -//// ( ( arg ) => 22 ) ;/*19*/ -//// ( ( arg = 1 ) => 23 ) ;/*20*/ -//// ( ( arg ? ) => 24 ) ;/*21*/ -//// ( ( arg : number ) => 25 ) ;/*22*/ -//// ( ( arg : number = 0 ) => 26 ) ;/*23*/ -//// ( ( arg ? : number ) => 27 ) ;/*24*/ -//// ( ( ... arg : number [ ] ) => 28 ) ;/*25*/ -//// -////// in multiple paren -//// ( ( ( ( ( arg ) => { return 32 ; } ) ) ) ) ;/*26*/ -//// -////// in ternary exression -//// false ? ( ) => 41 : null ;/*27*/ -//// false ? ( arg ) => 42 : null ;/*28*/ -//// false ? ( arg = 1 ) => 43 : null ;/*29*/ -//// false ? ( arg ? ) => 44 : null ;/*30*/ -//// false ? ( arg : number ) => 45 : null ;/*31*/ -//// false ? ( arg ? : number ) => 46 : null ;/*32*/ -//// false ? ( arg ? : number = 0 ) => 47 : null ;/*33*/ -//// false ? ( ... arg : number [ ] ) => 48 : null ;/*34*/ -//// -////// in ternary exression within paren -//// false ? ( ( ) => 51 ) : null ;/*35*/ -//// false ? ( ( arg ) => 52 ) : null ;/*36*/ -//// false ? ( ( arg = 1 ) => 53 ) : null ;/*37*/ -//// false ? ( ( arg ? ) => 54 ) : null ;/*38*/ -//// false ? ( ( arg : number ) => 55 ) : null ;/*39*/ -//// false ? ( ( arg ? : number ) => 56 ) : null ;/*40*/ -//// false ? ( ( arg ? : number = 0 ) => 57 ) : null ;/*41*/ -//// false ? ( ( ... arg : number [ ] ) => 58 ) : null ;/*42*/ -//// -////// ternary exression's else clause -//// false ? null : ( ) => 61 ;/*43*/ -//// false ? null : ( arg ) => 62 ;/*44*/ -//// false ? null : ( arg = 1 ) => 63 ;/*45*/ -//// false ? null : ( arg ? ) => 64 ;/*46*/ -//// false ? null : ( arg : number ) => 65 ;/*47*/ -//// false ? null : ( arg ? : number ) => 66 ;/*48*/ -//// false ? null : ( arg ? : number = 0 ) => 67 ;/*49*/ -//// false ? null : ( ... arg : number [ ] ) => 68 ;/*50*/ -//// -//// -////// nested ternary expressions -//// (( a ? ) => { return a ; }) ? ( b ? ) => { return b ; } : ( c ? ) => { return c ; } ;/*51*/ -//// -//////multiple levels -//// (( a ? ) => { return a ; }) ? ( b ) => ( c ) => 81 : ( c ) => ( d ) => 82 ;/*52*/ -//// -//// -////// In Expressions -//// ( ( arg ) => 90 ) instanceof Function ;/*53*/ -//// ( ( arg = 1 ) => 91 ) instanceof Function ;/*54*/ -//// ( ( arg ? ) => 92 ) instanceof Function ;/*55*/ -//// ( ( arg : number ) => 93 ) instanceof Function ;/*56*/ -//// ( ( arg : number = 1 ) => 94 ) instanceof Function ;/*57*/ -//// ( ( arg ? : number ) => 95 ) instanceof Function ;/*58*/ -//// ( ( ... arg : number [ ] ) => 96 ) instanceof Function ;/*59*/ -//// -////'' + (( arg ) => 100) ;/*60*/ -//// ( ( arg ) => 0 ) + '' + (( arg ) => 101) ;/*61*/ -//// ( ( arg = 1 ) => 0 ) + '' + (( arg = 2 ) => 102) ;/*62*/ -//// ( ( arg ? ) => 0 ) + '' + (( arg ? ) => 103) ;/*63*/ -//// ( ( arg : number ) => 0 ) + '' + (( arg : number ) => 104) ;/*64*/ -//// ( ( arg : number = 1 ) => 0 ) + '' + (( arg : number = 2 ) => 105) ;/*65*/ -//// ( ( arg ? : number ) => 0 ) + '' + (( arg ? : number ) => 106) ;/*66*/ -//// ( ( ... arg : number [ ] ) => 0 ) + '' + (( ... arg : number [ ] ) => 107) ;/*67*/ -//// ( ( arg1 , arg2 ? ) => 0 ) + '' + (( arg1 , arg2 ? ) => 108) ;/*68*/ -//// ( ( arg1 , ... arg2 : number [ ] ) => 0 ) + '' + (( arg1 , ... arg2 : number [ ] ) => 108) ;/*69*/ -//// -//// -////// Function Parameters -/////*70*/function foo ( ... arg : any [ ] ) { } -//// -/////*71*/foo ( -/////*72*/ ( a ) => 110 , -/////*73*/ ( ( a ) => 111 ) , -/////*74*/ ( a ) => { -//// return /*75*/112 ; -/////*76*/ } , -/////*77*/ ( a ? ) => 113 , -/////*78*/ ( a , b ? ) => 114 , -/////*79*/ ( a : number ) => 115 , -/////*80*/ ( a : number = 0 ) => 116 , -/////*81*/ ( a = 0 ) => 117 , -/////*82*/ ( a : number = 0 ) => 118 , -/////*83*/ ( a ? , b ? : number ) => 118 , -/////*84*/ ( ... a : number [ ] ) => 119 , -/////*85*/ ( a , b = 0 , ... c : number [ ] ) => 120 , -/////*86*/ ( a ) => ( b ) => ( c ) => 121 , -/////*87*/ false ? ( a ) => 0 : ( b ) => 122 -//// /*88*/) ; -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("() => 1;"); -goTo.marker("2"); -verify.currentLineContentIs("(arg) => 2;"); -goTo.marker("3"); -verify.currentLineContentIs("arg => 2;"); -goTo.marker("4"); -verify.currentLineContentIs("(arg = 1) => 3;"); -goTo.marker("5"); -verify.currentLineContentIs("(arg?) => 4;"); -goTo.marker("6"); -verify.currentLineContentIs("(arg: number) => 5;"); -goTo.marker("7"); -verify.currentLineContentIs("(arg: number = 0) => 6;"); -goTo.marker("8"); -verify.currentLineContentIs("(arg?: number) => 7;"); -goTo.marker("9"); -verify.currentLineContentIs("(...arg: number[]) => 8;"); -goTo.marker("10"); -verify.currentLineContentIs("(arg1, arg2) => 12;"); -goTo.marker("11"); -verify.currentLineContentIs("(arg1 = 1, arg2 = 3) => 13;"); -goTo.marker("12"); -verify.currentLineContentIs("(arg1?, arg2?) => 14;"); -goTo.marker("13"); -verify.currentLineContentIs("(arg1: number, arg2: number) => 15;"); -goTo.marker("14"); -verify.currentLineContentIs("(arg1: number = 0, arg2: number = 1) => 16;"); -goTo.marker("15"); -verify.currentLineContentIs("(arg1?: number, arg2?: number) => 17;"); -goTo.marker("16"); -verify.currentLineContentIs("(arg1, ...arg2: number[]) => 18;"); -goTo.marker("17"); -verify.currentLineContentIs("(arg1, arg2?: number) => 19;"); -goTo.marker("18"); -verify.currentLineContentIs("(() => 21);"); -goTo.marker("19"); -verify.currentLineContentIs("((arg) => 22);"); -goTo.marker("20"); -verify.currentLineContentIs("((arg = 1) => 23);"); -goTo.marker("21"); -verify.currentLineContentIs("((arg?) => 24);"); -goTo.marker("22"); -verify.currentLineContentIs("((arg: number) => 25);"); -goTo.marker("23"); -verify.currentLineContentIs("((arg: number = 0) => 26);"); -goTo.marker("24"); -verify.currentLineContentIs("((arg?: number) => 27);"); -goTo.marker("25"); -verify.currentLineContentIs("((...arg: number[]) => 28);"); -goTo.marker("26"); -verify.currentLineContentIs("(((((arg) => { return 32; }))));"); -goTo.marker("27"); -verify.currentLineContentIs("false ? () => 41 : null;"); -goTo.marker("28"); -verify.currentLineContentIs("false ? (arg) => 42 : null;"); -goTo.marker("29"); -verify.currentLineContentIs("false ? (arg = 1) => 43 : null;"); -goTo.marker("30"); -verify.currentLineContentIs("false ? (arg?) => 44 : null;"); -goTo.marker("31"); -verify.currentLineContentIs("false ? (arg: number) => 45 : null;"); -goTo.marker("32"); -verify.currentLineContentIs("false ? (arg?: number) => 46 : null;"); -goTo.marker("33"); -verify.currentLineContentIs("false ? (arg?: number = 0) => 47 : null;"); -goTo.marker("34"); -verify.currentLineContentIs("false ? (...arg: number[]) => 48 : null;"); -goTo.marker("35"); -verify.currentLineContentIs("false ? (() => 51) : null;"); -goTo.marker("36"); -verify.currentLineContentIs("false ? ((arg) => 52) : null;"); -goTo.marker("37"); -verify.currentLineContentIs("false ? ((arg = 1) => 53) : null;"); -goTo.marker("38"); -verify.currentLineContentIs("false ? ((arg?) => 54) : null;"); -goTo.marker("39"); -verify.currentLineContentIs("false ? ((arg: number) => 55) : null;"); -goTo.marker("40"); -verify.currentLineContentIs("false ? ((arg?: number) => 56) : null;"); -goTo.marker("41"); -verify.currentLineContentIs("false ? ((arg?: number = 0) => 57) : null;"); -goTo.marker("42"); -verify.currentLineContentIs("false ? ((...arg: number[]) => 58) : null;"); -goTo.marker("43"); -verify.currentLineContentIs("false ? null : () => 61;"); -goTo.marker("44"); -verify.currentLineContentIs("false ? null : (arg) => 62;"); -goTo.marker("45"); -verify.currentLineContentIs("false ? null : (arg = 1) => 63;"); -goTo.marker("46"); -verify.currentLineContentIs("false ? null : (arg?) => 64;"); -goTo.marker("47"); -verify.currentLineContentIs("false ? null : (arg: number) => 65;"); -goTo.marker("48"); -verify.currentLineContentIs("false ? null : (arg?: number) => 66;"); -goTo.marker("49"); -verify.currentLineContentIs("false ? null : (arg?: number = 0) => 67;"); -goTo.marker("50"); -verify.currentLineContentIs("false ? null : (...arg: number[]) => 68;"); -goTo.marker("51"); -verify.currentLineContentIs("((a?) => { return a; }) ? (b?) => { return b; } : (c?) => { return c; };"); -goTo.marker("52"); -verify.currentLineContentIs("((a?) => { return a; }) ? (b) => (c) => 81 : (c) => (d) => 82;"); -goTo.marker("53"); -verify.currentLineContentIs("((arg) => 90) instanceof Function;"); -goTo.marker("54"); -verify.currentLineContentIs("((arg = 1) => 91) instanceof Function;"); -goTo.marker("55"); -verify.currentLineContentIs("((arg?) => 92) instanceof Function;"); -goTo.marker("56"); -verify.currentLineContentIs("((arg: number) => 93) instanceof Function;"); -goTo.marker("57"); -verify.currentLineContentIs("((arg: number = 1) => 94) instanceof Function;"); -goTo.marker("58"); -verify.currentLineContentIs("((arg?: number) => 95) instanceof Function;"); -goTo.marker("59"); -verify.currentLineContentIs("((...arg: number[]) => 96) instanceof Function;"); -goTo.marker("60"); -verify.currentLineContentIs("'' + ((arg) => 100);"); - -goTo.marker("61"); -verify.currentLineContentIs("((arg) => 0) + '' + ((arg) => 101);"); -goTo.marker("62"); -verify.currentLineContentIs("((arg = 1) => 0) + '' + ((arg = 2) => 102);"); -goTo.marker("63"); -verify.currentLineContentIs("((arg?) => 0) + '' + ((arg?) => 103);"); -goTo.marker("64"); -verify.currentLineContentIs("((arg: number) => 0) + '' + ((arg: number) => 104);"); -goTo.marker("65"); -verify.currentLineContentIs("((arg: number = 1) => 0) + '' + ((arg: number = 2) => 105);"); -goTo.marker("66"); -verify.currentLineContentIs("((arg?: number) => 0) + '' + ((arg?: number) => 106);"); -goTo.marker("67"); -verify.currentLineContentIs("((...arg: number[]) => 0) + '' + ((...arg: number[]) => 107);"); -goTo.marker("68"); -verify.currentLineContentIs("((arg1, arg2?) => 0) + '' + ((arg1, arg2?) => 108);"); -goTo.marker("69"); -verify.currentLineContentIs("((arg1, ...arg2: number[]) => 0) + '' + ((arg1, ...arg2: number[]) => 108);"); -goTo.marker("70"); -verify.currentLineContentIs("function foo(...arg: any[]) { }"); -goTo.marker("71"); -verify.currentLineContentIs("foo("); -goTo.marker("72"); -verify.currentLineContentIs(" (a) => 110,"); -goTo.marker("73"); -verify.currentLineContentIs(" ((a) => 111),"); -goTo.marker("74"); -verify.currentLineContentIs(" (a) => {"); -goTo.marker("75"); -verify.currentLineContentIs(" return 112;"); -goTo.marker("76"); -verify.currentLineContentIs(" },"); -goTo.marker("77"); -verify.currentLineContentIs(" (a?) => 113,"); -goTo.marker("78"); -verify.currentLineContentIs(" (a, b?) => 114,"); -goTo.marker("79"); -verify.currentLineContentIs(" (a: number) => 115,"); -goTo.marker("80"); -verify.currentLineContentIs(" (a: number = 0) => 116,"); -goTo.marker("81"); -verify.currentLineContentIs(" (a = 0) => 117,"); -goTo.marker("82"); -verify.currentLineContentIs(" (a: number = 0) => 118,"); -goTo.marker("83"); -verify.currentLineContentIs(" (a?, b?: number) => 118,"); -goTo.marker("84"); -verify.currentLineContentIs(" (...a: number[]) => 119,"); -goTo.marker("85"); -verify.currentLineContentIs(" (a, b = 0, ...c: number[]) => 120,"); -goTo.marker("86"); -verify.currentLineContentIs(" (a) => (b) => (c) => 121,"); -goTo.marker("87"); -verify.currentLineContentIs(" false ? (a) => 0 : (b) => 122"); +/// + +////// valid +//// ( ) => 1 ;/*1*/ +//// ( arg ) => 2 ;/*2*/ +//// arg => 2 ;/*3*/ +//// ( arg = 1 ) => 3 ;/*4*/ +//// ( arg ? ) => 4 ;/*5*/ +//// ( arg : number ) => 5 ;/*6*/ +//// ( arg : number = 0 ) => 6 ;/*7*/ +//// ( arg ? : number ) => 7 ;/*8*/ +//// ( ... arg : number [ ] ) => 8 ;/*9*/ +//// ( arg1 , arg2 ) => 12 ;/*10*/ +//// ( arg1 = 1 , arg2 =3 ) => 13 ;/*11*/ +//// ( arg1 ? , arg2 ? ) => 14 ;/*12*/ +//// ( arg1 : number , arg2 : number ) => 15 ;/*13*/ +//// ( arg1 : number = 0 , arg2 : number = 1 ) => 16 ;/*14*/ +//// ( arg1 ? : number , arg2 ? : number ) => 17 ;/*15*/ +//// ( arg1 , ... arg2 : number [ ] ) => 18 ;/*16*/ +//// ( arg1 , arg2 ? : number ) => 19 ;/*17*/ +//// +////// in paren +//// ( ( ) => 21 ) ;/*18*/ +//// ( ( arg ) => 22 ) ;/*19*/ +//// ( ( arg = 1 ) => 23 ) ;/*20*/ +//// ( ( arg ? ) => 24 ) ;/*21*/ +//// ( ( arg : number ) => 25 ) ;/*22*/ +//// ( ( arg : number = 0 ) => 26 ) ;/*23*/ +//// ( ( arg ? : number ) => 27 ) ;/*24*/ +//// ( ( ... arg : number [ ] ) => 28 ) ;/*25*/ +//// +////// in multiple paren +//// ( ( ( ( ( arg ) => { return 32 ; } ) ) ) ) ;/*26*/ +//// +////// in ternary exression +//// false ? ( ) => 41 : null ;/*27*/ +//// false ? ( arg ) => 42 : null ;/*28*/ +//// false ? ( arg = 1 ) => 43 : null ;/*29*/ +//// false ? ( arg ? ) => 44 : null ;/*30*/ +//// false ? ( arg : number ) => 45 : null ;/*31*/ +//// false ? ( arg ? : number ) => 46 : null ;/*32*/ +//// false ? ( arg ? : number = 0 ) => 47 : null ;/*33*/ +//// false ? ( ... arg : number [ ] ) => 48 : null ;/*34*/ +//// +////// in ternary exression within paren +//// false ? ( ( ) => 51 ) : null ;/*35*/ +//// false ? ( ( arg ) => 52 ) : null ;/*36*/ +//// false ? ( ( arg = 1 ) => 53 ) : null ;/*37*/ +//// false ? ( ( arg ? ) => 54 ) : null ;/*38*/ +//// false ? ( ( arg : number ) => 55 ) : null ;/*39*/ +//// false ? ( ( arg ? : number ) => 56 ) : null ;/*40*/ +//// false ? ( ( arg ? : number = 0 ) => 57 ) : null ;/*41*/ +//// false ? ( ( ... arg : number [ ] ) => 58 ) : null ;/*42*/ +//// +////// ternary exression's else clause +//// false ? null : ( ) => 61 ;/*43*/ +//// false ? null : ( arg ) => 62 ;/*44*/ +//// false ? null : ( arg = 1 ) => 63 ;/*45*/ +//// false ? null : ( arg ? ) => 64 ;/*46*/ +//// false ? null : ( arg : number ) => 65 ;/*47*/ +//// false ? null : ( arg ? : number ) => 66 ;/*48*/ +//// false ? null : ( arg ? : number = 0 ) => 67 ;/*49*/ +//// false ? null : ( ... arg : number [ ] ) => 68 ;/*50*/ +//// +//// +////// nested ternary expressions +//// (( a ? ) => { return a ; }) ? ( b ? ) => { return b ; } : ( c ? ) => { return c ; } ;/*51*/ +//// +//////multiple levels +//// (( a ? ) => { return a ; }) ? ( b ) => ( c ) => 81 : ( c ) => ( d ) => 82 ;/*52*/ +//// +//// +////// In Expressions +//// ( ( arg ) => 90 ) instanceof Function ;/*53*/ +//// ( ( arg = 1 ) => 91 ) instanceof Function ;/*54*/ +//// ( ( arg ? ) => 92 ) instanceof Function ;/*55*/ +//// ( ( arg : number ) => 93 ) instanceof Function ;/*56*/ +//// ( ( arg : number = 1 ) => 94 ) instanceof Function ;/*57*/ +//// ( ( arg ? : number ) => 95 ) instanceof Function ;/*58*/ +//// ( ( ... arg : number [ ] ) => 96 ) instanceof Function ;/*59*/ +//// +////'' + (( arg ) => 100) ;/*60*/ +//// ( ( arg ) => 0 ) + '' + (( arg ) => 101) ;/*61*/ +//// ( ( arg = 1 ) => 0 ) + '' + (( arg = 2 ) => 102) ;/*62*/ +//// ( ( arg ? ) => 0 ) + '' + (( arg ? ) => 103) ;/*63*/ +//// ( ( arg : number ) => 0 ) + '' + (( arg : number ) => 104) ;/*64*/ +//// ( ( arg : number = 1 ) => 0 ) + '' + (( arg : number = 2 ) => 105) ;/*65*/ +//// ( ( arg ? : number ) => 0 ) + '' + (( arg ? : number ) => 106) ;/*66*/ +//// ( ( ... arg : number [ ] ) => 0 ) + '' + (( ... arg : number [ ] ) => 107) ;/*67*/ +//// ( ( arg1 , arg2 ? ) => 0 ) + '' + (( arg1 , arg2 ? ) => 108) ;/*68*/ +//// ( ( arg1 , ... arg2 : number [ ] ) => 0 ) + '' + (( arg1 , ... arg2 : number [ ] ) => 108) ;/*69*/ +//// +//// +////// Function Parameters +/////*70*/function foo ( ... arg : any [ ] ) { } +//// +/////*71*/foo ( +/////*72*/ ( a ) => 110 , +/////*73*/ ( ( a ) => 111 ) , +/////*74*/ ( a ) => { +//// return /*75*/112 ; +/////*76*/ } , +/////*77*/ ( a ? ) => 113 , +/////*78*/ ( a , b ? ) => 114 , +/////*79*/ ( a : number ) => 115 , +/////*80*/ ( a : number = 0 ) => 116 , +/////*81*/ ( a = 0 ) => 117 , +/////*82*/ ( a : number = 0 ) => 118 , +/////*83*/ ( a ? , b ? : number ) => 118 , +/////*84*/ ( ... a : number [ ] ) => 119 , +/////*85*/ ( a , b = 0 , ... c : number [ ] ) => 120 , +/////*86*/ ( a ) => ( b ) => ( c ) => 121 , +/////*87*/ false ? ( a ) => 0 : ( b ) => 122 +//// /*88*/) ; +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("() => 1;"); +goTo.marker("2"); +verify.currentLineContentIs("(arg) => 2;"); +goTo.marker("3"); +verify.currentLineContentIs("arg => 2;"); +goTo.marker("4"); +verify.currentLineContentIs("(arg = 1) => 3;"); +goTo.marker("5"); +verify.currentLineContentIs("(arg?) => 4;"); +goTo.marker("6"); +verify.currentLineContentIs("(arg: number) => 5;"); +goTo.marker("7"); +verify.currentLineContentIs("(arg: number = 0) => 6;"); +goTo.marker("8"); +verify.currentLineContentIs("(arg?: number) => 7;"); +goTo.marker("9"); +verify.currentLineContentIs("(...arg: number[]) => 8;"); +goTo.marker("10"); +verify.currentLineContentIs("(arg1, arg2) => 12;"); +goTo.marker("11"); +verify.currentLineContentIs("(arg1 = 1, arg2 = 3) => 13;"); +goTo.marker("12"); +verify.currentLineContentIs("(arg1?, arg2?) => 14;"); +goTo.marker("13"); +verify.currentLineContentIs("(arg1: number, arg2: number) => 15;"); +goTo.marker("14"); +verify.currentLineContentIs("(arg1: number = 0, arg2: number = 1) => 16;"); +goTo.marker("15"); +verify.currentLineContentIs("(arg1?: number, arg2?: number) => 17;"); +goTo.marker("16"); +verify.currentLineContentIs("(arg1, ...arg2: number[]) => 18;"); +goTo.marker("17"); +verify.currentLineContentIs("(arg1, arg2?: number) => 19;"); +goTo.marker("18"); +verify.currentLineContentIs("(() => 21);"); +goTo.marker("19"); +verify.currentLineContentIs("((arg) => 22);"); +goTo.marker("20"); +verify.currentLineContentIs("((arg = 1) => 23);"); +goTo.marker("21"); +verify.currentLineContentIs("((arg?) => 24);"); +goTo.marker("22"); +verify.currentLineContentIs("((arg: number) => 25);"); +goTo.marker("23"); +verify.currentLineContentIs("((arg: number = 0) => 26);"); +goTo.marker("24"); +verify.currentLineContentIs("((arg?: number) => 27);"); +goTo.marker("25"); +verify.currentLineContentIs("((...arg: number[]) => 28);"); +goTo.marker("26"); +verify.currentLineContentIs("(((((arg) => { return 32; }))));"); +goTo.marker("27"); +verify.currentLineContentIs("false ? () => 41 : null;"); +goTo.marker("28"); +verify.currentLineContentIs("false ? (arg) => 42 : null;"); +goTo.marker("29"); +verify.currentLineContentIs("false ? (arg = 1) => 43 : null;"); +goTo.marker("30"); +verify.currentLineContentIs("false ? (arg?) => 44 : null;"); +goTo.marker("31"); +verify.currentLineContentIs("false ? (arg: number) => 45 : null;"); +goTo.marker("32"); +verify.currentLineContentIs("false ? (arg?: number) => 46 : null;"); +goTo.marker("33"); +verify.currentLineContentIs("false ? (arg?: number = 0) => 47 : null;"); +goTo.marker("34"); +verify.currentLineContentIs("false ? (...arg: number[]) => 48 : null;"); +goTo.marker("35"); +verify.currentLineContentIs("false ? (() => 51) : null;"); +goTo.marker("36"); +verify.currentLineContentIs("false ? ((arg) => 52) : null;"); +goTo.marker("37"); +verify.currentLineContentIs("false ? ((arg = 1) => 53) : null;"); +goTo.marker("38"); +verify.currentLineContentIs("false ? ((arg?) => 54) : null;"); +goTo.marker("39"); +verify.currentLineContentIs("false ? ((arg: number) => 55) : null;"); +goTo.marker("40"); +verify.currentLineContentIs("false ? ((arg?: number) => 56) : null;"); +goTo.marker("41"); +verify.currentLineContentIs("false ? ((arg?: number = 0) => 57) : null;"); +goTo.marker("42"); +verify.currentLineContentIs("false ? ((...arg: number[]) => 58) : null;"); +goTo.marker("43"); +verify.currentLineContentIs("false ? null : () => 61;"); +goTo.marker("44"); +verify.currentLineContentIs("false ? null : (arg) => 62;"); +goTo.marker("45"); +verify.currentLineContentIs("false ? null : (arg = 1) => 63;"); +goTo.marker("46"); +verify.currentLineContentIs("false ? null : (arg?) => 64;"); +goTo.marker("47"); +verify.currentLineContentIs("false ? null : (arg: number) => 65;"); +goTo.marker("48"); +verify.currentLineContentIs("false ? null : (arg?: number) => 66;"); +goTo.marker("49"); +verify.currentLineContentIs("false ? null : (arg?: number = 0) => 67;"); +goTo.marker("50"); +verify.currentLineContentIs("false ? null : (...arg: number[]) => 68;"); +goTo.marker("51"); +verify.currentLineContentIs("((a?) => { return a; }) ? (b?) => { return b; } : (c?) => { return c; };"); +goTo.marker("52"); +verify.currentLineContentIs("((a?) => { return a; }) ? (b) => (c) => 81 : (c) => (d) => 82;"); +goTo.marker("53"); +verify.currentLineContentIs("((arg) => 90) instanceof Function;"); +goTo.marker("54"); +verify.currentLineContentIs("((arg = 1) => 91) instanceof Function;"); +goTo.marker("55"); +verify.currentLineContentIs("((arg?) => 92) instanceof Function;"); +goTo.marker("56"); +verify.currentLineContentIs("((arg: number) => 93) instanceof Function;"); +goTo.marker("57"); +verify.currentLineContentIs("((arg: number = 1) => 94) instanceof Function;"); +goTo.marker("58"); +verify.currentLineContentIs("((arg?: number) => 95) instanceof Function;"); +goTo.marker("59"); +verify.currentLineContentIs("((...arg: number[]) => 96) instanceof Function;"); +goTo.marker("60"); +verify.currentLineContentIs("'' + ((arg) => 100);"); + +goTo.marker("61"); +verify.currentLineContentIs("((arg) => 0) + '' + ((arg) => 101);"); +goTo.marker("62"); +verify.currentLineContentIs("((arg = 1) => 0) + '' + ((arg = 2) => 102);"); +goTo.marker("63"); +verify.currentLineContentIs("((arg?) => 0) + '' + ((arg?) => 103);"); +goTo.marker("64"); +verify.currentLineContentIs("((arg: number) => 0) + '' + ((arg: number) => 104);"); +goTo.marker("65"); +verify.currentLineContentIs("((arg: number = 1) => 0) + '' + ((arg: number = 2) => 105);"); +goTo.marker("66"); +verify.currentLineContentIs("((arg?: number) => 0) + '' + ((arg?: number) => 106);"); +goTo.marker("67"); +verify.currentLineContentIs("((...arg: number[]) => 0) + '' + ((...arg: number[]) => 107);"); +goTo.marker("68"); +verify.currentLineContentIs("((arg1, arg2?) => 0) + '' + ((arg1, arg2?) => 108);"); +goTo.marker("69"); +verify.currentLineContentIs("((arg1, ...arg2: number[]) => 0) + '' + ((arg1, ...arg2: number[]) => 108);"); +goTo.marker("70"); +verify.currentLineContentIs("function foo(...arg: any[]) { }"); +goTo.marker("71"); +verify.currentLineContentIs("foo("); +goTo.marker("72"); +verify.currentLineContentIs(" (a) => 110,"); +goTo.marker("73"); +verify.currentLineContentIs(" ((a) => 111),"); +goTo.marker("74"); +verify.currentLineContentIs(" (a) => {"); +goTo.marker("75"); +verify.currentLineContentIs(" return 112;"); +goTo.marker("76"); +verify.currentLineContentIs(" },"); +goTo.marker("77"); +verify.currentLineContentIs(" (a?) => 113,"); +goTo.marker("78"); +verify.currentLineContentIs(" (a, b?) => 114,"); +goTo.marker("79"); +verify.currentLineContentIs(" (a: number) => 115,"); +goTo.marker("80"); +verify.currentLineContentIs(" (a: number = 0) => 116,"); +goTo.marker("81"); +verify.currentLineContentIs(" (a = 0) => 117,"); +goTo.marker("82"); +verify.currentLineContentIs(" (a: number = 0) => 118,"); +goTo.marker("83"); +verify.currentLineContentIs(" (a?, b?: number) => 118,"); +goTo.marker("84"); +verify.currentLineContentIs(" (...a: number[]) => 119,"); +goTo.marker("85"); +verify.currentLineContentIs(" (a, b = 0, ...c: number[]) => 120,"); +goTo.marker("86"); +verify.currentLineContentIs(" (a) => (b) => (c) => 121,"); +goTo.marker("87"); +verify.currentLineContentIs(" false ? (a) => 0 : (b) => 122"); diff --git a/tests/cases/fourslash/formattingKeywordAsIdentifier.ts b/tests/cases/fourslash/formattingKeywordAsIdentifier.ts index aa1a636f624..ee544da345d 100644 --- a/tests/cases/fourslash/formattingKeywordAsIdentifier.ts +++ b/tests/cases/fourslash/formattingKeywordAsIdentifier.ts @@ -1,7 +1,7 @@ -/// - -////declare var module/*1*/ - -goTo.marker("1"); -edit.insert(";"); +/// + +////declare var module/*1*/ + +goTo.marker("1"); +edit.insert(";"); verify.currentLineContentIs("declare var module;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingNestedScopes.ts b/tests/cases/fourslash/formattingNestedScopes.ts index 269a67dcaaf..cbec72d9b11 100644 --- a/tests/cases/fourslash/formattingNestedScopes.ts +++ b/tests/cases/fourslash/formattingNestedScopes.ts @@ -1,4 +1,4 @@ -/// +/// /////*1*/ module My.App { /////*2*/export var appModule = angular.module("app", [ diff --git a/tests/cases/fourslash/formattingOnClasses.ts b/tests/cases/fourslash/formattingOnClasses.ts index 91e63eb3c97..045ee91e427 100644 --- a/tests/cases/fourslash/formattingOnClasses.ts +++ b/tests/cases/fourslash/formattingOnClasses.ts @@ -1,207 +1,207 @@ -/// - -/////*1*/ class a { -/////*2*/ constructor ( n : number ) ; -/////*3*/ constructor ( s : string ) ; -/////*4*/ constructor ( ns : any ) { -//// -/////*5*/ } -//// -/////*6*/ public pgF ( ) { } -//// -/////*7*/ public pv ; -/////*8*/ public get d ( ) { -/////*9*/ return 30 ; -/////*10*/ } -/////*11*/ public set d ( number ) { -/////*12*/ } -//// -/////*13*/ public static get p2 ( ) { -/////*14*/ return { x : 30 , y : 40 } ; -/////*15*/ } -//// -/////*16*/ private static d2 ( ) { -/////*17*/ } -/////*18*/ private static get p3 ( ) { -/////*19*/ return "string" ; -/////*20*/ } -/////*21*/ private pv3 ; -//// -/////*22*/ private foo ( n : number ) : string ; -/////*23*/ private foo ( s : string ) : string ; -/////*24*/ private foo ( ns : any ) { -/////*25*/ return ns.toString ( ) ; -/////*26*/ } -/////*27*/} -//// -/////*28*/ class b extends a { -/////*29*/} -//// -/////*30*/ class m1b { -//// -/////*31*/} -//// -/////*32*/ interface m1ib { -//// -/////*33*/ } -/////*34*/ class c extends m1b { -/////*35*/} -//// -/////*36*/ class ib2 implements m1ib { -/////*37*/} -//// -/////*38*/ declare class aAmbient { -/////*39*/ constructor ( n : number ) ; -/////*40*/ constructor ( s : string ) ; -/////*41*/ public pgF ( ) : void ; -/////*42*/ public pv ; -/////*43*/ public d : number ; -/////*44*/ static p2 : { x : number ; y : number ; } ; -/////*45*/ static d2 ( ) ; -/////*46*/ static p3 ; -/////*47*/ private pv3 ; -/////*48*/ private foo ( s ) ; -/////*49*/} -//// -/////*50*/ class d { -/////*51*/ private foo ( n : number ) : string ; -/////*52*/ private foo ( s : string ) : string ; -/////*53*/ private foo ( ns : any ) { -/////*54*/ return ns.toString ( ) ; -/////*55*/ } -/////*56*/} -//// -/////*57*/ class e { -/////*58*/ private foo ( s : string ) : string ; -/////*59*/ private foo ( n : number ) : string ; -/////*60*/ private foo ( ns : any ) { -/////*61*/ return ns.toString ( ) ; -/////*62*/ } -/////*63*/} -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("class a {"); -goTo.marker("2"); -verify.currentLineContentIs(" constructor(n: number);"); -goTo.marker("3"); -verify.currentLineContentIs(" constructor(s: string);"); -goTo.marker("4"); -verify.currentLineContentIs(" constructor(ns: any) {"); -goTo.marker("5"); -verify.currentLineContentIs(" }"); -goTo.marker("6"); -verify.currentLineContentIs(" public pgF() { }"); -goTo.marker("7"); -verify.currentLineContentIs(" public pv;"); -goTo.marker("8"); -verify.currentLineContentIs(" public get d() {"); -goTo.marker("9"); -verify.currentLineContentIs(" return 30;"); -goTo.marker("10"); -verify.currentLineContentIs(" }"); -goTo.marker("11"); -verify.currentLineContentIs(" public set d(number) {"); -goTo.marker("12"); -verify.currentLineContentIs(" }"); -goTo.marker("13"); -verify.currentLineContentIs(" public static get p2() {"); -goTo.marker("14"); -verify.currentLineContentIs(" return { x: 30, y: 40 };"); -goTo.marker("15"); -verify.currentLineContentIs(" }"); -goTo.marker("16"); -verify.currentLineContentIs(" private static d2() {"); -goTo.marker("17"); -verify.currentLineContentIs(" }"); -goTo.marker("18"); -verify.currentLineContentIs(" private static get p3() {"); -goTo.marker("19"); -verify.currentLineContentIs(' return "string";'); -goTo.marker("20"); -verify.currentLineContentIs(" }"); -goTo.marker("21"); -verify.currentLineContentIs(" private pv3;"); -goTo.marker("22"); -verify.currentLineContentIs(" private foo(n: number): string;"); -goTo.marker("23"); -verify.currentLineContentIs(" private foo(s: string): string;"); -goTo.marker("24"); -verify.currentLineContentIs(" private foo(ns: any) {"); -goTo.marker("25"); -verify.currentLineContentIs(" return ns.toString();"); -goTo.marker("26"); -verify.currentLineContentIs(" }"); -goTo.marker("27"); -verify.currentLineContentIs("}"); -goTo.marker("28"); -verify.currentLineContentIs("class b extends a {"); -goTo.marker("29"); -verify.currentLineContentIs("}"); -goTo.marker("30"); -verify.currentLineContentIs("class m1b {"); -goTo.marker("31"); -verify.currentLineContentIs("}"); -goTo.marker("32"); -verify.currentLineContentIs("interface m1ib {"); -goTo.marker("33"); -verify.currentLineContentIs("}"); -goTo.marker("34"); -verify.currentLineContentIs("class c extends m1b {"); -goTo.marker("35"); -verify.currentLineContentIs("}"); -goTo.marker("36"); -verify.currentLineContentIs("class ib2 implements m1ib {"); -goTo.marker("37"); -verify.currentLineContentIs("}"); -goTo.marker("38"); -verify.currentLineContentIs("declare class aAmbient {"); -goTo.marker("39"); -verify.currentLineContentIs(" constructor(n: number);"); -goTo.marker("40"); -verify.currentLineContentIs(" constructor(s: string);"); -goTo.marker("41"); -verify.currentLineContentIs(" public pgF(): void;"); -goTo.marker("42"); -verify.currentLineContentIs(" public pv;"); -goTo.marker("43"); -verify.currentLineContentIs(" public d: number;"); -goTo.marker("44"); -verify.currentLineContentIs(" static p2: { x: number; y: number; };"); -goTo.marker("45"); -verify.currentLineContentIs(" static d2();"); -goTo.marker("46"); -verify.currentLineContentIs(" static p3;"); -goTo.marker("47"); -verify.currentLineContentIs(" private pv3;"); -goTo.marker("48"); -verify.currentLineContentIs(" private foo(s);"); -goTo.marker("49"); -verify.currentLineContentIs("}"); -goTo.marker("50"); -verify.currentLineContentIs("class d {"); -goTo.marker("51"); -verify.currentLineContentIs(" private foo(n: number): string;"); -goTo.marker("52"); -verify.currentLineContentIs(" private foo(s: string): string;"); -goTo.marker("53"); -verify.currentLineContentIs(" private foo(ns: any) {"); -goTo.marker("54"); -verify.currentLineContentIs(" return ns.toString();"); -goTo.marker("55"); -verify.currentLineContentIs(" }"); -goTo.marker("56"); -verify.currentLineContentIs("}"); -goTo.marker("57"); -verify.currentLineContentIs("class e {"); -goTo.marker("58"); -verify.currentLineContentIs(" private foo(s: string): string;"); -goTo.marker("59"); -verify.currentLineContentIs(" private foo(n: number): string;"); -goTo.marker("60"); -verify.currentLineContentIs(" private foo(ns: any) {"); -goTo.marker("61"); -verify.currentLineContentIs(" return ns.toString();"); -goTo.marker("62"); -verify.currentLineContentIs(" }"); -goTo.marker("63"); +/// + +/////*1*/ class a { +/////*2*/ constructor ( n : number ) ; +/////*3*/ constructor ( s : string ) ; +/////*4*/ constructor ( ns : any ) { +//// +/////*5*/ } +//// +/////*6*/ public pgF ( ) { } +//// +/////*7*/ public pv ; +/////*8*/ public get d ( ) { +/////*9*/ return 30 ; +/////*10*/ } +/////*11*/ public set d ( number ) { +/////*12*/ } +//// +/////*13*/ public static get p2 ( ) { +/////*14*/ return { x : 30 , y : 40 } ; +/////*15*/ } +//// +/////*16*/ private static d2 ( ) { +/////*17*/ } +/////*18*/ private static get p3 ( ) { +/////*19*/ return "string" ; +/////*20*/ } +/////*21*/ private pv3 ; +//// +/////*22*/ private foo ( n : number ) : string ; +/////*23*/ private foo ( s : string ) : string ; +/////*24*/ private foo ( ns : any ) { +/////*25*/ return ns.toString ( ) ; +/////*26*/ } +/////*27*/} +//// +/////*28*/ class b extends a { +/////*29*/} +//// +/////*30*/ class m1b { +//// +/////*31*/} +//// +/////*32*/ interface m1ib { +//// +/////*33*/ } +/////*34*/ class c extends m1b { +/////*35*/} +//// +/////*36*/ class ib2 implements m1ib { +/////*37*/} +//// +/////*38*/ declare class aAmbient { +/////*39*/ constructor ( n : number ) ; +/////*40*/ constructor ( s : string ) ; +/////*41*/ public pgF ( ) : void ; +/////*42*/ public pv ; +/////*43*/ public d : number ; +/////*44*/ static p2 : { x : number ; y : number ; } ; +/////*45*/ static d2 ( ) ; +/////*46*/ static p3 ; +/////*47*/ private pv3 ; +/////*48*/ private foo ( s ) ; +/////*49*/} +//// +/////*50*/ class d { +/////*51*/ private foo ( n : number ) : string ; +/////*52*/ private foo ( s : string ) : string ; +/////*53*/ private foo ( ns : any ) { +/////*54*/ return ns.toString ( ) ; +/////*55*/ } +/////*56*/} +//// +/////*57*/ class e { +/////*58*/ private foo ( s : string ) : string ; +/////*59*/ private foo ( n : number ) : string ; +/////*60*/ private foo ( ns : any ) { +/////*61*/ return ns.toString ( ) ; +/////*62*/ } +/////*63*/} +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("class a {"); +goTo.marker("2"); +verify.currentLineContentIs(" constructor(n: number);"); +goTo.marker("3"); +verify.currentLineContentIs(" constructor(s: string);"); +goTo.marker("4"); +verify.currentLineContentIs(" constructor(ns: any) {"); +goTo.marker("5"); +verify.currentLineContentIs(" }"); +goTo.marker("6"); +verify.currentLineContentIs(" public pgF() { }"); +goTo.marker("7"); +verify.currentLineContentIs(" public pv;"); +goTo.marker("8"); +verify.currentLineContentIs(" public get d() {"); +goTo.marker("9"); +verify.currentLineContentIs(" return 30;"); +goTo.marker("10"); +verify.currentLineContentIs(" }"); +goTo.marker("11"); +verify.currentLineContentIs(" public set d(number) {"); +goTo.marker("12"); +verify.currentLineContentIs(" }"); +goTo.marker("13"); +verify.currentLineContentIs(" public static get p2() {"); +goTo.marker("14"); +verify.currentLineContentIs(" return { x: 30, y: 40 };"); +goTo.marker("15"); +verify.currentLineContentIs(" }"); +goTo.marker("16"); +verify.currentLineContentIs(" private static d2() {"); +goTo.marker("17"); +verify.currentLineContentIs(" }"); +goTo.marker("18"); +verify.currentLineContentIs(" private static get p3() {"); +goTo.marker("19"); +verify.currentLineContentIs(' return "string";'); +goTo.marker("20"); +verify.currentLineContentIs(" }"); +goTo.marker("21"); +verify.currentLineContentIs(" private pv3;"); +goTo.marker("22"); +verify.currentLineContentIs(" private foo(n: number): string;"); +goTo.marker("23"); +verify.currentLineContentIs(" private foo(s: string): string;"); +goTo.marker("24"); +verify.currentLineContentIs(" private foo(ns: any) {"); +goTo.marker("25"); +verify.currentLineContentIs(" return ns.toString();"); +goTo.marker("26"); +verify.currentLineContentIs(" }"); +goTo.marker("27"); +verify.currentLineContentIs("}"); +goTo.marker("28"); +verify.currentLineContentIs("class b extends a {"); +goTo.marker("29"); +verify.currentLineContentIs("}"); +goTo.marker("30"); +verify.currentLineContentIs("class m1b {"); +goTo.marker("31"); +verify.currentLineContentIs("}"); +goTo.marker("32"); +verify.currentLineContentIs("interface m1ib {"); +goTo.marker("33"); +verify.currentLineContentIs("}"); +goTo.marker("34"); +verify.currentLineContentIs("class c extends m1b {"); +goTo.marker("35"); +verify.currentLineContentIs("}"); +goTo.marker("36"); +verify.currentLineContentIs("class ib2 implements m1ib {"); +goTo.marker("37"); +verify.currentLineContentIs("}"); +goTo.marker("38"); +verify.currentLineContentIs("declare class aAmbient {"); +goTo.marker("39"); +verify.currentLineContentIs(" constructor(n: number);"); +goTo.marker("40"); +verify.currentLineContentIs(" constructor(s: string);"); +goTo.marker("41"); +verify.currentLineContentIs(" public pgF(): void;"); +goTo.marker("42"); +verify.currentLineContentIs(" public pv;"); +goTo.marker("43"); +verify.currentLineContentIs(" public d: number;"); +goTo.marker("44"); +verify.currentLineContentIs(" static p2: { x: number; y: number; };"); +goTo.marker("45"); +verify.currentLineContentIs(" static d2();"); +goTo.marker("46"); +verify.currentLineContentIs(" static p3;"); +goTo.marker("47"); +verify.currentLineContentIs(" private pv3;"); +goTo.marker("48"); +verify.currentLineContentIs(" private foo(s);"); +goTo.marker("49"); +verify.currentLineContentIs("}"); +goTo.marker("50"); +verify.currentLineContentIs("class d {"); +goTo.marker("51"); +verify.currentLineContentIs(" private foo(n: number): string;"); +goTo.marker("52"); +verify.currentLineContentIs(" private foo(s: string): string;"); +goTo.marker("53"); +verify.currentLineContentIs(" private foo(ns: any) {"); +goTo.marker("54"); +verify.currentLineContentIs(" return ns.toString();"); +goTo.marker("55"); +verify.currentLineContentIs(" }"); +goTo.marker("56"); +verify.currentLineContentIs("}"); +goTo.marker("57"); +verify.currentLineContentIs("class e {"); +goTo.marker("58"); +verify.currentLineContentIs(" private foo(s: string): string;"); +goTo.marker("59"); +verify.currentLineContentIs(" private foo(n: number): string;"); +goTo.marker("60"); +verify.currentLineContentIs(" private foo(ns: any) {"); +goTo.marker("61"); +verify.currentLineContentIs(" return ns.toString();"); +goTo.marker("62"); +verify.currentLineContentIs(" }"); +goTo.marker("63"); verify.currentLineContentIs("}"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnClosingBracket.ts b/tests/cases/fourslash/formattingOnClosingBracket.ts index babfd39b90c..08909753317 100644 --- a/tests/cases/fourslash/formattingOnClosingBracket.ts +++ b/tests/cases/fourslash/formattingOnClosingBracket.ts @@ -1,91 +1,91 @@ -/// - -////function f( ) {/*1*/ -////var x = 3;/*2*/ -//// var z = 2 ;/*3*/ -//// a = z ++ - 2 * x ;/*4*/ -//// for ( ; ; ) {/*5*/ -//// a+=(g +g)*a%t;/*6*/ -//// b -- ;/*7*/ -////}/*8*/ -//// -//// switch ( a )/*9*/ -//// { -//// case 1 : {/*10*/ -//// a ++ ;/*11*/ -//// b--;/*12*/ -//// if(a===a)/*13*/ -//// return;/*14*/ -//// else/*15*/ -//// { -//// for(a in b)/*16*/ -//// if(a!=a)/*17*/ -//// { -//// for(a in b)/*18*/ -//// { -////a++;/*19*/ -//// }/*20*/ -//// }/*21*/ -//// }/*22*/ -//// }/*23*/ -//// default:/*24*/ -//// break;/*25*/ -//// }/*26*/ -////}/*27*/ - -format.setOption("InsertSpaceAfterSemicolonInForStatements", true); -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("function f() {"); -goTo.marker("2"); -verify.currentLineContentIs(" var x = 3;"); -goTo.marker("3"); -verify.currentLineContentIs(" var z = 2;"); -goTo.marker("4"); -verify.currentLineContentIs(" a = z++ - 2 * x;"); -goTo.marker("5"); -verify.currentLineContentIs(" for (; ;) {"); -goTo.marker("6"); -verify.currentLineContentIs(" a += (g + g) * a % t;"); -goTo.marker("7"); -verify.currentLineContentIs(" b--;"); -goTo.marker("8"); -verify.currentLineContentIs(" }"); -goTo.marker("9"); -verify.currentLineContentIs(" switch (a) {"); -goTo.marker("10"); -verify.currentLineContentIs(" case 1: {"); -goTo.marker("11"); -verify.currentLineContentIs(" a++;"); -goTo.marker("12"); -verify.currentLineContentIs(" b--;"); -goTo.marker("13"); -verify.currentLineContentIs(" if (a === a)"); -goTo.marker("14"); -verify.currentLineContentIs(" return;"); -goTo.marker("15"); -verify.currentLineContentIs(" else {"); -goTo.marker("16"); -verify.currentLineContentIs(" for (a in b)"); -goTo.marker("17"); -verify.currentLineContentIs(" if (a != a) {"); -goTo.marker("18"); -verify.currentLineContentIs(" for (a in b) {"); -goTo.marker("19"); -verify.currentLineContentIs(" a++;"); -goTo.marker("20"); -verify.currentLineContentIs(" }"); -goTo.marker("21"); -verify.currentLineContentIs(" }"); -goTo.marker("22"); -verify.currentLineContentIs(" }"); -goTo.marker("23"); -verify.currentLineContentIs(" }"); -goTo.marker("24"); -verify.currentLineContentIs(" default:"); -goTo.marker("25"); -verify.currentLineContentIs(" break;"); -goTo.marker("26"); -verify.currentLineContentIs(" }"); -goTo.marker("27"); +/// + +////function f( ) {/*1*/ +////var x = 3;/*2*/ +//// var z = 2 ;/*3*/ +//// a = z ++ - 2 * x ;/*4*/ +//// for ( ; ; ) {/*5*/ +//// a+=(g +g)*a%t;/*6*/ +//// b -- ;/*7*/ +////}/*8*/ +//// +//// switch ( a )/*9*/ +//// { +//// case 1 : {/*10*/ +//// a ++ ;/*11*/ +//// b--;/*12*/ +//// if(a===a)/*13*/ +//// return;/*14*/ +//// else/*15*/ +//// { +//// for(a in b)/*16*/ +//// if(a!=a)/*17*/ +//// { +//// for(a in b)/*18*/ +//// { +////a++;/*19*/ +//// }/*20*/ +//// }/*21*/ +//// }/*22*/ +//// }/*23*/ +//// default:/*24*/ +//// break;/*25*/ +//// }/*26*/ +////}/*27*/ + +format.setOption("InsertSpaceAfterSemicolonInForStatements", true); +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("function f() {"); +goTo.marker("2"); +verify.currentLineContentIs(" var x = 3;"); +goTo.marker("3"); +verify.currentLineContentIs(" var z = 2;"); +goTo.marker("4"); +verify.currentLineContentIs(" a = z++ - 2 * x;"); +goTo.marker("5"); +verify.currentLineContentIs(" for (; ;) {"); +goTo.marker("6"); +verify.currentLineContentIs(" a += (g + g) * a % t;"); +goTo.marker("7"); +verify.currentLineContentIs(" b--;"); +goTo.marker("8"); +verify.currentLineContentIs(" }"); +goTo.marker("9"); +verify.currentLineContentIs(" switch (a) {"); +goTo.marker("10"); +verify.currentLineContentIs(" case 1: {"); +goTo.marker("11"); +verify.currentLineContentIs(" a++;"); +goTo.marker("12"); +verify.currentLineContentIs(" b--;"); +goTo.marker("13"); +verify.currentLineContentIs(" if (a === a)"); +goTo.marker("14"); +verify.currentLineContentIs(" return;"); +goTo.marker("15"); +verify.currentLineContentIs(" else {"); +goTo.marker("16"); +verify.currentLineContentIs(" for (a in b)"); +goTo.marker("17"); +verify.currentLineContentIs(" if (a != a) {"); +goTo.marker("18"); +verify.currentLineContentIs(" for (a in b) {"); +goTo.marker("19"); +verify.currentLineContentIs(" a++;"); +goTo.marker("20"); +verify.currentLineContentIs(" }"); +goTo.marker("21"); +verify.currentLineContentIs(" }"); +goTo.marker("22"); +verify.currentLineContentIs(" }"); +goTo.marker("23"); +verify.currentLineContentIs(" }"); +goTo.marker("24"); +verify.currentLineContentIs(" default:"); +goTo.marker("25"); +verify.currentLineContentIs(" break;"); +goTo.marker("26"); +verify.currentLineContentIs(" }"); +goTo.marker("27"); verify.currentLineContentIs("}"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnCommaOperator.ts b/tests/cases/fourslash/formattingOnCommaOperator.ts index 00626f992ca..1b8ec5087ac 100644 --- a/tests/cases/fourslash/formattingOnCommaOperator.ts +++ b/tests/cases/fourslash/formattingOnCommaOperator.ts @@ -1,13 +1,13 @@ -/// - -////var v1 = ((1, 2, 3), 4, 5, (6, 7));/*1*/ -////function f1() { -//// var a = 1; -//// return a, v1, a;/*2*/ -////} - -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("var v1 = ((1, 2, 3), 4, 5, (6, 7));"); -goTo.marker("2"); +/// + +////var v1 = ((1, 2, 3), 4, 5, (6, 7));/*1*/ +////function f1() { +//// var a = 1; +//// return a, v1, a;/*2*/ +////} + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("var v1 = ((1, 2, 3), 4, 5, (6, 7));"); +goTo.marker("2"); verify.currentLineContentIs(" return a, v1, a;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnDoWhileNoSemicolon.ts b/tests/cases/fourslash/formattingOnDoWhileNoSemicolon.ts index ccc00b587e2..848f9943925 100644 --- a/tests/cases/fourslash/formattingOnDoWhileNoSemicolon.ts +++ b/tests/cases/fourslash/formattingOnDoWhileNoSemicolon.ts @@ -1,19 +1,19 @@ -/// - -/////*2*/do { -/////*3*/ for (var i = 0; i < 10; i++) -/////*4*/ i -= 2 -/////*5*/ }/*1*/while (1 !== 1) -goTo.marker("1"); -edit.insert("\r\n"); -verify.currentLineContentIs("while (1 !== 1)"); -goTo.marker("2"); -verify.currentLineContentIs("do {"); -goTo.marker("3"); -verify.currentLineContentIs(" for (var i = 0; i < 10; i++)"); -goTo.marker("4"); -verify.currentLineContentIs(" i -= 2"); -goTo.marker("5"); -//bug 718362 expected result : "}" , actual result : " }" -//verify.currentLineContentIs("}"); +/// + +/////*2*/do { +/////*3*/ for (var i = 0; i < 10; i++) +/////*4*/ i -= 2 +/////*5*/ }/*1*/while (1 !== 1) +goTo.marker("1"); +edit.insert("\r\n"); +verify.currentLineContentIs("while (1 !== 1)"); +goTo.marker("2"); +verify.currentLineContentIs("do {"); +goTo.marker("3"); +verify.currentLineContentIs(" for (var i = 0; i < 10; i++)"); +goTo.marker("4"); +verify.currentLineContentIs(" i -= 2"); +goTo.marker("5"); +//bug 718362 expected result : "}" , actual result : " }" +//verify.currentLineContentIs("}"); verify.currentLineContentIs("}"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnDocumentReadyFunction.ts b/tests/cases/fourslash/formattingOnDocumentReadyFunction.ts index 17a7f34c98c..ecc42c05320 100644 --- a/tests/cases/fourslash/formattingOnDocumentReadyFunction.ts +++ b/tests/cases/fourslash/formattingOnDocumentReadyFunction.ts @@ -1,12 +1,12 @@ -/// - -/////*1*/$ ( document ) . ready ( function ( ) { -/////*2*/ alert ( 'i am ready' ) ; -/////*3*/ } ); -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("$(document).ready(function() {"); -goTo.marker("2"); -verify.currentLineContentIs(" alert('i am ready');"); -goTo.marker("3"); +/// + +/////*1*/$ ( document ) . ready ( function ( ) { +/////*2*/ alert ( 'i am ready' ) ; +/////*3*/ } ); +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("$(document).ready(function() {"); +goTo.marker("2"); +verify.currentLineContentIs(" alert('i am ready');"); +goTo.marker("3"); verify.currentLineContentIs("});"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnEmptyInterfaceLiteral.ts b/tests/cases/fourslash/formattingOnEmptyInterfaceLiteral.ts index 5710357c377..bd82ed698c0 100644 --- a/tests/cases/fourslash/formattingOnEmptyInterfaceLiteral.ts +++ b/tests/cases/fourslash/formattingOnEmptyInterfaceLiteral.ts @@ -1,25 +1,25 @@ -/// - -/////*1*/ function foo ( x : { } ) { } -//// -/////*2*/foo ( { } ) ; -//// -//// -//// -/////*3*/ interface bar { -/////*4*/ x : { } ; -/////*5*/ y : ( ) => { } ; -/////*6*/ } -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("function foo(x: {}) { }"); -goTo.marker("2"); -verify.currentLineContentIs("foo({});"); -goTo.marker("3"); -verify.currentLineContentIs("interface bar {"); -goTo.marker("4"); -verify.currentLineContentIs(" x: {};"); -goTo.marker("5"); -verify.currentLineContentIs(" y: () => {};"); -goTo.marker("6"); +/// + +/////*1*/ function foo ( x : { } ) { } +//// +/////*2*/foo ( { } ) ; +//// +//// +//// +/////*3*/ interface bar { +/////*4*/ x : { } ; +/////*5*/ y : ( ) => { } ; +/////*6*/ } +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("function foo(x: {}) { }"); +goTo.marker("2"); +verify.currentLineContentIs("foo({});"); +goTo.marker("3"); +verify.currentLineContentIs("interface bar {"); +goTo.marker("4"); +verify.currentLineContentIs(" x: {};"); +goTo.marker("5"); +verify.currentLineContentIs(" y: () => {};"); +goTo.marker("6"); verify.currentLineContentIs("}"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnInvalidCodes.ts b/tests/cases/fourslash/formattingOnInvalidCodes.ts index c42412628b6..c5d71020249 100644 --- a/tests/cases/fourslash/formattingOnInvalidCodes.ts +++ b/tests/cases/fourslash/formattingOnInvalidCodes.ts @@ -1,273 +1,273 @@ -/// - -/////*1*/var a;var c , b;var $d -/////*2*/var $e -/////*3*/var f -/////*4*/a++;b++; -//// -/////*5*/function f ( ) { -/////*6*/ for (i = 0; i < 10; i++) { -/////*7*/ k = abc + 123 ^ d; -/////*8*/ a = XYZ[m (a[b[c][d]])]; -/////*9*/ break; -//// -/////*10*/ switch ( variable){ -/////*11*/ case 1: abc += 425; -/////*12*/break; -/////*13*/case 404 : a [x--/2]%=3 ; -/////*14*/ break ; -/////*15*/ case vari : v[--x ] *=++y*( m + n / k[z]); -/////*16*/ for (a in b){ -/////*17*/ for (a = 0; a < 10; ++a) { -/////*18*/ a++;--a; -/////*19*/ if (a == b) { -/////*20*/ a++;b--; -/////*21*/ } -/////*22*/else -/////*23*/if (a == c){ -/////*24*/++a; -/////*25*/(--c)+=d; -/////*26*/$c = $a + --$b; -/////*27*/} -/////*28*/if (a == b) -/////*29*/if (a != b) { -/////*30*/ if (a !== b) -/////*31*/ if (a === b) -/////*32*/ --a; -/////*33*/ else -/////*34*/ --a; -/////*35*/ else { -/////*36*/ a--;++b; -/////*37*/a++ -/////*38*/ } -/////*39*/ } -/////*40*/ } -/////*41*/ for (x in y) { -/////*42*/m-=m; -/////*43*/k=1+2+3+4; -/////*44*/} -/////*45*/} -/////*46*/ break; -//// -/////*47*/ } -/////*48*/ } -/////*49*/ var a ={b:function(){}}; -/////*50*/ return {a:1,b:2} -/////*51*/} -//// -/////*52*/var z = 1; -/////*53*/ for (i = 0; i < 10; i++) -/////*54*/ for (j = 0; j < 10; j++) -/////*55*/for (k = 0; k < 10; ++k) { -/////*56*/z++; -/////*57*/} -//// -/////*58*/for (k = 0; k < 10; k += 2) { -/////*59*/z++; -/////*60*/} -//// -/////*61*/ $(document).ready (); -//// -//// -/////*62*/ function pageLoad() { -/////*63*/ $('#TextBox1' ) . unbind ( ) ; -/////*64*/$('#TextBox1' ) . datepicker ( ) ; -/////*65*/} -//// -/////*66*/ function pageLoad ( ) { -/////*67*/ var webclass=[ -/////*68*/ { 'student' :/*69*/ -/////*70*/ { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' } -/////*71*/ } , -/////*72*/{ 'student':/*73*/ -/////*74*/{'id':'2','name':'Adam Davidson','legacySkill':'Cobol,MainFrame'} -/////*75*/} , -/////*76*/ { 'student':/*77*/ -/////*78*/{ 'id':'3','name':'Charles Boyer' ,'legacySkill':'HTML, XML'} -/////*79*/} -/////*80*/ ]; -//// -/////*81*/$create(Sys.UI.DataView,{data:webclass},null,null,$get('SList')); -//// -/////*82*/} -//// -/////*83*/$( document ).ready(function(){ -/////*84*/alert('hello'); -/////*85*/ } ) ; -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("var a; var c, b; var $d"); -goTo.marker("2"); -verify.currentLineContentIs("var $e"); -goTo.marker("3"); -verify.currentLineContentIs("var f"); -goTo.marker("4"); -verify.currentLineContentIs("a++; b++;"); -goTo.marker("5"); -verify.currentLineContentIs("function f() {"); -goTo.marker("6"); -verify.currentLineContentIs(" for (i = 0; i < 10; i++) {"); -goTo.marker("7"); -verify.currentLineContentIs(" k = abc + 123 ^ d;"); -goTo.marker("8"); -verify.currentLineContentIs(" a = XYZ[m(a[b[c][d]])];"); -goTo.marker("9"); -verify.currentLineContentIs(" break;"); -goTo.marker("10"); -verify.currentLineContentIs(" switch (variable) {"); -goTo.marker("11"); -verify.currentLineContentIs(" case 1: abc += 425;"); -goTo.marker("12"); -verify.currentLineContentIs(" break;"); -goTo.marker("13"); -verify.currentLineContentIs(" case 404: a[x-- / 2] %= 3;"); -goTo.marker("14"); -verify.currentLineContentIs(" break;"); -goTo.marker("15"); -verify.currentLineContentIs(" case vari: v[--x] *= ++y * (m + n / k[z]);"); -goTo.marker("16"); -verify.currentLineContentIs(" for (a in b) {"); -goTo.marker("17"); -verify.currentLineContentIs(" for (a = 0; a < 10; ++a) {"); -goTo.marker("18"); -verify.currentLineContentIs(" a++; --a;"); -goTo.marker("19"); -verify.currentLineContentIs(" if (a == b) {"); -goTo.marker("20"); -verify.currentLineContentIs(" a++; b--;"); -goTo.marker("21"); -verify.currentLineContentIs(" }"); -goTo.marker("22"); -verify.currentLineContentIs(" else"); -goTo.marker("23"); -verify.currentLineContentIs(" if (a == c) {"); -goTo.marker("24"); -verify.currentLineContentIs(" ++a;"); -goTo.marker("25"); -verify.currentLineContentIs(" (--c) += d;"); -goTo.marker("26"); -verify.currentLineContentIs(" $c = $a + --$b;"); -goTo.marker("27"); -verify.currentLineContentIs(" }"); -goTo.marker("28"); -verify.currentLineContentIs(" if (a == b)"); -goTo.marker("29"); -verify.currentLineContentIs(" if (a != b) {"); -goTo.marker("30"); -verify.currentLineContentIs(" if (a !== b)"); -goTo.marker("31"); -verify.currentLineContentIs(" if (a === b)"); -goTo.marker("32"); -verify.currentLineContentIs(" --a;"); -goTo.marker("33"); -verify.currentLineContentIs(" else"); -goTo.marker("34"); -verify.currentLineContentIs(" --a;"); -goTo.marker("35"); -verify.currentLineContentIs(" else {"); -goTo.marker("36"); -verify.currentLineContentIs(" a--; ++b;"); -goTo.marker("37"); -verify.currentLineContentIs(" a++"); -goTo.marker("38"); -//bug 697788 expect result : " }", actual result : " }" -//verify.currentLineContentIs(" }"); -verify.currentLineContentIs(" }"); -goTo.marker("39"); -verify.currentLineContentIs(" }"); -goTo.marker("40"); -verify.currentLineContentIs(" }"); -goTo.marker("41"); -verify.currentLineContentIs(" for (x in y) {"); -goTo.marker("42"); -verify.currentLineContentIs(" m -= m;"); -goTo.marker("43"); -verify.currentLineContentIs(" k = 1 + 2 + 3 + 4;"); -goTo.marker("44"); -verify.currentLineContentIs(" }"); -goTo.marker("45"); -verify.currentLineContentIs(" }"); -goTo.marker("46"); -verify.currentLineContentIs(" break;"); -goTo.marker("47"); -verify.currentLineContentIs(" }"); -goTo.marker("48"); -verify.currentLineContentIs(" }"); -goTo.marker("49"); -//bug 704204 expect result : " var a = { b: function () { } };", actual result : " var a = { b: function() { } };" -//verify.currentLineContentIs(" var a = { b: function () { } };"); -verify.currentLineContentIs(" var a = { b: function() { } };"); -goTo.marker("50"); -verify.currentLineContentIs(" return { a: 1, b: 2 }"); -goTo.marker("51"); -verify.currentLineContentIs("}"); -goTo.marker("52"); -verify.currentLineContentIs("var z = 1;"); -goTo.marker("53"); -verify.currentLineContentIs("for (i = 0; i < 10; i++)"); -goTo.marker("54"); -verify.currentLineContentIs(" for (j = 0; j < 10; j++)"); -goTo.marker("55"); -verify.currentLineContentIs(" for (k = 0; k < 10; ++k) {"); -goTo.marker("56"); -verify.currentLineContentIs(" z++;"); -goTo.marker("57"); -verify.currentLineContentIs(" }"); -goTo.marker("58"); -verify.currentLineContentIs("for (k = 0; k < 10; k += 2) {"); -goTo.marker("59"); -verify.currentLineContentIs(" z++;"); -goTo.marker("60"); -verify.currentLineContentIs("}"); -goTo.marker("61"); -verify.currentLineContentIs("$(document).ready();"); -goTo.marker("62"); -verify.currentLineContentIs("function pageLoad() {"); -goTo.marker("63"); -verify.currentLineContentIs(" $('#TextBox1').unbind();"); -goTo.marker("64"); -verify.currentLineContentIs(" $('#TextBox1').datepicker();"); -goTo.marker("65"); -verify.currentLineContentIs("}"); -goTo.marker("66"); -verify.currentLineContentIs("function pageLoad() {"); -goTo.marker("67"); -verify.currentLineContentIs(" var webclass = ["); -goTo.marker("68"); -verify.currentLineContentIs(" {"); -goTo.marker("69"); -verify.currentLineContentIs(" 'student':"); -goTo.marker("70"); -verify.currentLineContentIs(" { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }"); -goTo.marker("71"); -verify.currentLineContentIs(" },"); -goTo.marker("72"); -verify.currentLineContentIs(" {"); -goTo.marker("73"); -verify.currentLineContentIs(" 'student':"); -goTo.marker("74"); -verify.currentLineContentIs(" { 'id': '2', 'name': 'Adam Davidson', 'legacySkill': 'Cobol,MainFrame' }"); -goTo.marker("75"); -verify.currentLineContentIs(" },"); -goTo.marker("76"); -verify.currentLineContentIs(" {"); -goTo.marker("77"); -verify.currentLineContentIs(" 'student':"); -goTo.marker("78"); -verify.currentLineContentIs(" { 'id': '3', 'name': 'Charles Boyer', 'legacySkill': 'HTML, XML' }"); -goTo.marker("79"); -verify.currentLineContentIs(" }"); -goTo.marker("80"); -verify.currentLineContentIs(" ];"); -goTo.marker("81"); -verify.currentLineContentIs(" $create(Sys.UI.DataView, { data: webclass }, null, null, $get('SList'));"); -goTo.marker("82"); -verify.currentLineContentIs("}"); -goTo.marker("83"); -//bug 704204 expect result : "$(document).ready(function () {", actual result : "$(document).ready(function() " -//verify.currentLineContentIs("$(document).ready(function () {"); -verify.currentLineContentIs("$(document).ready(function() {"); -goTo.marker("84"); -verify.currentLineContentIs(" alert('hello');"); -goTo.marker("85"); +/// + +/////*1*/var a;var c , b;var $d +/////*2*/var $e +/////*3*/var f +/////*4*/a++;b++; +//// +/////*5*/function f ( ) { +/////*6*/ for (i = 0; i < 10; i++) { +/////*7*/ k = abc + 123 ^ d; +/////*8*/ a = XYZ[m (a[b[c][d]])]; +/////*9*/ break; +//// +/////*10*/ switch ( variable){ +/////*11*/ case 1: abc += 425; +/////*12*/break; +/////*13*/case 404 : a [x--/2]%=3 ; +/////*14*/ break ; +/////*15*/ case vari : v[--x ] *=++y*( m + n / k[z]); +/////*16*/ for (a in b){ +/////*17*/ for (a = 0; a < 10; ++a) { +/////*18*/ a++;--a; +/////*19*/ if (a == b) { +/////*20*/ a++;b--; +/////*21*/ } +/////*22*/else +/////*23*/if (a == c){ +/////*24*/++a; +/////*25*/(--c)+=d; +/////*26*/$c = $a + --$b; +/////*27*/} +/////*28*/if (a == b) +/////*29*/if (a != b) { +/////*30*/ if (a !== b) +/////*31*/ if (a === b) +/////*32*/ --a; +/////*33*/ else +/////*34*/ --a; +/////*35*/ else { +/////*36*/ a--;++b; +/////*37*/a++ +/////*38*/ } +/////*39*/ } +/////*40*/ } +/////*41*/ for (x in y) { +/////*42*/m-=m; +/////*43*/k=1+2+3+4; +/////*44*/} +/////*45*/} +/////*46*/ break; +//// +/////*47*/ } +/////*48*/ } +/////*49*/ var a ={b:function(){}}; +/////*50*/ return {a:1,b:2} +/////*51*/} +//// +/////*52*/var z = 1; +/////*53*/ for (i = 0; i < 10; i++) +/////*54*/ for (j = 0; j < 10; j++) +/////*55*/for (k = 0; k < 10; ++k) { +/////*56*/z++; +/////*57*/} +//// +/////*58*/for (k = 0; k < 10; k += 2) { +/////*59*/z++; +/////*60*/} +//// +/////*61*/ $(document).ready (); +//// +//// +/////*62*/ function pageLoad() { +/////*63*/ $('#TextBox1' ) . unbind ( ) ; +/////*64*/$('#TextBox1' ) . datepicker ( ) ; +/////*65*/} +//// +/////*66*/ function pageLoad ( ) { +/////*67*/ var webclass=[ +/////*68*/ { 'student' :/*69*/ +/////*70*/ { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' } +/////*71*/ } , +/////*72*/{ 'student':/*73*/ +/////*74*/{'id':'2','name':'Adam Davidson','legacySkill':'Cobol,MainFrame'} +/////*75*/} , +/////*76*/ { 'student':/*77*/ +/////*78*/{ 'id':'3','name':'Charles Boyer' ,'legacySkill':'HTML, XML'} +/////*79*/} +/////*80*/ ]; +//// +/////*81*/$create(Sys.UI.DataView,{data:webclass},null,null,$get('SList')); +//// +/////*82*/} +//// +/////*83*/$( document ).ready(function(){ +/////*84*/alert('hello'); +/////*85*/ } ) ; +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("var a; var c, b; var $d"); +goTo.marker("2"); +verify.currentLineContentIs("var $e"); +goTo.marker("3"); +verify.currentLineContentIs("var f"); +goTo.marker("4"); +verify.currentLineContentIs("a++; b++;"); +goTo.marker("5"); +verify.currentLineContentIs("function f() {"); +goTo.marker("6"); +verify.currentLineContentIs(" for (i = 0; i < 10; i++) {"); +goTo.marker("7"); +verify.currentLineContentIs(" k = abc + 123 ^ d;"); +goTo.marker("8"); +verify.currentLineContentIs(" a = XYZ[m(a[b[c][d]])];"); +goTo.marker("9"); +verify.currentLineContentIs(" break;"); +goTo.marker("10"); +verify.currentLineContentIs(" switch (variable) {"); +goTo.marker("11"); +verify.currentLineContentIs(" case 1: abc += 425;"); +goTo.marker("12"); +verify.currentLineContentIs(" break;"); +goTo.marker("13"); +verify.currentLineContentIs(" case 404: a[x-- / 2] %= 3;"); +goTo.marker("14"); +verify.currentLineContentIs(" break;"); +goTo.marker("15"); +verify.currentLineContentIs(" case vari: v[--x] *= ++y * (m + n / k[z]);"); +goTo.marker("16"); +verify.currentLineContentIs(" for (a in b) {"); +goTo.marker("17"); +verify.currentLineContentIs(" for (a = 0; a < 10; ++a) {"); +goTo.marker("18"); +verify.currentLineContentIs(" a++; --a;"); +goTo.marker("19"); +verify.currentLineContentIs(" if (a == b) {"); +goTo.marker("20"); +verify.currentLineContentIs(" a++; b--;"); +goTo.marker("21"); +verify.currentLineContentIs(" }"); +goTo.marker("22"); +verify.currentLineContentIs(" else"); +goTo.marker("23"); +verify.currentLineContentIs(" if (a == c) {"); +goTo.marker("24"); +verify.currentLineContentIs(" ++a;"); +goTo.marker("25"); +verify.currentLineContentIs(" (--c) += d;"); +goTo.marker("26"); +verify.currentLineContentIs(" $c = $a + --$b;"); +goTo.marker("27"); +verify.currentLineContentIs(" }"); +goTo.marker("28"); +verify.currentLineContentIs(" if (a == b)"); +goTo.marker("29"); +verify.currentLineContentIs(" if (a != b) {"); +goTo.marker("30"); +verify.currentLineContentIs(" if (a !== b)"); +goTo.marker("31"); +verify.currentLineContentIs(" if (a === b)"); +goTo.marker("32"); +verify.currentLineContentIs(" --a;"); +goTo.marker("33"); +verify.currentLineContentIs(" else"); +goTo.marker("34"); +verify.currentLineContentIs(" --a;"); +goTo.marker("35"); +verify.currentLineContentIs(" else {"); +goTo.marker("36"); +verify.currentLineContentIs(" a--; ++b;"); +goTo.marker("37"); +verify.currentLineContentIs(" a++"); +goTo.marker("38"); +//bug 697788 expect result : " }", actual result : " }" +//verify.currentLineContentIs(" }"); +verify.currentLineContentIs(" }"); +goTo.marker("39"); +verify.currentLineContentIs(" }"); +goTo.marker("40"); +verify.currentLineContentIs(" }"); +goTo.marker("41"); +verify.currentLineContentIs(" for (x in y) {"); +goTo.marker("42"); +verify.currentLineContentIs(" m -= m;"); +goTo.marker("43"); +verify.currentLineContentIs(" k = 1 + 2 + 3 + 4;"); +goTo.marker("44"); +verify.currentLineContentIs(" }"); +goTo.marker("45"); +verify.currentLineContentIs(" }"); +goTo.marker("46"); +verify.currentLineContentIs(" break;"); +goTo.marker("47"); +verify.currentLineContentIs(" }"); +goTo.marker("48"); +verify.currentLineContentIs(" }"); +goTo.marker("49"); +//bug 704204 expect result : " var a = { b: function () { } };", actual result : " var a = { b: function() { } };" +//verify.currentLineContentIs(" var a = { b: function () { } };"); +verify.currentLineContentIs(" var a = { b: function() { } };"); +goTo.marker("50"); +verify.currentLineContentIs(" return { a: 1, b: 2 }"); +goTo.marker("51"); +verify.currentLineContentIs("}"); +goTo.marker("52"); +verify.currentLineContentIs("var z = 1;"); +goTo.marker("53"); +verify.currentLineContentIs("for (i = 0; i < 10; i++)"); +goTo.marker("54"); +verify.currentLineContentIs(" for (j = 0; j < 10; j++)"); +goTo.marker("55"); +verify.currentLineContentIs(" for (k = 0; k < 10; ++k) {"); +goTo.marker("56"); +verify.currentLineContentIs(" z++;"); +goTo.marker("57"); +verify.currentLineContentIs(" }"); +goTo.marker("58"); +verify.currentLineContentIs("for (k = 0; k < 10; k += 2) {"); +goTo.marker("59"); +verify.currentLineContentIs(" z++;"); +goTo.marker("60"); +verify.currentLineContentIs("}"); +goTo.marker("61"); +verify.currentLineContentIs("$(document).ready();"); +goTo.marker("62"); +verify.currentLineContentIs("function pageLoad() {"); +goTo.marker("63"); +verify.currentLineContentIs(" $('#TextBox1').unbind();"); +goTo.marker("64"); +verify.currentLineContentIs(" $('#TextBox1').datepicker();"); +goTo.marker("65"); +verify.currentLineContentIs("}"); +goTo.marker("66"); +verify.currentLineContentIs("function pageLoad() {"); +goTo.marker("67"); +verify.currentLineContentIs(" var webclass = ["); +goTo.marker("68"); +verify.currentLineContentIs(" {"); +goTo.marker("69"); +verify.currentLineContentIs(" 'student':"); +goTo.marker("70"); +verify.currentLineContentIs(" { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }"); +goTo.marker("71"); +verify.currentLineContentIs(" },"); +goTo.marker("72"); +verify.currentLineContentIs(" {"); +goTo.marker("73"); +verify.currentLineContentIs(" 'student':"); +goTo.marker("74"); +verify.currentLineContentIs(" { 'id': '2', 'name': 'Adam Davidson', 'legacySkill': 'Cobol,MainFrame' }"); +goTo.marker("75"); +verify.currentLineContentIs(" },"); +goTo.marker("76"); +verify.currentLineContentIs(" {"); +goTo.marker("77"); +verify.currentLineContentIs(" 'student':"); +goTo.marker("78"); +verify.currentLineContentIs(" { 'id': '3', 'name': 'Charles Boyer', 'legacySkill': 'HTML, XML' }"); +goTo.marker("79"); +verify.currentLineContentIs(" }"); +goTo.marker("80"); +verify.currentLineContentIs(" ];"); +goTo.marker("81"); +verify.currentLineContentIs(" $create(Sys.UI.DataView, { data: webclass }, null, null, $get('SList'));"); +goTo.marker("82"); +verify.currentLineContentIs("}"); +goTo.marker("83"); +//bug 704204 expect result : "$(document).ready(function () {", actual result : "$(document).ready(function() " +//verify.currentLineContentIs("$(document).ready(function () {"); +verify.currentLineContentIs("$(document).ready(function() {"); +goTo.marker("84"); +verify.currentLineContentIs(" alert('hello');"); +goTo.marker("85"); verify.currentLineContentIs("});"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnModuleIndentation.ts b/tests/cases/fourslash/formattingOnModuleIndentation.ts index 374c5a7c95c..776e2fa1bd5 100644 --- a/tests/cases/fourslash/formattingOnModuleIndentation.ts +++ b/tests/cases/fourslash/formattingOnModuleIndentation.ts @@ -1,13 +1,13 @@ -/// - -//// module Foo { -//// export module A . B . C { }/**/ -//// } - -format.document(); -goTo.bof(); -verify.currentLineContentIs("module Foo {"); -goTo.marker(); -verify.currentLineContentIs(" export module A.B.C { }"); -goTo.eof(); +/// + +//// module Foo { +//// export module A . B . C { }/**/ +//// } + +format.document(); +goTo.bof(); +verify.currentLineContentIs("module Foo {"); +goTo.marker(); +verify.currentLineContentIs(" export module A.B.C { }"); +goTo.eof(); verify.currentLineContentIs("}"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnNestedDoWhileByEnter.ts b/tests/cases/fourslash/formattingOnNestedDoWhileByEnter.ts index 17b91dbd808..e35f4a333b9 100644 --- a/tests/cases/fourslash/formattingOnNestedDoWhileByEnter.ts +++ b/tests/cases/fourslash/formattingOnNestedDoWhileByEnter.ts @@ -1,23 +1,23 @@ -/// - -/////*2*/do{ -/////*3*/do/*1*/{ -/////*4*/do{ -/////*5*/}while(a!==b) -/////*6*/}while(a!==b) -/////*7*/}while(a!==b) -goTo.marker("1"); -edit.insert("\r\n"); -verify.currentLineContentIs(" {"); -goTo.marker("2"); -verify.currentLineContentIs("do{"); -goTo.marker("3"); -verify.currentLineContentIs(" do"); -goTo.marker("4"); -verify.currentLineContentIs("do{"); -goTo.marker("5"); -verify.currentLineContentIs("}while(a!==b)"); -goTo.marker("6"); -verify.currentLineContentIs("}while(a!==b)"); -goTo.marker("7"); +/// + +/////*2*/do{ +/////*3*/do/*1*/{ +/////*4*/do{ +/////*5*/}while(a!==b) +/////*6*/}while(a!==b) +/////*7*/}while(a!==b) +goTo.marker("1"); +edit.insert("\r\n"); +verify.currentLineContentIs(" {"); +goTo.marker("2"); +verify.currentLineContentIs("do{"); +goTo.marker("3"); +verify.currentLineContentIs(" do"); +goTo.marker("4"); +verify.currentLineContentIs("do{"); +goTo.marker("5"); +verify.currentLineContentIs("}while(a!==b)"); +goTo.marker("6"); +verify.currentLineContentIs("}while(a!==b)"); +goTo.marker("7"); verify.currentLineContentIs("}while(a!==b)"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnNestedStatements.ts b/tests/cases/fourslash/formattingOnNestedStatements.ts index 547fcfa27ef..13c957af455 100644 --- a/tests/cases/fourslash/formattingOnNestedStatements.ts +++ b/tests/cases/fourslash/formattingOnNestedStatements.ts @@ -1,14 +1,14 @@ -/// - -////{ -/////*1*/{ -/////*3*/test -////}/*2*/ -////} -format.selection("1", "2"); -goTo.marker("1"); -verify.currentLineContentIs(" {"); -goTo.marker("3"); -verify.currentLineContentIs(" test"); -goTo.marker("2"); +/// + +////{ +/////*1*/{ +/////*3*/test +////}/*2*/ +////} +format.selection("1", "2"); +goTo.marker("1"); +verify.currentLineContentIs(" {"); +goTo.marker("3"); +verify.currentLineContentIs(" test"); +goTo.marker("2"); verify.currentLineContentIs(" }"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnObjectLiteral.ts b/tests/cases/fourslash/formattingOnObjectLiteral.ts index b8db4dd45dc..5b8d5f9cb52 100644 --- a/tests/cases/fourslash/formattingOnObjectLiteral.ts +++ b/tests/cases/fourslash/formattingOnObjectLiteral.ts @@ -1,85 +1,85 @@ -/// - -////var x = /*1*/{foo:/*2*/ 1, -////bar: "tt",/*3*/ -////boo: /*4*/1 + 5}/*5*/; -//// -////var x2 = /*6*/{foo/*7*/: 1, -////bar: /*8*/"tt",boo:1+5}/*9*/; -//// -////function Foo() {/*10*/ -////var typeICalc = {/*11*/ -////clear: {/*12*/ -////"()": [1, 2, 3]/*13*/ -////}/*14*/ -////}/*15*/ -////}/*16*/ -//// -////// Rule for object literal members for the "value" of the memebr to follow the indent/*17*/ -////// of the member, i.e. the relative position of the value is maintained when the member/*18*/ -////// is indented./*19*/ -////var x2 = {/*20*/ -//// foo:/*21*/ -////3,/*22*/ -//// 'bar':/*23*/ -//// { a: 1, b : 2}/*24*/ -////};/*25*/ -//// -////var x={ };/*26*/ -////var y = {};/*27*/ - -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("var x = {"); -goTo.marker("2"); -verify.currentLineContentIs(" foo: 1,"); -goTo.marker("3"); -verify.currentLineContentIs(" bar: \"tt\","); -goTo.marker("4"); -verify.currentLineContentIs(" boo: 1 + 5"); -goTo.marker("5"); -verify.currentLineContentIs("};"); -goTo.marker("6"); -verify.currentLineContentIs("var x2 = {"); -goTo.marker("7"); -verify.currentLineContentIs(" foo: 1,"); -goTo.marker("8"); -verify.currentLineContentIs(" bar: \"tt\", boo: 1 + 5"); -goTo.marker("9"); -verify.currentLineContentIs("};"); -goTo.marker("10"); -verify.currentLineContentIs("function Foo() {"); -goTo.marker("11"); -verify.currentLineContentIs(" var typeICalc = {"); -goTo.marker("12"); -verify.currentLineContentIs(" clear: {"); -goTo.marker("13"); -verify.currentLineContentIs(" \"()\": [1, 2, 3]"); -goTo.marker("14"); -verify.currentLineContentIs(" }"); -goTo.marker("15"); -verify.currentLineContentIs(" }"); -goTo.marker("16"); -verify.currentLineContentIs("}"); -goTo.marker("17"); -verify.currentLineContentIs("// Rule for object literal members for the \"value\" of the memebr to follow the indent"); -goTo.marker("18"); -verify.currentLineContentIs("// of the member, i.e. the relative position of the value is maintained when the member"); -goTo.marker("19"); -verify.currentLineContentIs("// is indented."); -goTo.marker("20"); -verify.currentLineContentIs("var x2 = {"); -goTo.marker("21"); -verify.currentLineContentIs(" foo:"); -goTo.marker("22"); -verify.currentLineContentIs(" 3,"); -goTo.marker("23"); -verify.currentLineContentIs(" 'bar':"); -goTo.marker("24"); -verify.currentLineContentIs(" { a: 1, b: 2 }"); -goTo.marker("25"); -verify.currentLineContentIs("};"); -goTo.marker("26"); -verify.currentLineContentIs("var x = {};"); -goTo.marker("27"); +/// + +////var x = /*1*/{foo:/*2*/ 1, +////bar: "tt",/*3*/ +////boo: /*4*/1 + 5}/*5*/; +//// +////var x2 = /*6*/{foo/*7*/: 1, +////bar: /*8*/"tt",boo:1+5}/*9*/; +//// +////function Foo() {/*10*/ +////var typeICalc = {/*11*/ +////clear: {/*12*/ +////"()": [1, 2, 3]/*13*/ +////}/*14*/ +////}/*15*/ +////}/*16*/ +//// +////// Rule for object literal members for the "value" of the memebr to follow the indent/*17*/ +////// of the member, i.e. the relative position of the value is maintained when the member/*18*/ +////// is indented./*19*/ +////var x2 = {/*20*/ +//// foo:/*21*/ +////3,/*22*/ +//// 'bar':/*23*/ +//// { a: 1, b : 2}/*24*/ +////};/*25*/ +//// +////var x={ };/*26*/ +////var y = {};/*27*/ + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("var x = {"); +goTo.marker("2"); +verify.currentLineContentIs(" foo: 1,"); +goTo.marker("3"); +verify.currentLineContentIs(" bar: \"tt\","); +goTo.marker("4"); +verify.currentLineContentIs(" boo: 1 + 5"); +goTo.marker("5"); +verify.currentLineContentIs("};"); +goTo.marker("6"); +verify.currentLineContentIs("var x2 = {"); +goTo.marker("7"); +verify.currentLineContentIs(" foo: 1,"); +goTo.marker("8"); +verify.currentLineContentIs(" bar: \"tt\", boo: 1 + 5"); +goTo.marker("9"); +verify.currentLineContentIs("};"); +goTo.marker("10"); +verify.currentLineContentIs("function Foo() {"); +goTo.marker("11"); +verify.currentLineContentIs(" var typeICalc = {"); +goTo.marker("12"); +verify.currentLineContentIs(" clear: {"); +goTo.marker("13"); +verify.currentLineContentIs(" \"()\": [1, 2, 3]"); +goTo.marker("14"); +verify.currentLineContentIs(" }"); +goTo.marker("15"); +verify.currentLineContentIs(" }"); +goTo.marker("16"); +verify.currentLineContentIs("}"); +goTo.marker("17"); +verify.currentLineContentIs("// Rule for object literal members for the \"value\" of the memebr to follow the indent"); +goTo.marker("18"); +verify.currentLineContentIs("// of the member, i.e. the relative position of the value is maintained when the member"); +goTo.marker("19"); +verify.currentLineContentIs("// is indented."); +goTo.marker("20"); +verify.currentLineContentIs("var x2 = {"); +goTo.marker("21"); +verify.currentLineContentIs(" foo:"); +goTo.marker("22"); +verify.currentLineContentIs(" 3,"); +goTo.marker("23"); +verify.currentLineContentIs(" 'bar':"); +goTo.marker("24"); +verify.currentLineContentIs(" { a: 1, b: 2 }"); +goTo.marker("25"); +verify.currentLineContentIs("};"); +goTo.marker("26"); +verify.currentLineContentIs("var x = {};"); +goTo.marker("27"); verify.currentLineContentIs("var y = {};"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnOpenBraceOfFunctions.ts b/tests/cases/fourslash/formattingOnOpenBraceOfFunctions.ts index 6414362a4cd..a7905dc938d 100644 --- a/tests/cases/fourslash/formattingOnOpenBraceOfFunctions.ts +++ b/tests/cases/fourslash/formattingOnOpenBraceOfFunctions.ts @@ -1,10 +1,10 @@ -/// - -/////**/function T2_y() -////{ -////Plugin.T1.t1_x(); -////} - -format.document(); -goTo.marker(); +/// + +/////**/function T2_y() +////{ +////Plugin.T1.t1_x(); +////} + +format.document(); +goTo.marker(); verify.currentLineContentIs("function T2_y() {"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnSemiColon.ts b/tests/cases/fourslash/formattingOnSemiColon.ts index b560055a761..027bb637edd 100644 --- a/tests/cases/fourslash/formattingOnSemiColon.ts +++ b/tests/cases/fourslash/formattingOnSemiColon.ts @@ -1,7 +1,7 @@ -/// - -////var a=b+c^d-e*++f - -goTo.eof(); -edit.insert(";"); +/// + +////var a=b+c^d-e*++f + +goTo.eof(); +edit.insert(";"); verify.currentFileContentIs("var a = b + c ^ d - e * ++f;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnSingleLineBlocks.ts b/tests/cases/fourslash/formattingOnSingleLineBlocks.ts index b832fa7222b..fc1a6818b95 100644 --- a/tests/cases/fourslash/formattingOnSingleLineBlocks.ts +++ b/tests/cases/fourslash/formattingOnSingleLineBlocks.ts @@ -1,16 +1,16 @@ -/// - -/////*1*/class C -////{}/*2*/ -/////*3*/if (true) -////{}/*4*/ - -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("class C"); -goTo.marker("2"); -verify.currentLineContentIs("{ }"); -goTo.marker("3"); -verify.currentLineContentIs("if (true)"); -goTo.marker("4"); +/// + +/////*1*/class C +////{}/*2*/ +/////*3*/if (true) +////{}/*4*/ + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("class C"); +goTo.marker("2"); +verify.currentLineContentIs("{ }"); +goTo.marker("3"); +verify.currentLineContentIs("if (true)"); +goTo.marker("4"); verify.currentLineContentIs("{ }"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnStatementsWithNoSemicolon.ts b/tests/cases/fourslash/formattingOnStatementsWithNoSemicolon.ts index c49152f5011..e33298a5a3b 100644 --- a/tests/cases/fourslash/formattingOnStatementsWithNoSemicolon.ts +++ b/tests/cases/fourslash/formattingOnStatementsWithNoSemicolon.ts @@ -1,170 +1,170 @@ -/// - -/////*1*/do -//// { var a/*2*/ -/////*3*/} while (1) -/////*4*/function f() { -/////*5*/ var s = 1 -/////*6*/ } -/////*7*/switch (t) { -/////*8*/ case 1: -/////*9*/{ -/////*10*/test -/////*11*/} -/////*12*/} -/////*13*/do{do{do{}while(a!==b)}while(a!==b)}while(a!==b) -/////*14*/do{ -/////*15*/do{ -/////*16*/do{ -/////*17*/}while(a!==b) -/////*18*/}while(a!==b) -/////*19*/}while(a!==b) -/////*20*/for(var i=0;i<10;i++){ -/////*21*/for(var j=0;j<10;j++){ -/////*22*/j-=i -/////*23*/}/*24*/} -/////*25*/function foo() { -/////*26*/try { -/////*27*/x+=2 -/////*28*/} -/////*29*/catch( e){ -/////*30*/x+=2 -/////*31*/}finally { -/////*32*/x+=2 -/////*33*/} -/////*34*/} -/////*35*/do { var a } while (1) -//// foo(function (file) {/*49*/ -//// return 0/*50*/ -//// }).then(function (doc) {/*51*/ -//// return 1/*52*/ -//// });/*53*/ -/////*54*/if(1) -/////*55*/if(1) -/////*56*/x++ -/////*57*/else -/////*58*/if(1) -/////*59*/x+=2 -/////*60*/else -/////*61*/x+=2 -//// -//// -//// -/////*62*/; -//// do do do do/*63*/ -//// test;/*64*/ -//// while (0)/*65*/ -//// while (0)/*66*/ -//// while (0)/*67*/ -//// while (0)/*68*/ -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("do {"); -goTo.marker("2"); -verify.currentLineContentIs(" var a"); -goTo.marker("3"); -verify.currentLineContentIs("} while (1)"); -goTo.marker("4"); -verify.currentLineContentIs("function f() {"); -goTo.marker("5"); -verify.currentLineContentIs(" var s = 1"); -goTo.marker("6"); -verify.currentLineContentIs("}"); -goTo.marker("7"); -verify.currentLineContentIs("switch (t) {"); -goTo.marker("8"); -verify.currentLineContentIs(" case 1:"); -goTo.marker("9"); -verify.currentLineContentIs(" {"); -goTo.marker("10"); -verify.currentLineContentIs(" test"); -goTo.marker("11"); -verify.currentLineContentIs(" }"); -goTo.marker("12"); -verify.currentLineContentIs("}"); -goTo.marker("13"); -verify.currentLineContentIs("do { do { do { } while (a !== b) } while (a !== b) } while (a !== b)"); -goTo.marker("14"); -verify.currentLineContentIs("do {"); -goTo.marker("15"); -verify.currentLineContentIs(" do {"); -goTo.marker("16"); -verify.currentLineContentIs(" do {"); -goTo.marker("17"); -verify.currentLineContentIs(" } while (a !== b)"); -goTo.marker("18"); -verify.currentLineContentIs(" } while (a !== b)"); -goTo.marker("19"); -verify.currentLineContentIs("} while (a !== b)"); -goTo.marker("20"); -verify.currentLineContentIs("for (var i = 0; i < 10; i++) {"); -goTo.marker("21"); -verify.currentLineContentIs(" for (var j = 0; j < 10; j++) {"); -goTo.marker("22"); -verify.currentLineContentIs(" j -= i"); -goTo.marker("23"); -verify.currentLineContentIs(" }"); -goTo.marker("24"); -verify.currentLineContentIs(" }"); -goTo.marker("25"); -verify.currentLineContentIs("function foo() {"); -goTo.marker("26"); -verify.currentLineContentIs(" try {"); -goTo.marker("27"); -verify.currentLineContentIs(" x += 2"); -goTo.marker("28"); -verify.currentLineContentIs(" }"); -goTo.marker("29"); -verify.currentLineContentIs(" catch (e) {"); -goTo.marker("30"); -verify.currentLineContentIs(" x += 2"); -goTo.marker("31"); -verify.currentLineContentIs(" } finally {"); -goTo.marker("32"); -verify.currentLineContentIs(" x += 2"); -goTo.marker("33"); -verify.currentLineContentIs(" }"); -goTo.marker("34"); -verify.currentLineContentIs("}"); -goTo.marker("35"); -verify.currentLineContentIs("do { var a } while (1)"); -goTo.marker("49"); -verify.currentLineContentIs("foo(function(file) {"); -goTo.marker("50"); -verify.currentLineContentIs(" return 0"); -goTo.marker("51"); -verify.currentLineContentIs("}).then(function(doc) {"); -goTo.marker("52"); -verify.currentLineContentIs(" return 1"); -goTo.marker("53"); -verify.currentLineContentIs("});"); -goTo.marker("54"); -verify.currentLineContentIs("if (1)"); -goTo.marker("55"); -verify.currentLineContentIs(" if (1)"); -goTo.marker("56"); -verify.currentLineContentIs(" x++"); -goTo.marker("57"); -verify.currentLineContentIs(" else"); -goTo.marker("58"); -verify.currentLineContentIs(" if (1)"); -goTo.marker("59"); -verify.currentLineContentIs(" x += 2"); -goTo.marker("60"); -verify.currentLineContentIs(" else"); -goTo.marker("61"); -verify.currentLineContentIs(" x += 2"); -goTo.marker("62"); -verify.currentLineContentIs(" ;"); -goTo.marker("63"); -verify.currentLineContentIs("do do do do"); -goTo.marker("64"); -verify.currentLineContentIs(" test;"); -goTo.marker("65"); -verify.currentLineContentIs("while (0)"); -goTo.marker("66"); -verify.currentLineContentIs("while (0)"); -goTo.marker("67"); -verify.currentLineContentIs("while (0)"); -goTo.marker("68"); -verify.currentLineContentIs("while (0)"); +/// + +/////*1*/do +//// { var a/*2*/ +/////*3*/} while (1) +/////*4*/function f() { +/////*5*/ var s = 1 +/////*6*/ } +/////*7*/switch (t) { +/////*8*/ case 1: +/////*9*/{ +/////*10*/test +/////*11*/} +/////*12*/} +/////*13*/do{do{do{}while(a!==b)}while(a!==b)}while(a!==b) +/////*14*/do{ +/////*15*/do{ +/////*16*/do{ +/////*17*/}while(a!==b) +/////*18*/}while(a!==b) +/////*19*/}while(a!==b) +/////*20*/for(var i=0;i<10;i++){ +/////*21*/for(var j=0;j<10;j++){ +/////*22*/j-=i +/////*23*/}/*24*/} +/////*25*/function foo() { +/////*26*/try { +/////*27*/x+=2 +/////*28*/} +/////*29*/catch( e){ +/////*30*/x+=2 +/////*31*/}finally { +/////*32*/x+=2 +/////*33*/} +/////*34*/} +/////*35*/do { var a } while (1) +//// foo(function (file) {/*49*/ +//// return 0/*50*/ +//// }).then(function (doc) {/*51*/ +//// return 1/*52*/ +//// });/*53*/ +/////*54*/if(1) +/////*55*/if(1) +/////*56*/x++ +/////*57*/else +/////*58*/if(1) +/////*59*/x+=2 +/////*60*/else +/////*61*/x+=2 +//// +//// +//// +/////*62*/; +//// do do do do/*63*/ +//// test;/*64*/ +//// while (0)/*65*/ +//// while (0)/*66*/ +//// while (0)/*67*/ +//// while (0)/*68*/ +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("do {"); +goTo.marker("2"); +verify.currentLineContentIs(" var a"); +goTo.marker("3"); +verify.currentLineContentIs("} while (1)"); +goTo.marker("4"); +verify.currentLineContentIs("function f() {"); +goTo.marker("5"); +verify.currentLineContentIs(" var s = 1"); +goTo.marker("6"); +verify.currentLineContentIs("}"); +goTo.marker("7"); +verify.currentLineContentIs("switch (t) {"); +goTo.marker("8"); +verify.currentLineContentIs(" case 1:"); +goTo.marker("9"); +verify.currentLineContentIs(" {"); +goTo.marker("10"); +verify.currentLineContentIs(" test"); +goTo.marker("11"); +verify.currentLineContentIs(" }"); +goTo.marker("12"); +verify.currentLineContentIs("}"); +goTo.marker("13"); +verify.currentLineContentIs("do { do { do { } while (a !== b) } while (a !== b) } while (a !== b)"); +goTo.marker("14"); +verify.currentLineContentIs("do {"); +goTo.marker("15"); +verify.currentLineContentIs(" do {"); +goTo.marker("16"); +verify.currentLineContentIs(" do {"); +goTo.marker("17"); +verify.currentLineContentIs(" } while (a !== b)"); +goTo.marker("18"); +verify.currentLineContentIs(" } while (a !== b)"); +goTo.marker("19"); +verify.currentLineContentIs("} while (a !== b)"); +goTo.marker("20"); +verify.currentLineContentIs("for (var i = 0; i < 10; i++) {"); +goTo.marker("21"); +verify.currentLineContentIs(" for (var j = 0; j < 10; j++) {"); +goTo.marker("22"); +verify.currentLineContentIs(" j -= i"); +goTo.marker("23"); +verify.currentLineContentIs(" }"); +goTo.marker("24"); +verify.currentLineContentIs(" }"); +goTo.marker("25"); +verify.currentLineContentIs("function foo() {"); +goTo.marker("26"); +verify.currentLineContentIs(" try {"); +goTo.marker("27"); +verify.currentLineContentIs(" x += 2"); +goTo.marker("28"); +verify.currentLineContentIs(" }"); +goTo.marker("29"); +verify.currentLineContentIs(" catch (e) {"); +goTo.marker("30"); +verify.currentLineContentIs(" x += 2"); +goTo.marker("31"); +verify.currentLineContentIs(" } finally {"); +goTo.marker("32"); +verify.currentLineContentIs(" x += 2"); +goTo.marker("33"); +verify.currentLineContentIs(" }"); +goTo.marker("34"); +verify.currentLineContentIs("}"); +goTo.marker("35"); +verify.currentLineContentIs("do { var a } while (1)"); +goTo.marker("49"); +verify.currentLineContentIs("foo(function(file) {"); +goTo.marker("50"); +verify.currentLineContentIs(" return 0"); +goTo.marker("51"); +verify.currentLineContentIs("}).then(function(doc) {"); +goTo.marker("52"); +verify.currentLineContentIs(" return 1"); +goTo.marker("53"); +verify.currentLineContentIs("});"); +goTo.marker("54"); +verify.currentLineContentIs("if (1)"); +goTo.marker("55"); +verify.currentLineContentIs(" if (1)"); +goTo.marker("56"); +verify.currentLineContentIs(" x++"); +goTo.marker("57"); +verify.currentLineContentIs(" else"); +goTo.marker("58"); +verify.currentLineContentIs(" if (1)"); +goTo.marker("59"); +verify.currentLineContentIs(" x += 2"); +goTo.marker("60"); +verify.currentLineContentIs(" else"); +goTo.marker("61"); +verify.currentLineContentIs(" x += 2"); +goTo.marker("62"); +verify.currentLineContentIs(" ;"); +goTo.marker("63"); +verify.currentLineContentIs("do do do do"); +goTo.marker("64"); +verify.currentLineContentIs(" test;"); +goTo.marker("65"); +verify.currentLineContentIs("while (0)"); +goTo.marker("66"); +verify.currentLineContentIs("while (0)"); +goTo.marker("67"); +verify.currentLineContentIs("while (0)"); +goTo.marker("68"); +verify.currentLineContentIs("while (0)"); diff --git a/tests/cases/fourslash/formattingOnTabAfterCloseCurly.ts b/tests/cases/fourslash/formattingOnTabAfterCloseCurly.ts index 2e7c344d225..e3d9490be03 100644 --- a/tests/cases/fourslash/formattingOnTabAfterCloseCurly.ts +++ b/tests/cases/fourslash/formattingOnTabAfterCloseCurly.ts @@ -1,32 +1,32 @@ -/// - -////module Tools {/*1*/ -//// export enum NodeType {/*2*/ -//// Error,/*3*/ -//// Comment,/*4*/ -//// } /*5*/ -//// export enum foob/*6*/ -//// { -//// Blah=1, Bleah=2/*7*/ -//// }/*8*/ -////}/*9*/ - -format.document(); -goTo.marker("1"); -verify.currentLineContentIs("module Tools {"); -goTo.marker("2"); -verify.currentLineContentIs(" export enum NodeType {"); -goTo.marker("3"); -verify.currentLineContentIs(" Error,"); -goTo.marker("4"); -verify.currentLineContentIs(" Comment,"); -goTo.marker("5"); -verify.currentLineContentIs(" }"); -goTo.marker("6"); -verify.currentLineContentIs(" export enum foob {"); -goTo.marker("7"); -verify.currentLineContentIs(" Blah = 1, Bleah = 2"); -goTo.marker("8"); -verify.currentLineContentIs(" }"); -goTo.marker("9"); +/// + +////module Tools {/*1*/ +//// export enum NodeType {/*2*/ +//// Error,/*3*/ +//// Comment,/*4*/ +//// } /*5*/ +//// export enum foob/*6*/ +//// { +//// Blah=1, Bleah=2/*7*/ +//// }/*8*/ +////}/*9*/ + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs("module Tools {"); +goTo.marker("2"); +verify.currentLineContentIs(" export enum NodeType {"); +goTo.marker("3"); +verify.currentLineContentIs(" Error,"); +goTo.marker("4"); +verify.currentLineContentIs(" Comment,"); +goTo.marker("5"); +verify.currentLineContentIs(" }"); +goTo.marker("6"); +verify.currentLineContentIs(" export enum foob {"); +goTo.marker("7"); +verify.currentLineContentIs(" Blah = 1, Bleah = 2"); +goTo.marker("8"); +verify.currentLineContentIs(" }"); +goTo.marker("9"); verify.currentLineContentIs("}"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingSkippedTokens.ts b/tests/cases/fourslash/formattingSkippedTokens.ts index 094612c8939..3b8ec47bf38 100644 --- a/tests/cases/fourslash/formattingSkippedTokens.ts +++ b/tests/cases/fourslash/formattingSkippedTokens.ts @@ -19,4 +19,4 @@ verify.currentLineContentIs('4 +:5'); goTo.marker('4'); verify.currentLineContentIs(' : T) { }'); goTo.marker('5'); -verify.currentLineContentIs('var x ='); +verify.currentLineContentIs('var x ='); diff --git a/tests/cases/fourslash/formattingSpacesAfterConstructor.ts b/tests/cases/fourslash/formattingSpacesAfterConstructor.ts index fa46feedb4c..8df762def20 100644 --- a/tests/cases/fourslash/formattingSpacesAfterConstructor.ts +++ b/tests/cases/fourslash/formattingSpacesAfterConstructor.ts @@ -1,6 +1,6 @@ -/// - -/////*1*/class test { constructor () { } } -format.document(); -goTo.marker("1"); +/// + +/////*1*/class test { constructor () { } } +format.document(); +goTo.marker("1"); verify.currentLineContentIs("class test { constructor() { } }"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingWithEnterAfterMultilineString.ts b/tests/cases/fourslash/formattingWithEnterAfterMultilineString.ts index 9c35768d865..e64c7be0492 100644 --- a/tests/cases/fourslash/formattingWithEnterAfterMultilineString.ts +++ b/tests/cases/fourslash/formattingWithEnterAfterMultilineString.ts @@ -1,15 +1,15 @@ -/// - -////class Greeter3 { -//// stop() { -//// /*2*/var s = "hello\ -////"/*1*/ -//// } -////} - -goTo.marker("1"); -edit.insert("\r\n"); -// We actually need to verify smart (virtual) identation here rather than actual identation. Fourslash support is required. -verify.indentationIs(8); -goTo.marker("2"); +/// + +////class Greeter3 { +//// stop() { +//// /*2*/var s = "hello\ +////"/*1*/ +//// } +////} + +goTo.marker("1"); +edit.insert("\r\n"); +// We actually need to verify smart (virtual) identation here rather than actual identation. Fourslash support is required. +verify.indentationIs(8); +goTo.marker("2"); verify.currentLineContentIs(" var s = \"hello\\"); \ No newline at end of file diff --git a/tests/cases/fourslash/functionOverloadCount.ts b/tests/cases/fourslash/functionOverloadCount.ts index 00856dcb24a..71dad1d9d72 100644 --- a/tests/cases/fourslash/functionOverloadCount.ts +++ b/tests/cases/fourslash/functionOverloadCount.ts @@ -9,7 +9,7 @@ //// } ////} ////var i = new C1; -////i.attr(/*1*/ - -goTo.marker('1'); +////i.attr(/*1*/ + +goTo.marker('1'); verify.signatureHelpCountIs(3); \ No newline at end of file diff --git a/tests/cases/fourslash/functionRenamingErrorRecovery.ts b/tests/cases/fourslash/functionRenamingErrorRecovery.ts index 0c393560933..0a120022ee9 100644 --- a/tests/cases/fourslash/functionRenamingErrorRecovery.ts +++ b/tests/cases/fourslash/functionRenamingErrorRecovery.ts @@ -1,9 +1,9 @@ -/// - -////class Foo { public bar/*1*//*2*/() { } } - -goTo.marker("1"); -edit.backspace(3); -edit.insert("Pizza"); -verify.currentLineContentIs("class Foo { public Pizza() { } }"); +/// + +////class Foo { public bar/*1*//*2*/() { } } + +goTo.marker("1"); +edit.backspace(3); +edit.insert("Pizza"); +verify.currentLineContentIs("class Foo { public Pizza() { } }"); verify.not.errorExistsAfterMarker("2"); \ No newline at end of file diff --git a/tests/cases/fourslash/genericArityEnforcementAfterEdit.ts b/tests/cases/fourslash/genericArityEnforcementAfterEdit.ts index 899a4387f91..5b107e3779e 100644 --- a/tests/cases/fourslash/genericArityEnforcementAfterEdit.ts +++ b/tests/cases/fourslash/genericArityEnforcementAfterEdit.ts @@ -1,10 +1,10 @@ -/// - -//// interface G { } -//// /**/ -//// var v4: G, any>; - -verify.numberOfErrorsInCurrentFile(1); -goTo.marker(); -edit.insert(' '); -verify.numberOfErrorsInCurrentFile(1); +/// + +//// interface G { } +//// /**/ +//// var v4: G, any>; + +verify.numberOfErrorsInCurrentFile(1); +goTo.marker(); +edit.insert(' '); +verify.numberOfErrorsInCurrentFile(1); diff --git a/tests/cases/fourslash/genericRespecialization1.ts b/tests/cases/fourslash/genericRespecialization1.ts index 34eff798060..e8db5eafc4a 100644 --- a/tests/cases/fourslash/genericRespecialization1.ts +++ b/tests/cases/fourslash/genericRespecialization1.ts @@ -1,75 +1,75 @@ -/// - -//// class Food { -//// private amount: number; -//// constructor(public name: string) { -//// this.amount = 100; -//// } -//// public eat(amountToEat: number): boolean { -//// this.amount -= amountToEat; -//// if (this.amount <= 0) { -//// this.amount = 0; -//// return false; -//// } -//// else { -//// return true; -//// } -//// } -//// } -//// class IceCream extends Food { -//// private isDairyFree: boolean; -//// constructor(public flavor: string) { -//// super("Ice Cream"); -//// } -//// } -//// class Cookie extends Food { -//// constructor(public flavor: string, public isGlutenFree: boolean) { -//// super("Cookie"); -//// } -//// } -//// class Slug { -//// // This is NOT a food!!! -//// } -//// class GenericMonster { -//// private name: string; -//// private age: number; -//// private isFriendly: boolean; -//// constructor(name: string, age: number, isFriendly: boolean, private food: T, public variant: V) { -//// this.name = name; -//// this.age = age; -//// this.isFriendly = isFriendly; -//// } -//// public getFood(): T { -//// return this.food; -//// } -//// public getVariant(): V { -//// return this.variant; -//// } -//// public eatFood(amountToEat: number): boolean { -//// return this.food.eat(amountToEat); -//// } -//// public sayGreeting(): string { -//// return ("My name is " + this.name + ", and my age is " + this.age + ". I enjoy eating " + this.food.name + " and my variant is " + this.variant); -//// } -//// } -//// class GenericPlanet> { -//// constructor(public name: string, public solarSystem: string, public species: T) { } -//// } -//// var cookie = new Cookie("Chocolate Chip", false); -//// var cookieMonster = new GenericMonster("Cookie Monster", 50, true, cookie, "hello"); -//// var sesameStreet = new GenericPlanet>("Sesame Street", "Alpha Centuri", cookieMonster); -//// class GenericPlanet2{ -//// constructor(public name: string, public solarSystem: string, public species: GenericMonster) { } -//// } -//// /*1*/ - -verify.numberOfErrorsInCurrentFile(0); -goTo.marker('1'); -edit.insertLine(''); -edit.insertLine(''); -verify.numberOfErrorsInCurrentFile(0); -goTo.marker('2'); -edit.deleteAtCaret("Cookie".length); -edit.insert("any"); -verify.numberOfErrorsInCurrentFile(0); +/// + +//// class Food { +//// private amount: number; +//// constructor(public name: string) { +//// this.amount = 100; +//// } +//// public eat(amountToEat: number): boolean { +//// this.amount -= amountToEat; +//// if (this.amount <= 0) { +//// this.amount = 0; +//// return false; +//// } +//// else { +//// return true; +//// } +//// } +//// } +//// class IceCream extends Food { +//// private isDairyFree: boolean; +//// constructor(public flavor: string) { +//// super("Ice Cream"); +//// } +//// } +//// class Cookie extends Food { +//// constructor(public flavor: string, public isGlutenFree: boolean) { +//// super("Cookie"); +//// } +//// } +//// class Slug { +//// // This is NOT a food!!! +//// } +//// class GenericMonster { +//// private name: string; +//// private age: number; +//// private isFriendly: boolean; +//// constructor(name: string, age: number, isFriendly: boolean, private food: T, public variant: V) { +//// this.name = name; +//// this.age = age; +//// this.isFriendly = isFriendly; +//// } +//// public getFood(): T { +//// return this.food; +//// } +//// public getVariant(): V { +//// return this.variant; +//// } +//// public eatFood(amountToEat: number): boolean { +//// return this.food.eat(amountToEat); +//// } +//// public sayGreeting(): string { +//// return ("My name is " + this.name + ", and my age is " + this.age + ". I enjoy eating " + this.food.name + " and my variant is " + this.variant); +//// } +//// } +//// class GenericPlanet> { +//// constructor(public name: string, public solarSystem: string, public species: T) { } +//// } +//// var cookie = new Cookie("Chocolate Chip", false); +//// var cookieMonster = new GenericMonster("Cookie Monster", 50, true, cookie, "hello"); +//// var sesameStreet = new GenericPlanet>("Sesame Street", "Alpha Centuri", cookieMonster); +//// class GenericPlanet2{ +//// constructor(public name: string, public solarSystem: string, public species: GenericMonster) { } +//// } +//// /*1*/ + +verify.numberOfErrorsInCurrentFile(0); +goTo.marker('1'); +edit.insertLine(''); +edit.insertLine(''); +verify.numberOfErrorsInCurrentFile(0); +goTo.marker('2'); +edit.deleteAtCaret("Cookie".length); +edit.insert("any"); +verify.numberOfErrorsInCurrentFile(0); edit.insertLine('var narnia = new GenericPlanet2('); // shouldn't crash at this point \ No newline at end of file diff --git a/tests/cases/fourslash/getDeclarationDiagnostics.ts b/tests/cases/fourslash/getDeclarationDiagnostics.ts index 693261d62b4..0dcc9fea6a6 100644 --- a/tests/cases/fourslash/getDeclarationDiagnostics.ts +++ b/tests/cases/fourslash/getDeclarationDiagnostics.ts @@ -1,19 +1,19 @@ -/// - -// @declaration: true -// @out: true - -// @Filename: inputFile1.ts -//// module m { -//// export class C implements I { } -//// interface I { } -//// } /*1*/ - -// @Filename: input2.ts -//// var x = "hello world"; /*2*/ - -goTo.marker("1"); -verify.numberOfErrorsInCurrentFile(1); - -goTo.marker("2"); -verify.numberOfErrorsInCurrentFile(0); +/// + +// @declaration: true +// @out: true + +// @Filename: inputFile1.ts +//// module m { +//// export class C implements I { } +//// interface I { } +//// } /*1*/ + +// @Filename: input2.ts +//// var x = "hello world"; /*2*/ + +goTo.marker("1"); +verify.numberOfErrorsInCurrentFile(1); + +goTo.marker("2"); +verify.numberOfErrorsInCurrentFile(0); diff --git a/tests/cases/fourslash/getEmitOutputDeclarationMultiFiles.ts b/tests/cases/fourslash/getEmitOutputDeclarationMultiFiles.ts index b9c7f5a0db9..8148dd3960d 100644 --- a/tests/cases/fourslash/getEmitOutputDeclarationMultiFiles.ts +++ b/tests/cases/fourslash/getEmitOutputDeclarationMultiFiles.ts @@ -1,22 +1,22 @@ -/// - -// @BaselineFile: getEmitOutputDeclarationMultiFiles.baseline -// @declaration: true - -// @Filename: inputFile1.ts -// @emitThisFile: true -//// var x: number = 5; -//// class Bar { -//// x : string; -//// y : number -//// } - -// @Filename: inputFile2.ts -// @emitThisFile: true -//// var x1: string = "hello world"; -//// class Foo{ -//// x : string; -//// y : number; -//// } - +/// + +// @BaselineFile: getEmitOutputDeclarationMultiFiles.baseline +// @declaration: true + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// var x: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.ts +// @emitThisFile: true +//// var x1: string = "hello world"; +//// class Foo{ +//// x : string; +//// y : number; +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputDeclarationSingleFile.ts b/tests/cases/fourslash/getEmitOutputDeclarationSingleFile.ts index b8e9c58f5b0..502e3903d75 100644 --- a/tests/cases/fourslash/getEmitOutputDeclarationSingleFile.ts +++ b/tests/cases/fourslash/getEmitOutputDeclarationSingleFile.ts @@ -1,22 +1,22 @@ -/// - -// @BaselineFile: getEmitOutputDeclarationSingleFile.baseline -// @declaration: true -// @out: declSingleFile.js - -// @Filename: inputFile1.ts -// @emitThisFile: true -//// var x: number = 5; -//// class Bar { -//// x : string; -//// y : number -//// } - -// @Filename: inputFile2.ts -//// var x1: string = "hello world"; -//// class Foo{ -//// x : string; -//// y : number; -//// } - +/// + +// @BaselineFile: getEmitOutputDeclarationSingleFile.baseline +// @declaration: true +// @out: declSingleFile.js + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// var x: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.ts +//// var x1: string = "hello world"; +//// class Foo{ +//// x : string; +//// y : number; +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputExternalModule.ts b/tests/cases/fourslash/getEmitOutputExternalModule.ts index ef9fb348c57..080cd56e976 100644 --- a/tests/cases/fourslash/getEmitOutputExternalModule.ts +++ b/tests/cases/fourslash/getEmitOutputExternalModule.ts @@ -1,19 +1,19 @@ -/// - -// @BaselineFile: getEmitOutputExternalModule.baseline -// @out: declSingleFile.js - -// @Filename: inputFile1.ts -// @emitThisFile: true -//// var x: number = 5; -//// class Bar { -//// x : string; -//// y : number -//// } - -// @Filename: inputFile2.ts -//// export module M { -//// class C {c} -//// } - +/// + +// @BaselineFile: getEmitOutputExternalModule.baseline +// @out: declSingleFile.js + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// var x: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.ts +//// export module M { +//// class C {c} +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputExternalModule2.ts b/tests/cases/fourslash/getEmitOutputExternalModule2.ts index abecc219698..f4b55abc2ea 100644 --- a/tests/cases/fourslash/getEmitOutputExternalModule2.ts +++ b/tests/cases/fourslash/getEmitOutputExternalModule2.ts @@ -1,26 +1,26 @@ -/// - -// @BaselineFile: getEmitOutputExternalModule2.baseline -// @out: declSingleFile.js - -// @Filename: inputFile1.ts -//// var x: number = 5; -//// class Bar { -//// x : string; -//// y : number -//// } - -// @Filename: inputFile2.ts -// @emitThisFile: true -//// var x: string = "world"; -//// class Bar2 { -//// x : string; -//// y : number -//// } - -// @Filename: inputFile3.ts -//// export module M { -//// class C {c} -//// } - +/// + +// @BaselineFile: getEmitOutputExternalModule2.baseline +// @out: declSingleFile.js + +// @Filename: inputFile1.ts +//// var x: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.ts +// @emitThisFile: true +//// var x: string = "world"; +//// class Bar2 { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile3.ts +//// export module M { +//// class C {c} +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputMapRoot.ts b/tests/cases/fourslash/getEmitOutputMapRoot.ts index 15932d41c32..7cbaf5d60b1 100644 --- a/tests/cases/fourslash/getEmitOutputMapRoot.ts +++ b/tests/cases/fourslash/getEmitOutputMapRoot.ts @@ -1,17 +1,17 @@ -/// - -// @BaselineFile: getEmitOutputMapRoots.baseline -// @out: declSingleFile.js -// @sourceMap: true -// @mapRoot: mapRootDir/ - -// @Filename: inputFile.ts -// @emitThisFile: true -//// var x = 109; -//// var foo = "hello world"; -//// class M { -//// x: number; -//// y: string; -//// } - +/// + +// @BaselineFile: getEmitOutputMapRoots.baseline +// @out: declSingleFile.js +// @sourceMap: true +// @mapRoot: mapRootDir/ + +// @Filename: inputFile.ts +// @emitThisFile: true +//// var x = 109; +//// var foo = "hello world"; +//// class M { +//// x: number; +//// y: string; +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputNoErrors.ts b/tests/cases/fourslash/getEmitOutputNoErrors.ts index b48a86a03ab..6ef4f34da51 100644 --- a/tests/cases/fourslash/getEmitOutputNoErrors.ts +++ b/tests/cases/fourslash/getEmitOutputNoErrors.ts @@ -1,12 +1,12 @@ -/// - -// @BaselineFile: getEmitOutputNoErrors.baseline -// @Filename: inputFile.ts -// @emitThisFile: true -//// var x; -//// class M { -//// x: number; -//// y: string; -//// } - +/// + +// @BaselineFile: getEmitOutputNoErrors.baseline +// @Filename: inputFile.ts +// @emitThisFile: true +//// var x; +//// class M { +//// x: number; +//// y: string; +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputOnlyOneFile.ts b/tests/cases/fourslash/getEmitOutputOnlyOneFile.ts index 2ad822741f2..ecf042f9184 100644 --- a/tests/cases/fourslash/getEmitOutputOnlyOneFile.ts +++ b/tests/cases/fourslash/getEmitOutputOnlyOneFile.ts @@ -1,20 +1,20 @@ -/// - -// @BaselineFile: getEmitOutputOnlyOneFile.baseline - -// @Filename: inputFile1.ts -//// var x: any; -//// class Bar { -//// x : string; -//// y : number -//// } - -// @Filename: inputFile2.ts -// @emitThisFile: true -//// var x: any; -//// class Foo{ -//// x : string; -//// y : number -//// } - +/// + +// @BaselineFile: getEmitOutputOnlyOneFile.baseline + +// @Filename: inputFile1.ts +//// var x: any; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.ts +// @emitThisFile: true +//// var x: any; +//// class Foo{ +//// x : string; +//// y : number +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputSingleFile.ts b/tests/cases/fourslash/getEmitOutputSingleFile.ts index ec774149f4b..babeb8dee14 100644 --- a/tests/cases/fourslash/getEmitOutputSingleFile.ts +++ b/tests/cases/fourslash/getEmitOutputSingleFile.ts @@ -1,21 +1,21 @@ -/// - -// @BaselineFile: getEmitOutputSingleFile.baseline -// @out: outputDir/singleFile.js - -// @Filename: inputFile1.ts -//// var x: any; -//// class Bar { -//// x : string; -//// y : number -//// } - -// @Filename: inputFile2.ts -// @emitThisFile: true -//// var x: any; -//// class Foo{ -//// x : string; -//// y : number -//// } - +/// + +// @BaselineFile: getEmitOutputSingleFile.baseline +// @out: outputDir/singleFile.js + +// @Filename: inputFile1.ts +//// var x: any; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.ts +// @emitThisFile: true +//// var x: any; +//// class Foo{ +//// x : string; +//// y : number +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputSingleFile2.ts b/tests/cases/fourslash/getEmitOutputSingleFile2.ts index 8bf4f7f4af7..5dd0276a936 100644 --- a/tests/cases/fourslash/getEmitOutputSingleFile2.ts +++ b/tests/cases/fourslash/getEmitOutputSingleFile2.ts @@ -1,28 +1,28 @@ -/// - -// @BaselineFile: getEmitOutputSingleFile2.baseline -// @module: CommonJS -// @declaration: true -// @out: declSingleFile.js -// @outDir: tests/cases/fourslash/ - -// @Filename: inputFile1.ts -//// var x: number = 5; -//// class Bar { -//// x : string; -//// y : number -//// } - -// @Filename: inputFile2.ts -//// var x1: string = "hello world"; -//// class Foo{ -//// x : string; -//// y : number; -//// } - -// @Filename: inputFile3.ts -// @emitThisFile: true -////export var foo = 10; -////export var bar = "hello world" - +/// + +// @BaselineFile: getEmitOutputSingleFile2.baseline +// @module: CommonJS +// @declaration: true +// @out: declSingleFile.js +// @outDir: tests/cases/fourslash/ + +// @Filename: inputFile1.ts +//// var x: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.ts +//// var x1: string = "hello world"; +//// class Foo{ +//// x : string; +//// y : number; +//// } + +// @Filename: inputFile3.ts +// @emitThisFile: true +////export var foo = 10; +////export var bar = "hello world" + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputSourceMap.ts b/tests/cases/fourslash/getEmitOutputSourceMap.ts index df02af35ec3..24e37648064 100644 --- a/tests/cases/fourslash/getEmitOutputSourceMap.ts +++ b/tests/cases/fourslash/getEmitOutputSourceMap.ts @@ -1,15 +1,15 @@ -/// - -// @BaselineFile: getEmitOutputSourceMap.baseline -// @sourceMap: true - -// @Filename: inputFile.ts -// @emitThisFile: true -//// var x = 109; -//// var foo = "hello world"; -//// class M { -//// x: number; -//// y: string; -//// } - +/// + +// @BaselineFile: getEmitOutputSourceMap.baseline +// @sourceMap: true + +// @Filename: inputFile.ts +// @emitThisFile: true +//// var x = 109; +//// var foo = "hello world"; +//// class M { +//// x: number; +//// y: string; +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputSourceMap2.ts b/tests/cases/fourslash/getEmitOutputSourceMap2.ts index a8b43328ea5..4b4b1185c7a 100644 --- a/tests/cases/fourslash/getEmitOutputSourceMap2.ts +++ b/tests/cases/fourslash/getEmitOutputSourceMap2.ts @@ -1,23 +1,23 @@ -/// - -// @BaselineFile: getEmitOutputSourceMap2.baseline -// @sourceMap: true -// @outDir: sample/outDir - -// @Filename: inputFile1.ts -// @emitThisFile: true -//// var x = 109; -//// var foo = "hello world"; -//// class M { -//// x: number; -//// y: string; -//// } - -// @Filename: inputFile2.ts -// @emitThisFile: true -//// var intro = "hello world"; -//// if (intro !== undefined) { -//// var k = 10; -//// } - +/// + +// @BaselineFile: getEmitOutputSourceMap2.baseline +// @sourceMap: true +// @outDir: sample/outDir + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// var x = 109; +//// var foo = "hello world"; +//// class M { +//// x: number; +//// y: string; +//// } + +// @Filename: inputFile2.ts +// @emitThisFile: true +//// var intro = "hello world"; +//// if (intro !== undefined) { +//// var k = 10; +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputSourceRoot.ts b/tests/cases/fourslash/getEmitOutputSourceRoot.ts index b260e593098..ac7d63558e4 100644 --- a/tests/cases/fourslash/getEmitOutputSourceRoot.ts +++ b/tests/cases/fourslash/getEmitOutputSourceRoot.ts @@ -1,16 +1,16 @@ -/// - -// @BaselineFile: getEmitOutputSourceRoot.baseline -// @sourceMap: true -// @sourceRoot: sourceRootDir/ - -// @Filename: inputFile.ts -// @emitThisFile: true -//// var x = 109; -//// var foo = "hello world"; -//// class M { -//// x: number; -//// y: string; -//// } - +/// + +// @BaselineFile: getEmitOutputSourceRoot.baseline +// @sourceMap: true +// @sourceRoot: sourceRootDir/ + +// @Filename: inputFile.ts +// @emitThisFile: true +//// var x = 109; +//// var foo = "hello world"; +//// class M { +//// x: number; +//// y: string; +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputSourceRootMultiFiles.ts b/tests/cases/fourslash/getEmitOutputSourceRootMultiFiles.ts index bddf9e423ce..7360f9f27ef 100644 --- a/tests/cases/fourslash/getEmitOutputSourceRootMultiFiles.ts +++ b/tests/cases/fourslash/getEmitOutputSourceRootMultiFiles.ts @@ -1,24 +1,24 @@ -/// - -// @BaselineFile: getEmitOutputSourceRootMultiFiles.baseline -// @sourceMap: true -// @sourceRoot: sourceRootDir/ - -// @Filename: inputFile1.ts -// @emitThisFile: true -//// var x = 109; -//// var foo = "hello world"; -//// class M { -//// x: number; -//// y: string; -//// } - -// @Filename: inputFile2.ts -// @emitThisFile: true -//// var bar = "hello world Typescript"; -//// class C { -//// x: number; -//// y: string[]; -//// } - +/// + +// @BaselineFile: getEmitOutputSourceRootMultiFiles.baseline +// @sourceMap: true +// @sourceRoot: sourceRootDir/ + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// var x = 109; +//// var foo = "hello world"; +//// class M { +//// x: number; +//// y: string; +//// } + +// @Filename: inputFile2.ts +// @emitThisFile: true +//// var bar = "hello world Typescript"; +//// class C { +//// x: number; +//// y: string[]; +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputWithDeclarationFile.ts b/tests/cases/fourslash/getEmitOutputWithDeclarationFile.ts index d15b49755d3..9e73a8490da 100644 --- a/tests/cases/fourslash/getEmitOutputWithDeclarationFile.ts +++ b/tests/cases/fourslash/getEmitOutputWithDeclarationFile.ts @@ -1,17 +1,17 @@ -/// - -// @BaselineFile: getEmitOutputWithDeclarationFile.baseline - -// @Filename: decl.d.ts -// @emitThisFile: true -//// interface I { a: string; } - -// @Filename: inputFile2.ts -// @emitThisFile: true -//// var x1: string = "hello world"; -//// class Foo{ -//// x : string; -//// y : number; -//// } - +/// + +// @BaselineFile: getEmitOutputWithDeclarationFile.baseline + +// @Filename: decl.d.ts +// @emitThisFile: true +//// interface I { a: string; } + +// @Filename: inputFile2.ts +// @emitThisFile: true +//// var x1: string = "hello world"; +//// class Foo{ +//// x : string; +//// y : number; +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputWithDeclarationFile2.ts b/tests/cases/fourslash/getEmitOutputWithDeclarationFile2.ts index ac68611246b..8f8e21cbcbb 100644 --- a/tests/cases/fourslash/getEmitOutputWithDeclarationFile2.ts +++ b/tests/cases/fourslash/getEmitOutputWithDeclarationFile2.ts @@ -1,18 +1,18 @@ -/// - -// @BaselineFile: getEmitOutputWithDeclarationFile2.baseline -// @module: CommonJS - -// @Filename: decl.d.ts -// @emitThisFile: true -//// interface I { a: string; } - -// @Filename: inputFile2.ts -// @emitThisFile: true -//// export class Foo { } - -// @Filename: inputFile3.ts -// @emitThisFile: true -//// var x:string = "hello"; - +/// + +// @BaselineFile: getEmitOutputWithDeclarationFile2.baseline +// @module: CommonJS + +// @Filename: decl.d.ts +// @emitThisFile: true +//// interface I { a: string; } + +// @Filename: inputFile2.ts +// @emitThisFile: true +//// export class Foo { } + +// @Filename: inputFile3.ts +// @emitThisFile: true +//// var x:string = "hello"; + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputWithDeclarationFile3.ts b/tests/cases/fourslash/getEmitOutputWithDeclarationFile3.ts index 266edaf23e1..60f7b433149 100644 --- a/tests/cases/fourslash/getEmitOutputWithDeclarationFile3.ts +++ b/tests/cases/fourslash/getEmitOutputWithDeclarationFile3.ts @@ -1,22 +1,22 @@ -/// - -// @BaselineFile: getEmitOutputWithDeclarationFile3.baseline -// @out: declSingle.js - -// @Filename: decl.d.ts -//// interface I { a: string; } - -// @Filename: inputFile2.ts -//// export class Foo { } - -// @Filename: inputFile3.ts -// @emitThisFile: true -//// var x:string = "hello"; - -// @Filename: inputFile4.ts -//// var x1:number = 1000; - -// @Filename: inputFile5.js -//// var x2 = 1000; -debugger; +/// + +// @BaselineFile: getEmitOutputWithDeclarationFile3.baseline +// @out: declSingle.js + +// @Filename: decl.d.ts +//// interface I { a: string; } + +// @Filename: inputFile2.ts +//// export class Foo { } + +// @Filename: inputFile3.ts +// @emitThisFile: true +//// var x:string = "hello"; + +// @Filename: inputFile4.ts +//// var x1:number = 1000; + +// @Filename: inputFile5.js +//// var x2 = 1000; +debugger; verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputWithEarlySemanticErrors.ts b/tests/cases/fourslash/getEmitOutputWithEarlySemanticErrors.ts index 2946fffb808..58d6ce19ed1 100644 --- a/tests/cases/fourslash/getEmitOutputWithEarlySemanticErrors.ts +++ b/tests/cases/fourslash/getEmitOutputWithEarlySemanticErrors.ts @@ -1,10 +1,10 @@ -/// - -// @BaselineFile: getEmitOutputWithEarlySyntacticErrors.baseline - -// @Filename: inputFile1.ts -// @emitThisFile: true -//// // File contains early errors. All outputs should be skipped. -//// const uninitialized_const_error; - +/// + +// @BaselineFile: getEmitOutputWithEarlySyntacticErrors.baseline + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// // File contains early errors. All outputs should be skipped. +//// const uninitialized_const_error; + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputWithEmitterErrors.ts b/tests/cases/fourslash/getEmitOutputWithEmitterErrors.ts index ba643f996d7..0d2f488e433 100644 --- a/tests/cases/fourslash/getEmitOutputWithEmitterErrors.ts +++ b/tests/cases/fourslash/getEmitOutputWithEmitterErrors.ts @@ -1,15 +1,15 @@ -/// - -// @BaselineFile: getEmitOutputWithEmitterErrors.baseline -// @declaration: true - -// @Filename: inputFile.ts -// @emitThisFile: true -////module M { -//// class C { } -//// export var foo = new C(); -////} - - -// Only generate javscript file. The semantic error should not affect it +/// + +// @BaselineFile: getEmitOutputWithEmitterErrors.baseline +// @declaration: true + +// @Filename: inputFile.ts +// @emitThisFile: true +////module M { +//// class C { } +//// export var foo = new C(); +////} + + +// Only generate javscript file. The semantic error should not affect it verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputWithEmitterErrors2.ts b/tests/cases/fourslash/getEmitOutputWithEmitterErrors2.ts index 5240a102a28..865c94adcae 100644 --- a/tests/cases/fourslash/getEmitOutputWithEmitterErrors2.ts +++ b/tests/cases/fourslash/getEmitOutputWithEmitterErrors2.ts @@ -1,14 +1,14 @@ -/// - -// @BaselineFile: getEmitOutputWithEmitterErrors2.baseline -// @declaration: true -// @module: AMD - -// @Filename: inputFile.ts -// @emitThisFile: true -////class C { } -////export module M { -//// export var foo = new C(); -////} - +/// + +// @BaselineFile: getEmitOutputWithEmitterErrors2.baseline +// @declaration: true +// @module: AMD + +// @Filename: inputFile.ts +// @emitThisFile: true +////class C { } +////export module M { +//// export var foo = new C(); +////} + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputWithSemanticErrors.ts b/tests/cases/fourslash/getEmitOutputWithSemanticErrors.ts index b4e3a50b0e8..13aeda82cc8 100644 --- a/tests/cases/fourslash/getEmitOutputWithSemanticErrors.ts +++ b/tests/cases/fourslash/getEmitOutputWithSemanticErrors.ts @@ -1,9 +1,9 @@ -/// - -// @BaselineFile: getEmitOutputWithSemanticErrors.baseline - -// @Filename: inputFile.ts -// @emitThisFile: true -//// var x:number = "hello world"; - +/// + +// @BaselineFile: getEmitOutputWithSemanticErrors.baseline + +// @Filename: inputFile.ts +// @emitThisFile: true +//// var x:number = "hello world"; + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputWithSemanticErrors2.ts b/tests/cases/fourslash/getEmitOutputWithSemanticErrors2.ts index c67ef0fd29d..174b42bb37e 100644 --- a/tests/cases/fourslash/getEmitOutputWithSemanticErrors2.ts +++ b/tests/cases/fourslash/getEmitOutputWithSemanticErrors2.ts @@ -1,10 +1,10 @@ -/// - -// @BaselineFile: getEmitOutputWithSemanticErrors2.baseline -// @declaration: true - -// @Filename: inputFile.ts -// @emitThisFile: true -//// var x:number = "hello world"; - +/// + +// @BaselineFile: getEmitOutputWithSemanticErrors2.baseline +// @declaration: true + +// @Filename: inputFile.ts +// @emitThisFile: true +//// var x:number = "hello world"; + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputWithSemanticErrorsForMultipleFiles.ts b/tests/cases/fourslash/getEmitOutputWithSemanticErrorsForMultipleFiles.ts index 69f8b8a8b41..d24bcfbf504 100644 --- a/tests/cases/fourslash/getEmitOutputWithSemanticErrorsForMultipleFiles.ts +++ b/tests/cases/fourslash/getEmitOutputWithSemanticErrorsForMultipleFiles.ts @@ -1,16 +1,16 @@ -/// - -// @BaselineFile: getEmitOutputWithSemanticErrorsForMultipleFiles.baseline -// @declaration: true - -// @Filename: inputFile1.ts -// @emitThisFile: true -//// // File to emit, does not contain semantic errors -//// // expected to be emitted correctelly regardless of the semantic errors in the other file -//// var noErrors = true; - -// @Filename: inputFile2.ts -//// // File not emitted, and contains semantic errors -//// var semanticError: boolean = "string"; -debugger; +/// + +// @BaselineFile: getEmitOutputWithSemanticErrorsForMultipleFiles.baseline +// @declaration: true + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// // File to emit, does not contain semantic errors +//// // expected to be emitted correctelly regardless of the semantic errors in the other file +//// var noErrors = true; + +// @Filename: inputFile2.ts +//// // File not emitted, and contains semantic errors +//// var semanticError: boolean = "string"; +debugger; verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputWithSemanticErrorsForMultipleFiles2.ts b/tests/cases/fourslash/getEmitOutputWithSemanticErrorsForMultipleFiles2.ts index d5cfd1346ca..95a4ac78a88 100644 --- a/tests/cases/fourslash/getEmitOutputWithSemanticErrorsForMultipleFiles2.ts +++ b/tests/cases/fourslash/getEmitOutputWithSemanticErrorsForMultipleFiles2.ts @@ -1,17 +1,17 @@ -/// - -// @BaselineFile: getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline -// @declaration: true -// @out: out.js - -// @Filename: inputFile1.ts -// @emitThisFile: true -//// // File to emit, does not contain semantic errors, but --out is passed -//// // expected to not generate declarations because of the semantic errors in the other file -//// var noErrors = true; - -// @Filename: inputFile2.ts -//// // File not emitted, and contains semantic errors -//// var semanticError: boolean = "string"; - +/// + +// @BaselineFile: getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline +// @declaration: true +// @out: out.js + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// // File to emit, does not contain semantic errors, but --out is passed +//// // expected to not generate declarations because of the semantic errors in the other file +//// var noErrors = true; + +// @Filename: inputFile2.ts +//// // File not emitted, and contains semantic errors +//// var semanticError: boolean = "string"; + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputWithSyntacticErrorsForMultipleFiles.ts b/tests/cases/fourslash/getEmitOutputWithSyntacticErrorsForMultipleFiles.ts index 3b3d01eaac8..c2ddd3ea004 100644 --- a/tests/cases/fourslash/getEmitOutputWithSyntacticErrorsForMultipleFiles.ts +++ b/tests/cases/fourslash/getEmitOutputWithSyntacticErrorsForMultipleFiles.ts @@ -1,15 +1,15 @@ -/// - -// @BaselineFile: getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline - -// @Filename: inputFile1.ts -// @emitThisFile: true -//// // File to emit, does not contain syntactic errors -//// // expected to be emitted correctelly regardless of the syntactic errors in the other file -//// var noErrors = true; - -// @Filename: inputFile2.ts -//// // File not emitted, and contains syntactic errors -//// var syntactic Error; - +/// + +// @BaselineFile: getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// // File to emit, does not contain syntactic errors +//// // expected to be emitted correctelly regardless of the syntactic errors in the other file +//// var noErrors = true; + +// @Filename: inputFile2.ts +//// // File not emitted, and contains syntactic errors +//// var syntactic Error; + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputWithSyntacticErrorsForMultipleFiles2.ts b/tests/cases/fourslash/getEmitOutputWithSyntacticErrorsForMultipleFiles2.ts index ce82f958b91..f66e6563c81 100644 --- a/tests/cases/fourslash/getEmitOutputWithSyntacticErrorsForMultipleFiles2.ts +++ b/tests/cases/fourslash/getEmitOutputWithSyntacticErrorsForMultipleFiles2.ts @@ -1,16 +1,16 @@ -/// - -// @BaselineFile: getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline -// @out: out.js - -// @Filename: inputFile1.ts -// @emitThisFile: true -//// // File to emit, does not contain syntactic errors, but --out is passed -//// // expected to not generate outputs because of the syntactic errors in the other file. -//// var noErrors = true; - -// @Filename: inputFile2.ts -//// // File not emitted, and contains syntactic errors -//// var syntactic Error; - +/// + +// @BaselineFile: getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline +// @out: out.js + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// // File to emit, does not contain syntactic errors, but --out is passed +//// // expected to not generate outputs because of the syntactic errors in the other file. +//// var noErrors = true; + +// @Filename: inputFile2.ts +//// // File not emitted, and contains syntactic errors +//// var syntactic Error; + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputWithSyntaxErrors.ts b/tests/cases/fourslash/getEmitOutputWithSyntaxErrors.ts index 87e9bb076a5..4d094f463d1 100644 --- a/tests/cases/fourslash/getEmitOutputWithSyntaxErrors.ts +++ b/tests/cases/fourslash/getEmitOutputWithSyntaxErrors.ts @@ -1,9 +1,9 @@ -/// - -// @BaselineFile: getEmitOutputWithSyntaxErrors.baseline - -// @Filename: inputFile.ts -// @emitThisFile: true -//// var x: - +/// + +// @BaselineFile: getEmitOutputWithSyntaxErrors.baseline + +// @Filename: inputFile.ts +// @emitThisFile: true +//// var x: + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getMatchingBracesAdjacentBraces.ts b/tests/cases/fourslash/getMatchingBracesAdjacentBraces.ts index 8dd997ebe73..0dbd5630a5f 100644 --- a/tests/cases/fourslash/getMatchingBracesAdjacentBraces.ts +++ b/tests/cases/fourslash/getMatchingBracesAdjacentBraces.ts @@ -1,4 +1,4 @@ -////function f[||][|(x: T)|][|{ +////function f[||][|(x: T)|][|{ //// return x; ////}|] diff --git a/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts b/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts index ac74fc2192f..51d5907a5d6 100644 --- a/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts +++ b/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts @@ -1,4 +1,4 @@ -/// +/// ////class C { //// [|export|] foo; diff --git a/tests/cases/fourslash/getOccurrencesPropertyInAliasedInterface.ts b/tests/cases/fourslash/getOccurrencesPropertyInAliasedInterface.ts index f9d47b07478..53840fc3bd9 100644 --- a/tests/cases/fourslash/getOccurrencesPropertyInAliasedInterface.ts +++ b/tests/cases/fourslash/getOccurrencesPropertyInAliasedInterface.ts @@ -1,4 +1,4 @@ -////module m { +////module m { //// export interface Foo { //// [|abc|] //// } diff --git a/tests/cases/fourslash/getOccurrencesSetAndGet.ts b/tests/cases/fourslash/getOccurrencesSetAndGet.ts index b1ab6f44c6b..ddeaf8f26ff 100644 --- a/tests/cases/fourslash/getOccurrencesSetAndGet.ts +++ b/tests/cases/fourslash/getOccurrencesSetAndGet.ts @@ -1,34 +1,34 @@ -/// - -////class Foo { -//// [|set|] bar(b: any) { -//// } -//// -//// public [|get|] bar(): any { -//// return undefined; -//// } -//// -//// public set set(s: any) { -//// } -//// -//// public get set(): any { -//// return undefined; -//// } -//// -//// public set get(g: any) { -//// } -//// -//// public get get(): any { -//// return undefined; -//// } -////} - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); +/// + +////class Foo { +//// [|set|] bar(b: any) { +//// } +//// +//// public [|get|] bar(): any { +//// return undefined; +//// } +//// +//// public set set(s: any) { +//// } +//// +//// public get set(): any { +//// return undefined; +//// } +//// +//// public set get(g: any) { +//// } +//// +//// public get get(): any { +//// return undefined; +//// } +////} + +test.ranges().forEach(r => { + goTo.position(r.start); + + test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); + }); + + verify.occurrencesAtPositionCount(test.ranges().length); +}); diff --git a/tests/cases/fourslash/getOccurrencesSetAndGet2.ts b/tests/cases/fourslash/getOccurrencesSetAndGet2.ts index 1345394b8ee..3e05f511efc 100644 --- a/tests/cases/fourslash/getOccurrencesSetAndGet2.ts +++ b/tests/cases/fourslash/getOccurrencesSetAndGet2.ts @@ -1,34 +1,34 @@ -/// - -////class Foo { -//// set bar(b: any) { -//// } -//// -//// public get bar(): any { -//// return undefined; -//// } -//// -//// public [|set|] set(s: any) { -//// } -//// -//// public [|get|] set(): any { -//// return undefined; -//// } -//// -//// public set get(g: any) { -//// } -//// -//// public get get(): any { -//// return undefined; -//// } -////} - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); +/// + +////class Foo { +//// set bar(b: any) { +//// } +//// +//// public get bar(): any { +//// return undefined; +//// } +//// +//// public [|set|] set(s: any) { +//// } +//// +//// public [|get|] set(): any { +//// return undefined; +//// } +//// +//// public set get(g: any) { +//// } +//// +//// public get get(): any { +//// return undefined; +//// } +////} + +test.ranges().forEach(r => { + goTo.position(r.start); + + test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); + }); + + verify.occurrencesAtPositionCount(test.ranges().length); +}); diff --git a/tests/cases/fourslash/getOccurrencesSetAndGet3.ts b/tests/cases/fourslash/getOccurrencesSetAndGet3.ts index 4105a407571..777a62db6a5 100644 --- a/tests/cases/fourslash/getOccurrencesSetAndGet3.ts +++ b/tests/cases/fourslash/getOccurrencesSetAndGet3.ts @@ -1,34 +1,34 @@ -/// - -////class Foo { -//// set bar(b: any) { -//// } -//// -//// public get bar(): any { -//// return undefined; -//// } -//// -//// public set set(s: any) { -//// } -//// -//// public get set(): any { -//// return undefined; -//// } -//// -//// public [|set|] get(g: any) { -//// } -//// -//// public [|get|] get(): any { -//// return undefined; -//// } -////} - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); +/// + +////class Foo { +//// set bar(b: any) { +//// } +//// +//// public get bar(): any { +//// return undefined; +//// } +//// +//// public set set(s: any) { +//// } +//// +//// public get set(): any { +//// return undefined; +//// } +//// +//// public [|set|] get(g: any) { +//// } +//// +//// public [|get|] get(): any { +//// return undefined; +//// } +////} + +test.ranges().forEach(r => { + goTo.position(r.start); + + test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); + }); + + verify.occurrencesAtPositionCount(test.ranges().length); +}); diff --git a/tests/cases/fourslash/getOccurrencesThrow.ts b/tests/cases/fourslash/getOccurrencesThrow.ts index c25551db92e..19f10dbfb9f 100644 --- a/tests/cases/fourslash/getOccurrencesThrow.ts +++ b/tests/cases/fourslash/getOccurrencesThrow.ts @@ -1,58 +1,58 @@ -/// - -////function f(a: number) { -//// try { -//// throw "Hello"; -//// -//// try { -//// throw 10; -//// } -//// catch (x) { -//// [|return|] 100; -//// } -//// finally { -//// throw 10; -//// } -//// } -//// catch (x) { -//// [|throw|] "Something"; -//// } -//// finally { -//// [|throw|] "Also something"; -//// } -//// if (a > 0) { -//// [|return|] (function () { -//// return; -//// return; -//// return; -//// -//// if (false) { -//// return true; -//// } -//// throw "Hello!"; -//// })() || true; -//// } -//// -//// [|th/**/row|] 10; -//// -//// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) -//// -//// [|return|]; -//// [|return|] true; -//// [|throw|] false; -////} - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); - -goTo.marker(); -test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); -}); +/// + +////function f(a: number) { +//// try { +//// throw "Hello"; +//// +//// try { +//// throw 10; +//// } +//// catch (x) { +//// [|return|] 100; +//// } +//// finally { +//// throw 10; +//// } +//// } +//// catch (x) { +//// [|throw|] "Something"; +//// } +//// finally { +//// [|throw|] "Also something"; +//// } +//// if (a > 0) { +//// [|return|] (function () { +//// return; +//// return; +//// return; +//// +//// if (false) { +//// return true; +//// } +//// throw "Hello!"; +//// })() || true; +//// } +//// +//// [|th/**/row|] 10; +//// +//// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) +//// +//// [|return|]; +//// [|return|] true; +//// [|throw|] false; +////} + +test.ranges().forEach(r => { + goTo.position(r.start); + + test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); + }); + + verify.occurrencesAtPositionCount(test.ranges().length); +}); + +goTo.marker(); +test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); +}); diff --git a/tests/cases/fourslash/getOccurrencesThrow2.ts b/tests/cases/fourslash/getOccurrencesThrow2.ts index 99e18020396..9bd2f82e638 100644 --- a/tests/cases/fourslash/getOccurrencesThrow2.ts +++ b/tests/cases/fourslash/getOccurrencesThrow2.ts @@ -1,58 +1,58 @@ -/// - -////function f(a: number) { -//// try { -//// throw "Hello"; -//// -//// try { -//// [|t/**/hrow|] 10; -//// } -//// catch (x) { -//// return 100; -//// } -//// finally { -//// throw 10; -//// } -//// } -//// catch (x) { -//// throw "Something"; -//// } -//// finally { -//// throw "Also something"; -//// } -//// if (a > 0) { -//// return (function () { -//// return; -//// return; -//// return; -//// -//// if (false) { -//// return true; -//// } -//// throw "Hello!"; -//// })() || true; -//// } -//// -//// throw 10; -//// -//// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) -//// -//// return; -//// return true; -//// throw false; -////} - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); - -goTo.marker(); -test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); -}); +/// + +////function f(a: number) { +//// try { +//// throw "Hello"; +//// +//// try { +//// [|t/**/hrow|] 10; +//// } +//// catch (x) { +//// return 100; +//// } +//// finally { +//// throw 10; +//// } +//// } +//// catch (x) { +//// throw "Something"; +//// } +//// finally { +//// throw "Also something"; +//// } +//// if (a > 0) { +//// return (function () { +//// return; +//// return; +//// return; +//// +//// if (false) { +//// return true; +//// } +//// throw "Hello!"; +//// })() || true; +//// } +//// +//// throw 10; +//// +//// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) +//// +//// return; +//// return true; +//// throw false; +////} + +test.ranges().forEach(r => { + goTo.position(r.start); + + test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); + }); + + verify.occurrencesAtPositionCount(test.ranges().length); +}); + +goTo.marker(); +test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); +}); diff --git a/tests/cases/fourslash/getOccurrencesThrow3.ts b/tests/cases/fourslash/getOccurrencesThrow3.ts index 313d04b8e38..359b783df07 100644 --- a/tests/cases/fourslash/getOccurrencesThrow3.ts +++ b/tests/cases/fourslash/getOccurrencesThrow3.ts @@ -1,58 +1,58 @@ -/// - -////function f(a: number) { -//// try { -//// [|throw|] "Hello"; -//// -//// try { -//// throw 10; -//// } -//// catch (x) { -//// return 100; -//// } -//// finally { -//// [|thr/**/ow|] 10; -//// } -//// } -//// catch (x) { -//// throw "Something"; -//// } -//// finally { -//// throw "Also something"; -//// } -//// if (a > 0) { -//// return (function () { -//// return; -//// return; -//// return; -//// -//// if (false) { -//// return true; -//// } -//// throw "Hello!"; -//// })() || true; -//// } -//// -//// throw 10; -//// -//// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) -//// -//// return; -//// return true; -//// throw false; -////} - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); - -goTo.marker(); -test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); -}); +/// + +////function f(a: number) { +//// try { +//// [|throw|] "Hello"; +//// +//// try { +//// throw 10; +//// } +//// catch (x) { +//// return 100; +//// } +//// finally { +//// [|thr/**/ow|] 10; +//// } +//// } +//// catch (x) { +//// throw "Something"; +//// } +//// finally { +//// throw "Also something"; +//// } +//// if (a > 0) { +//// return (function () { +//// return; +//// return; +//// return; +//// +//// if (false) { +//// return true; +//// } +//// throw "Hello!"; +//// })() || true; +//// } +//// +//// throw 10; +//// +//// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) +//// +//// return; +//// return true; +//// throw false; +////} + +test.ranges().forEach(r => { + goTo.position(r.start); + + test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); + }); + + verify.occurrencesAtPositionCount(test.ranges().length); +}); + +goTo.marker(); +test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); +}); diff --git a/tests/cases/fourslash/getOccurrencesThrow4.ts b/tests/cases/fourslash/getOccurrencesThrow4.ts index adf321526af..ab2375907ee 100644 --- a/tests/cases/fourslash/getOccurrencesThrow4.ts +++ b/tests/cases/fourslash/getOccurrencesThrow4.ts @@ -1,58 +1,58 @@ -/// - -////function f(a: number) { -//// try { -//// throw "Hello"; -//// -//// try { -//// throw 10; -//// } -//// catch (x) { -//// return 100; -//// } -//// finally { -//// throw 10; -//// } -//// } -//// catch (x) { -//// throw "Something"; -//// } -//// finally { -//// throw "Also something"; -//// } -//// if (a > 0) { -//// return (function () { -//// [|return|]; -//// [|return|]; -//// [|return|]; -//// -//// if (false) { -//// [|return|] true; -//// } -//// [|th/**/row|] "Hello!"; -//// })() || true; -//// } -//// -//// throw 10; -//// -//// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) -//// -//// return; -//// return true; -//// throw false; -////} - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); - -goTo.marker(); -test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); -}); +/// + +////function f(a: number) { +//// try { +//// throw "Hello"; +//// +//// try { +//// throw 10; +//// } +//// catch (x) { +//// return 100; +//// } +//// finally { +//// throw 10; +//// } +//// } +//// catch (x) { +//// throw "Something"; +//// } +//// finally { +//// throw "Also something"; +//// } +//// if (a > 0) { +//// return (function () { +//// [|return|]; +//// [|return|]; +//// [|return|]; +//// +//// if (false) { +//// [|return|] true; +//// } +//// [|th/**/row|] "Hello!"; +//// })() || true; +//// } +//// +//// throw 10; +//// +//// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) +//// +//// return; +//// return true; +//// throw false; +////} + +test.ranges().forEach(r => { + goTo.position(r.start); + + test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); + }); + + verify.occurrencesAtPositionCount(test.ranges().length); +}); + +goTo.marker(); +test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); +}); diff --git a/tests/cases/fourslash/getOccurrencesThrow5.ts b/tests/cases/fourslash/getOccurrencesThrow5.ts index 3e5ba4bca13..9ba28191752 100644 --- a/tests/cases/fourslash/getOccurrencesThrow5.ts +++ b/tests/cases/fourslash/getOccurrencesThrow5.ts @@ -1,58 +1,58 @@ -/// - -////function f(a: number) { -//// try { -//// throw "Hello"; -//// -//// try { -//// throw 10; -//// } -//// catch (x) { -//// return 100; -//// } -//// finally { -//// throw 10; -//// } -//// } -//// catch (x) { -//// throw "Something"; -//// } -//// finally { -//// throw "Also something"; -//// } -//// if (a > 0) { -//// return (function () { -//// return; -//// return; -//// return; -//// -//// if (false) { -//// return true; -//// } -//// throw "Hello!"; -//// })() || true; -//// } -//// -//// throw 10; -//// -//// var unusued = [1, 2, 3, 4].map(x => { [|thr/**/ow|] 4 }) -//// -//// return; -//// return true; -//// throw false; -////} - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); - -goTo.marker(); -test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); -}); +/// + +////function f(a: number) { +//// try { +//// throw "Hello"; +//// +//// try { +//// throw 10; +//// } +//// catch (x) { +//// return 100; +//// } +//// finally { +//// throw 10; +//// } +//// } +//// catch (x) { +//// throw "Something"; +//// } +//// finally { +//// throw "Also something"; +//// } +//// if (a > 0) { +//// return (function () { +//// return; +//// return; +//// return; +//// +//// if (false) { +//// return true; +//// } +//// throw "Hello!"; +//// })() || true; +//// } +//// +//// throw 10; +//// +//// var unusued = [1, 2, 3, 4].map(x => { [|thr/**/ow|] 4 }) +//// +//// return; +//// return true; +//// throw false; +////} + +test.ranges().forEach(r => { + goTo.position(r.start); + + test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); + }); + + verify.occurrencesAtPositionCount(test.ranges().length); +}); + +goTo.marker(); +test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); +}); diff --git a/tests/cases/fourslash/getOccurrencesThrow6.ts b/tests/cases/fourslash/getOccurrencesThrow6.ts index 2769c9933db..8b58347ed8a 100644 --- a/tests/cases/fourslash/getOccurrencesThrow6.ts +++ b/tests/cases/fourslash/getOccurrencesThrow6.ts @@ -1,28 +1,28 @@ -/// - -////[|throw|] 100; -//// -////try { -//// throw 0; -//// var x = () => { throw 0; }; -////} -////catch (y) { -//// var x = () => { throw 0; }; -//// [|throw|] 200; -////} -////finally { -//// [|throw|] 300; -////} - - - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); - +/// + +////[|throw|] 100; +//// +////try { +//// throw 0; +//// var x = () => { throw 0; }; +////} +////catch (y) { +//// var x = () => { throw 0; }; +//// [|throw|] 200; +////} +////finally { +//// [|throw|] 300; +////} + + + +test.ranges().forEach(r => { + goTo.position(r.start); + + test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); + }); + + verify.occurrencesAtPositionCount(test.ranges().length); +}); + diff --git a/tests/cases/fourslash/getOccurrencesThrow7.ts b/tests/cases/fourslash/getOccurrencesThrow7.ts index 46e899a891b..48ab981d762 100644 --- a/tests/cases/fourslash/getOccurrencesThrow7.ts +++ b/tests/cases/fourslash/getOccurrencesThrow7.ts @@ -1,31 +1,31 @@ -/// - -////try { -//// [|throw|] 10; -//// -//// try { -//// throw 10; -//// } -//// catch (x) { -//// [|throw|] 10; -//// } -//// finally { -//// [|throw|] 10; -//// } -////} -////finally { -//// [|throw|] 10; -////} -//// -////[|throw|] 10; - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); - +/// + +////try { +//// [|throw|] 10; +//// +//// try { +//// throw 10; +//// } +//// catch (x) { +//// [|throw|] 10; +//// } +//// finally { +//// [|throw|] 10; +//// } +////} +////finally { +//// [|throw|] 10; +////} +//// +////[|throw|] 10; + +test.ranges().forEach(r => { + goTo.position(r.start); + + test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); + }); + + verify.occurrencesAtPositionCount(test.ranges().length); +}); + diff --git a/tests/cases/fourslash/getOccurrencesThrow8.ts b/tests/cases/fourslash/getOccurrencesThrow8.ts index 679e13c8d5a..cc527720dc4 100644 --- a/tests/cases/fourslash/getOccurrencesThrow8.ts +++ b/tests/cases/fourslash/getOccurrencesThrow8.ts @@ -1,31 +1,31 @@ -/// - -////try { -//// throw 10; -//// -//// try { -//// [|throw|] 10; -//// } -//// catch (x) { -//// throw 10; -//// } -//// finally { -//// throw 10; -//// } -////} -////finally { -//// throw 10; -////} -//// -////throw 10; - -test.ranges().forEach(r => { - goTo.position(r.start); - - test.ranges().forEach(range => { - verify.occurrencesAtPositionContains(range, false); - }); - - verify.occurrencesAtPositionCount(test.ranges().length); -}); - +/// + +////try { +//// throw 10; +//// +//// try { +//// [|throw|] 10; +//// } +//// catch (x) { +//// throw 10; +//// } +//// finally { +//// throw 10; +//// } +////} +////finally { +//// throw 10; +////} +//// +////throw 10; + +test.ranges().forEach(r => { + goTo.position(r.start); + + test.ranges().forEach(range => { + verify.occurrencesAtPositionContains(range, false); + }); + + verify.occurrencesAtPositionCount(test.ranges().length); +}); + diff --git a/tests/cases/fourslash/getSemanticDiagnosticForDeclaration.ts b/tests/cases/fourslash/getSemanticDiagnosticForDeclaration.ts index 6345c464213..804abbde33b 100644 --- a/tests/cases/fourslash/getSemanticDiagnosticForDeclaration.ts +++ b/tests/cases/fourslash/getSemanticDiagnosticForDeclaration.ts @@ -1,11 +1,11 @@ -/// - -// @module: CommonJS -// @declaration: true -//// interface privateInterface {} -//// export class Bar implements /*1*/privateInterface/*2*/{ } - -verify.errorExistsBetweenMarkers("1", "2"); -verify.numberOfErrorsInCurrentFile(1); - - +/// + +// @module: CommonJS +// @declaration: true +//// interface privateInterface {} +//// export class Bar implements /*1*/privateInterface/*2*/{ } + +verify.errorExistsBetweenMarkers("1", "2"); +verify.numberOfErrorsInCurrentFile(1); + + diff --git a/tests/cases/fourslash/getSemanticDiagnosticForNoDeclaration.ts b/tests/cases/fourslash/getSemanticDiagnosticForNoDeclaration.ts index dc351a21f2c..cdcde01054e 100644 --- a/tests/cases/fourslash/getSemanticDiagnosticForNoDeclaration.ts +++ b/tests/cases/fourslash/getSemanticDiagnosticForNoDeclaration.ts @@ -1,10 +1,10 @@ -/// - -// @module: CommonJS - -//// interface privateInterface {} -//// export class Bar implements /*1*/privateInterface/*2*/{ } - -verify.numberOfErrorsInCurrentFile(0); - - +/// + +// @module: CommonJS + +//// interface privateInterface {} +//// export class Bar implements /*1*/privateInterface/*2*/{ } + +verify.numberOfErrorsInCurrentFile(0); + + diff --git a/tests/cases/fourslash/globalCompletionListInsideObjectLiterals.ts b/tests/cases/fourslash/globalCompletionListInsideObjectLiterals.ts index 3f80f3d9c25..af7bc075f8c 100644 --- a/tests/cases/fourslash/globalCompletionListInsideObjectLiterals.ts +++ b/tests/cases/fourslash/globalCompletionListInsideObjectLiterals.ts @@ -1,49 +1,49 @@ -/// - -////module ObjectLiterals { -//// interface MyPoint { -//// x1: number; -//// y1: number; -//// } -//// -//// // Negative cases (global completion) -//// var p1: MyPoint = /*1*/{ -//// }; -//// -//// var p2: MyPoint = { -//// x1: /*2*/ -//// /*3*/}; -//// -//// var p3: MyPoint = { -//// y1 /*4*/ -//// }; -//// -//// var p4: MyPoint = { -//// x1: /*5*/ /*6*/, -//// }; -////} - -function VerifyGlobalCompletionList() { - verify.completionListItemsCountIsGreaterThan(10); -} - -// Completion on '{' location. -goTo.marker("1"); -VerifyGlobalCompletionList(); - -// Literal member completion after member name with empty member expression and missing colon. -goTo.marker("2"); -VerifyGlobalCompletionList(); - -goTo.marker("3"); -VerifyGlobalCompletionList(); - -goTo.marker("4"); -VerifyGlobalCompletionList(); - -// Literal member completion after member name with empty member expression. -goTo.marker("5"); -VerifyGlobalCompletionList(); - -goTo.marker("6"); +/// + +////module ObjectLiterals { +//// interface MyPoint { +//// x1: number; +//// y1: number; +//// } +//// +//// // Negative cases (global completion) +//// var p1: MyPoint = /*1*/{ +//// }; +//// +//// var p2: MyPoint = { +//// x1: /*2*/ +//// /*3*/}; +//// +//// var p3: MyPoint = { +//// y1 /*4*/ +//// }; +//// +//// var p4: MyPoint = { +//// x1: /*5*/ /*6*/, +//// }; +////} + +function VerifyGlobalCompletionList() { + verify.completionListItemsCountIsGreaterThan(10); +} + +// Completion on '{' location. +goTo.marker("1"); +VerifyGlobalCompletionList(); + +// Literal member completion after member name with empty member expression and missing colon. +goTo.marker("2"); +VerifyGlobalCompletionList(); + +goTo.marker("3"); +VerifyGlobalCompletionList(); + +goTo.marker("4"); +VerifyGlobalCompletionList(); + +// Literal member completion after member name with empty member expression. +goTo.marker("5"); +VerifyGlobalCompletionList(); + +goTo.marker("6"); VerifyGlobalCompletionList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts b/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts index 0c1248a0422..a1fda8886db 100644 --- a/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts @@ -1,22 +1,22 @@ -/// - -////class ConstructorOverload { -//// /*constructorOverload1*/constructor(); -//// /*constructorOverload2*/constructor(foo: string); -//// /*constructorDefinition*/constructor(foo: any) { } -////} -//// -////var constructorOverload = new /*constructorOverloadReference1*/ConstructorOverload(); -////var constructorOverload = new /*constructorOverloadReference2*/ConstructorOverload("foo"); - -goTo.marker('constructorOverloadReference1'); -goTo.definition(); -verify.caretAtMarker('constructorDefinition'); - -goTo.marker('constructorOverloadReference2'); -goTo.definition(); -verify.caretAtMarker('constructorDefinition'); - -goTo.marker('constructorOverload1'); -goTo.definition(); -verify.caretAtMarker('constructorDefinition'); +/// + +////class ConstructorOverload { +//// /*constructorOverload1*/constructor(); +//// /*constructorOverload2*/constructor(foo: string); +//// /*constructorDefinition*/constructor(foo: any) { } +////} +//// +////var constructorOverload = new /*constructorOverloadReference1*/ConstructorOverload(); +////var constructorOverload = new /*constructorOverloadReference2*/ConstructorOverload("foo"); + +goTo.marker('constructorOverloadReference1'); +goTo.definition(); +verify.caretAtMarker('constructorDefinition'); + +goTo.marker('constructorOverloadReference2'); +goTo.definition(); +verify.caretAtMarker('constructorDefinition'); + +goTo.marker('constructorOverload1'); +goTo.definition(); +verify.caretAtMarker('constructorDefinition'); diff --git a/tests/cases/fourslash/goToDefinitionDifferentFile.ts b/tests/cases/fourslash/goToDefinitionDifferentFile.ts index 54b799ba65f..3aa31d1556c 100644 --- a/tests/cases/fourslash/goToDefinitionDifferentFile.ts +++ b/tests/cases/fourslash/goToDefinitionDifferentFile.ts @@ -1,29 +1,29 @@ -/// - -// @Filename: goToDefinitionDifferentFile_Definition.ts -////var /*remoteVariableDefinition*/remoteVariable; -/////*remoteFunctionDefinition*/function remoteFunction() { } -/////*remoteClassDefinition*/class remoteClass { } -/////*remoteInterfaceDefinition*/interface remoteInterface{ } -/////*remoteModuleDefinition*/module remoteModule{ export var foo = 1;} - -// @Filename: goToDefinitionDifferentFile_Consumption.ts -/////*remoteVariableReference*/remoteVariable = 1; -/////*remoteFunctionReference*/remoteFunction(); -////var foo = new /*remoteClassReference*/remoteClass(); -////class fooCls implements /*remoteInterfaceReference*/remoteInterface { } -////var fooVar = /*remoteModuleReference*/remoteModule.foo; - -var markerList = [ - "remoteVariable", - "remoteFunction", - "remoteClass", - "remoteInterface", - "remoteModule", -]; - -markerList.forEach((marker) => { - goTo.marker(marker + 'Reference'); - goTo.definition(); - verify.caretAtMarker(marker + 'Definition'); -}); +/// + +// @Filename: goToDefinitionDifferentFile_Definition.ts +////var /*remoteVariableDefinition*/remoteVariable; +/////*remoteFunctionDefinition*/function remoteFunction() { } +/////*remoteClassDefinition*/class remoteClass { } +/////*remoteInterfaceDefinition*/interface remoteInterface{ } +/////*remoteModuleDefinition*/module remoteModule{ export var foo = 1;} + +// @Filename: goToDefinitionDifferentFile_Consumption.ts +/////*remoteVariableReference*/remoteVariable = 1; +/////*remoteFunctionReference*/remoteFunction(); +////var foo = new /*remoteClassReference*/remoteClass(); +////class fooCls implements /*remoteInterfaceReference*/remoteInterface { } +////var fooVar = /*remoteModuleReference*/remoteModule.foo; + +var markerList = [ + "remoteVariable", + "remoteFunction", + "remoteClass", + "remoteInterface", + "remoteModule", +]; + +markerList.forEach((marker) => { + goTo.marker(marker + 'Reference'); + goTo.definition(); + verify.caretAtMarker(marker + 'Definition'); +}); diff --git a/tests/cases/fourslash/goToDefinitionDifferentFileIndirectly.ts b/tests/cases/fourslash/goToDefinitionDifferentFileIndirectly.ts index c0675b29d23..7287fde2d1d 100644 --- a/tests/cases/fourslash/goToDefinitionDifferentFileIndirectly.ts +++ b/tests/cases/fourslash/goToDefinitionDifferentFileIndirectly.ts @@ -1,36 +1,36 @@ -/// - -// @Filename: Remote2.ts -////var /*remoteVariableDefinition*/rem2Var; -/////*remoteFunctionDefinition*/function rem2Fn() { } -/////*remoteClassDefinition*/class rem2Cls { } -/////*remoteInterfaceDefinition*/interface rem2Int{} -/////*remoteModuleDefinition*/module rem2Mod { export var foo; } - -// @Filename: Remote1.ts -////var remVar; -////function remFn() { } -////class remCls { } -////interface remInt{} -////module remMod { export var foo; } - -// @Filename: Definition.ts -/////*remoteVariableReference*/rem2Var = 1; -/////*remoteFunctionReference*/rem2Fn(); -////var rem2foo = new /*remoteClassReference*/rem2Cls(); -////class rem2fooCls implements /*remoteInterfaceReference*/rem2Int { } -////var rem2fooVar = /*remoteModuleReference*/rem2Mod.foo; - -var markerList = [ - "remoteVariable", - "remoteFunction", - "remoteClass", - "remoteInterface", - "remoteModule", -]; - -markerList.forEach((marker) => { - goTo.marker(marker + 'Reference'); - goTo.definition(); - verify.caretAtMarker(marker + 'Definition'); +/// + +// @Filename: Remote2.ts +////var /*remoteVariableDefinition*/rem2Var; +/////*remoteFunctionDefinition*/function rem2Fn() { } +/////*remoteClassDefinition*/class rem2Cls { } +/////*remoteInterfaceDefinition*/interface rem2Int{} +/////*remoteModuleDefinition*/module rem2Mod { export var foo; } + +// @Filename: Remote1.ts +////var remVar; +////function remFn() { } +////class remCls { } +////interface remInt{} +////module remMod { export var foo; } + +// @Filename: Definition.ts +/////*remoteVariableReference*/rem2Var = 1; +/////*remoteFunctionReference*/rem2Fn(); +////var rem2foo = new /*remoteClassReference*/rem2Cls(); +////class rem2fooCls implements /*remoteInterfaceReference*/rem2Int { } +////var rem2fooVar = /*remoteModuleReference*/rem2Mod.foo; + +var markerList = [ + "remoteVariable", + "remoteFunction", + "remoteClass", + "remoteInterface", + "remoteModule", +]; + +markerList.forEach((marker) => { + goTo.marker(marker + 'Reference'); + goTo.definition(); + verify.caretAtMarker(marker + 'Definition'); }); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionExternamModuleName.ts b/tests/cases/fourslash/goToDefinitionExternamModuleName.ts index 531e4562843..f403965fe12 100644 --- a/tests/cases/fourslash/goToDefinitionExternamModuleName.ts +++ b/tests/cases/fourslash/goToDefinitionExternamModuleName.ts @@ -1,4 +1,4 @@ -/// +/// // @Filename: b.ts ////import n = require('a/*1*/'); diff --git a/tests/cases/fourslash/goToDefinitionExternamModuleName2.ts b/tests/cases/fourslash/goToDefinitionExternamModuleName2.ts index 3ef9c2555ef..df7b3310394 100644 --- a/tests/cases/fourslash/goToDefinitionExternamModuleName2.ts +++ b/tests/cases/fourslash/goToDefinitionExternamModuleName2.ts @@ -1,4 +1,4 @@ -/// +/// // @Filename: b.ts ////import n = require('a/*1*/'); diff --git a/tests/cases/fourslash/goToDefinitionExternamModuleName3.ts b/tests/cases/fourslash/goToDefinitionExternamModuleName3.ts index ace3851e5bc..cd31f027895 100644 --- a/tests/cases/fourslash/goToDefinitionExternamModuleName3.ts +++ b/tests/cases/fourslash/goToDefinitionExternamModuleName3.ts @@ -1,4 +1,4 @@ -/// +/// // @Filename: b.ts ////import n = require('e/*1*/'); diff --git a/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts b/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts index 8867b674014..e6a763a98f1 100644 --- a/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts +++ b/tests/cases/fourslash/goToDefinitionInterfaceAfterImplement.ts @@ -1,16 +1,16 @@ -/// - -/////*interfaceDefinition*/interface sInt { -//// sVar: number; -//// sFn: () => void; -////} -//// -////class iClass implements /*interfaceReference*/sInt { -//// public sVar = 1; -//// public sFn() { -//// } -////} - -goTo.marker('interfaceReference'); -goTo.definition(); +/// + +/////*interfaceDefinition*/interface sInt { +//// sVar: number; +//// sFn: () => void; +////} +//// +////class iClass implements /*interfaceReference*/sInt { +//// public sVar = 1; +//// public sFn() { +//// } +////} + +goTo.marker('interfaceReference'); +goTo.definition(); verify.caretAtMarker('interfaceDefinition'); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionShadowVariableInsideModule.ts b/tests/cases/fourslash/goToDefinitionShadowVariableInsideModule.ts index dd073ccb6c4..92f2761b61a 100644 --- a/tests/cases/fourslash/goToDefinitionShadowVariableInsideModule.ts +++ b/tests/cases/fourslash/goToDefinitionShadowVariableInsideModule.ts @@ -1,10 +1,10 @@ -/// - -////module shdModule { -//// var /*shadowVariableDefinition*/shdVar; -//// /*shadowVariableReference*/shdVar = 1; -////} - -goTo.marker('shadowVariableReference'); -goTo.definition(); +/// + +////module shdModule { +//// var /*shadowVariableDefinition*/shdVar; +//// /*shadowVariableReference*/shdVar = 1; +////} + +goTo.marker('shadowVariableReference'); +goTo.definition(); verify.caretAtMarker('shadowVariableDefinition'); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionShorthandProperty.ts b/tests/cases/fourslash/goToDefinitionShorthandProperty.ts index 07ea82c03e1..5e906893719 100644 --- a/tests/cases/fourslash/goToDefinitionShorthandProperty.ts +++ b/tests/cases/fourslash/goToDefinitionShorthandProperty.ts @@ -1,4 +1,4 @@ -/// +/// //// var /*valueDeclaration1*/name = "hello"; //// var /*valueDeclaration2*/id = 100000; diff --git a/tests/cases/fourslash/goToDefinitionSourceUnit.ts b/tests/cases/fourslash/goToDefinitionSourceUnit.ts index 5a310d3ffc8..09900ff41be 100644 --- a/tests/cases/fourslash/goToDefinitionSourceUnit.ts +++ b/tests/cases/fourslash/goToDefinitionSourceUnit.ts @@ -1,24 +1,24 @@ -/// - -// @Filename: a.ts -//// //MyFile Comments -//// //more comments -//// /// -//// /// -//// -//// class clsInOverload { -//// static fnOverload(); -//// static fnOverload(foo: string); -//// static fnOverload(foo: any) { } -//// } -//// - -// @Filename: b.ts -/////*fileB*/ - -goTo.marker("unknownFile"); -verify.not.definitionLocationExists(); - -goTo.marker("knownFile"); -goTo.definition(); -verify.caretAtMarker('fileB'); +/// + +// @Filename: a.ts +//// //MyFile Comments +//// //more comments +//// /// +//// /// +//// +//// class clsInOverload { +//// static fnOverload(); +//// static fnOverload(foo: string); +//// static fnOverload(foo: any) { } +//// } +//// + +// @Filename: b.ts +/////*fileB*/ + +goTo.marker("unknownFile"); +verify.not.definitionLocationExists(); + +goTo.marker("knownFile"); +goTo.definition(); +verify.caretAtMarker('fileB'); diff --git a/tests/cases/fourslash/importDeclPaste0.ts b/tests/cases/fourslash/importDeclPaste0.ts index 6bb8eb6894e..f86920cdfde 100644 --- a/tests/cases/fourslash/importDeclPaste0.ts +++ b/tests/cases/fourslash/importDeclPaste0.ts @@ -1,18 +1,18 @@ -/// - -//// // @Filename: exportEqualsInterface_A.ts -//// interface A { -//// p1: number; -//// } -//// -//// export = A; -//// /*1*/ -//// var i: I1; -//// -//// var n: number = i.p1; - -edit.disableFormatting(); - -goTo.marker('1'); - -//edit.insert("\nimport I1 = module(\"exportEqualsInterface_A\");\n"); +/// + +//// // @Filename: exportEqualsInterface_A.ts +//// interface A { +//// p1: number; +//// } +//// +//// export = A; +//// /*1*/ +//// var i: I1; +//// +//// var n: number = i.p1; + +edit.disableFormatting(); + +goTo.marker('1'); + +//edit.insert("\nimport I1 = module(\"exportEqualsInterface_A\");\n"); diff --git a/tests/cases/fourslash/importValueUsedAsType.ts b/tests/cases/fourslash/importValueUsedAsType.ts index e2b881eb9bf..f3e5fb54860 100644 --- a/tests/cases/fourslash/importValueUsedAsType.ts +++ b/tests/cases/fourslash/importValueUsedAsType.ts @@ -1,12 +1,12 @@ -/// - -//// /**/ -//// module A { -//// export var X; -//// import Z = A.X; -//// var v: Z; -//// } - -goTo.marker(); -// Used to crash here -edit.insert(' '); +/// + +//// /**/ +//// module A { +//// export var X; +//// import Z = A.X; +//// var v: Z; +//// } + +goTo.marker(); +// Used to crash here +edit.insert(' '); diff --git a/tests/cases/fourslash/incrementalUpdateToClassImplementingGenericClass.ts b/tests/cases/fourslash/incrementalUpdateToClassImplementingGenericClass.ts index 8bb6cf489d6..f8dcc0a1f39 100644 --- a/tests/cases/fourslash/incrementalUpdateToClassImplementingGenericClass.ts +++ b/tests/cases/fourslash/incrementalUpdateToClassImplementingGenericClass.ts @@ -12,7 +12,7 @@ //// /*1*/get name2() { return this.name; } ////} ////var a = new Animal2('eprst'); - + goTo.marker('1'); diff --git a/tests/cases/fourslash/indentionsOfCommentBlockAfterFormatting.ts b/tests/cases/fourslash/indentionsOfCommentBlockAfterFormatting.ts index 4247b0e5e47..3b686285b99 100644 --- a/tests/cases/fourslash/indentionsOfCommentBlockAfterFormatting.ts +++ b/tests/cases/fourslash/indentionsOfCommentBlockAfterFormatting.ts @@ -1,43 +1,43 @@ -/// - -////// This is a test case of formatting. -////class TestClass { -////private foo: string; -////public bar: string; -////constructor(foo: string, bar: string) { -////this.foo = foo; -////this.bar = bar; -////} -/////** /*1*/ -////* This document is to be formatted./*2*/ -////* /*3*/ -////* After formatting, each line of this comment block should have indent consistent with the method./*4*/ -////* -//// */ -/////*5*/public testMethod() { -////} -////} -////var cookieMonster: TestClass; -////cookieMonster = new TestClass("FOO", "BAR"); - - -format.document(); -goTo.marker("1"); -verify.indentationIs(4); -goTo.marker("2"); -verify.indentationIs(4); -goTo.marker("3"); -verify.indentationIs(4); -goTo.marker("4"); -verify.indentationIs(4); -// Putting a marker in line "*" would bring some error when parsing code in automation. -// So move right by 1 offset from marker 4 to locate the caret in this line. -edit.moveRight(1); -verify.indentationIs(4); -// Putting a marker in line " */" would bring some error when parsing code in automation. -// So move left by 1 offset from marker 5 to locate the caret in this line. -goTo.marker("5"); -edit.moveLeft(1); -verify.indentationIs(4); -goTo.marker("5"); +/// + +////// This is a test case of formatting. +////class TestClass { +////private foo: string; +////public bar: string; +////constructor(foo: string, bar: string) { +////this.foo = foo; +////this.bar = bar; +////} +/////** /*1*/ +////* This document is to be formatted./*2*/ +////* /*3*/ +////* After formatting, each line of this comment block should have indent consistent with the method./*4*/ +////* +//// */ +/////*5*/public testMethod() { +////} +////} +////var cookieMonster: TestClass; +////cookieMonster = new TestClass("FOO", "BAR"); + + +format.document(); +goTo.marker("1"); +verify.indentationIs(4); +goTo.marker("2"); +verify.indentationIs(4); +goTo.marker("3"); +verify.indentationIs(4); +goTo.marker("4"); +verify.indentationIs(4); +// Putting a marker in line "*" would bring some error when parsing code in automation. +// So move right by 1 offset from marker 4 to locate the caret in this line. +edit.moveRight(1); +verify.indentationIs(4); +// Putting a marker in line " */" would bring some error when parsing code in automation. +// So move left by 1 offset from marker 5 to locate the caret in this line. +goTo.marker("5"); +edit.moveLeft(1); +verify.indentationIs(4); +goTo.marker("5"); verify.indentationIs(4); \ No newline at end of file diff --git a/tests/cases/fourslash/indexSignatureWithoutAnnotation.ts b/tests/cases/fourslash/indexSignatureWithoutAnnotation.ts index bc7449ece7c..af5fe9010fc 100644 --- a/tests/cases/fourslash/indexSignatureWithoutAnnotation.ts +++ b/tests/cases/fourslash/indexSignatureWithoutAnnotation.ts @@ -1,5 +1,5 @@ -/// - +/// + //// interface B { //// 1: any; //// } @@ -8,6 +8,6 @@ //// } //// interface D extends B, C /**/ { //// } - -goTo.marker(); -edit.insert(" "); + +goTo.marker(); +edit.insert(" "); diff --git a/tests/cases/fourslash/insertArgumentBeforeOverloadedConstructor.ts b/tests/cases/fourslash/insertArgumentBeforeOverloadedConstructor.ts index 659a3fb0354..7c8b9571c45 100644 --- a/tests/cases/fourslash/insertArgumentBeforeOverloadedConstructor.ts +++ b/tests/cases/fourslash/insertArgumentBeforeOverloadedConstructor.ts @@ -1,11 +1,11 @@ -/// - -//// alert(/**/100); -//// -//// class OverloadedMonster { -//// constructor(); -//// constructor(name) { } -//// } - -goTo.marker(); -edit.insert("'1', "); +/// + +//// alert(/**/100); +//// +//// class OverloadedMonster { +//// constructor(); +//// constructor(name) { } +//// } + +goTo.marker(); +edit.insert("'1', "); diff --git a/tests/cases/fourslash/insertInterfaceAndCheckTypeLiteralField.ts b/tests/cases/fourslash/insertInterfaceAndCheckTypeLiteralField.ts index 0cb5db908e2..d941421b129 100644 --- a/tests/cases/fourslash/insertInterfaceAndCheckTypeLiteralField.ts +++ b/tests/cases/fourslash/insertInterfaceAndCheckTypeLiteralField.ts @@ -1,11 +1,11 @@ -/// - -//// /*addC*/ -//// interface G { } -//// var v2: G<{ a: /*checkParam*/C }, C>; - -goTo.marker('addC'); -edit.insert('interface C { }'); - -goTo.marker('checkParam'); -verify.quickInfoExists(); +/// + +//// /*addC*/ +//// interface G { } +//// var v2: G<{ a: /*checkParam*/C }, C>; + +goTo.marker('addC'); +edit.insert('interface C { }'); + +goTo.marker('checkParam'); +verify.quickInfoExists(); diff --git a/tests/cases/fourslash/insertMethodCallAboveOthers.ts b/tests/cases/fourslash/insertMethodCallAboveOthers.ts index 4f7e1cf0e6c..5b8fe45d94f 100644 --- a/tests/cases/fourslash/insertMethodCallAboveOthers.ts +++ b/tests/cases/fourslash/insertMethodCallAboveOthers.ts @@ -1,8 +1,8 @@ -/// - -//// /**/ -//// paired.reduce(); -//// paired.map(() => undefined); - -goTo.marker(); -edit.insert("paired.reduce();"); +/// + +//// /**/ +//// paired.reduce(); +//// paired.map(() => undefined); + +goTo.marker(); +edit.insert("paired.reduce();"); diff --git a/tests/cases/fourslash/insertPublicBeforeSetter.ts b/tests/cases/fourslash/insertPublicBeforeSetter.ts index ca83d3ce054..1fb0b40e019 100644 --- a/tests/cases/fourslash/insertPublicBeforeSetter.ts +++ b/tests/cases/fourslash/insertPublicBeforeSetter.ts @@ -1,9 +1,9 @@ -/// - -//// class C { -//// /**/set Bar(bar:string) {} -//// } -//// var o2 = { set Foo(val:number) { } }; - -goTo.marker(); -edit.insert("public "); +/// + +//// class C { +//// /**/set Bar(bar:string) {} +//// } +//// var o2 = { set Foo(val:number) { } }; + +goTo.marker(); +edit.insert("public "); diff --git a/tests/cases/fourslash/insertSecondTryCatchBlock.ts b/tests/cases/fourslash/insertSecondTryCatchBlock.ts index 1d6f1963ad9..89bf0f0267e 100644 --- a/tests/cases/fourslash/insertSecondTryCatchBlock.ts +++ b/tests/cases/fourslash/insertSecondTryCatchBlock.ts @@ -1,7 +1,7 @@ -/// - -//// try {} catch(e) { } -//// /**/ - -goTo.marker(); -edit.insert('try {} catch(e) { }'); +/// + +//// try {} catch(e) { } +//// /**/ + +goTo.marker(); +edit.insert('try {} catch(e) { }'); diff --git a/tests/cases/fourslash/localGetReferences.ts b/tests/cases/fourslash/localGetReferences.ts index b390f9bef8b..6d5f541dd51 100644 --- a/tests/cases/fourslash/localGetReferences.ts +++ b/tests/cases/fourslash/localGetReferences.ts @@ -1,238 +1,238 @@ -/// - -// @Filename: localGetReferences_1.ts -////// Comment Refence Test: g/*1*/lobalVar -////var g/*3*/lobalVar: n/*2*/umber = 2; -//// -////class fooCls { -//// static clsS/*5*/Var = 1; -//// //Declare -//// cls/*4*/Var = 1; -//// -//// constructor (public clsParam: number) { -//// //Increments -//// globalVar++; -//// this.clsVar++; -//// fooCls.clsSVar++; -//// this.cls/*7*/Param++; -//// modTest.modVar++; -//// } -////} -//// -////function foo(/*8*/x: number) { -//// //Declare -//// var fn/*6*/Var = 1; -//// -//// //Increments -//// fooCls.clsSVar++; -//// globalVar++; -//// modTest.modVar++; -//// fnVar++; -//// -//// //Return -//// return x++; -////} -//// -////module modTest { -//// //Declare -//// export var modVar:number; -//// -//// //Increments -//// globalVar++; -//// fooCls.clsSVar++; -//// modVar++; -//// -//// class testCls { -//// static boo = foo; -//// } -//// -//// function testFn(){ -//// static boo = foo; -//// -//// //Increments -//// globalVar++; -//// fooCls.clsSVar++; -//// modVar++; -//// } -//// -//// module testMod { -//// var boo = foo; -//// } -////} -//// -//////Type test -////var clsTest: fooCls; -//// -//////Arguments -////clsTest = new fooCls(globalV/*10*/ar); -////foo(glo/*9*/balVar); -//// -//////Increments -////fooCls.clsSVar++; -////modTest.modVar++; -////globalVar = globalVar + globalVar; -//// -//////ETC - Other cases -////globalVar = 3; -/////*11*/foo = foo + 1; -/////*12*/err = err++; -/////*13*/ -//////Shadowed fn Parameter -////function shdw(globa/*14*/lVar: number) { -//// //Increments -//// globalVar++; -//// return globalVar; -////} -//// -//////Remotes -//////Type test -////var remoteclsTest: remotefooCls; -//// -//////Arguments -////remoteclsTest = new remotefooCls(remoteglobalVar); -////remotefoo(remoteglobalVar); -//// -//////Increments -////remotefooCls.remoteclsSVar++; -////remotemodTest.remotemodVar++; -////remoteglobalVar = remoteglobalVar + remoteglobalVar; -//// -//////ETC - Other cases -////remoteglobalVar = 3; -//// -//////Find References misses method param -////var -//// -//// -//// -//// array = ["f", "o", "o"]; -//// -////array.forEach( -//// -//// -////function(str) { -//// -//// -//// -//// return /*15*/str + " "; -//// -////}); - -// @Filename: localGetReferences_2.ts -////var remoteglobalVar: number = 2; -//// -////class remotefooCls { -//// //Declare -//// remoteclsVar = 1; -//// static remoteclsSVar = 1; -//// -//// constructor(public remoteclsParam: number) { -//// //Increments -//// remoteglobalVar++; -//// this.remoteclsVar++; -//// remotefooCls.remoteclsSVar++; -//// this.remoteclsParam++; -//// remotemodTest.remotemodVar++; -//// } -////} -//// -////function remotefoo(remotex: number) { -//// //Declare -//// var remotefnVar = 1; -//// -//// //Increments -//// remotefooCls.remoteclsSVar++; -//// remoteglobalVar++; -//// remotemodTest.remotemodVar++; -//// remotefnVar++; -//// -//// //Return -//// return remotex++; -////} -//// -////module remotemodTest { -//// //Declare -//// export var remotemodVar: number; -//// -//// //Increments -//// remoteglobalVar++; -//// remotefooCls.remoteclsSVar++; -//// remotemodVar++; -//// -//// class remotetestCls { -//// static remoteboo = remotefoo; -//// } -//// -//// function remotetestFn(){ -//// static remoteboo = remotefoo; -//// -//// //Increments -//// remoteglobalVar++; -//// remotefooCls.remoteclsSVar++; -//// remotemodVar++; -//// } -//// -//// module remotetestMod { -//// var remoteboo = remotefoo; -//// } -////} - -// References to comment. -goTo.marker("1"); -verify.referencesCountIs(0); - -// References to type. -goTo.marker("2"); -verify.referencesCountIs(0); - -// References to a variable declared in global. -goTo.marker("3"); -verify.referencesCountIs(11); - -// References to a variable declared in a class. -goTo.marker("4"); -verify.referencesCountIs(2); - -// References to static variable declared in a class. -goTo.marker("5"); -verify.referencesCountIs(6); - -// References to a variable declared in a function. -goTo.marker("6"); -verify.referencesCountIs(2); - -// References to a class parameter. -goTo.marker("7"); -verify.referencesCountIs(2); - -// References to a function parameter. -goTo.marker("8"); -verify.referencesCountIs(2); - -// References to a function argument. -goTo.marker("9"); -verify.referencesCountIs(11); - -// References to a class argument. -goTo.marker("10"); -verify.referencesCountIs(11); - -// References to illegal assignment. -goTo.marker("11"); -verify.referencesCountIs(7); - -// References to unresolved symbol. -goTo.marker("12"); -verify.referencesCountIs(1); - -// References to no context. -goTo.marker("13"); -verify.referencesCountIs(0); - -// References to shadowed function parameter. -goTo.marker("14"); -verify.referencesCountIs(3); - -// Reference misses function parameter. -goTo.marker("15"); +/// + +// @Filename: localGetReferences_1.ts +////// Comment Refence Test: g/*1*/lobalVar +////var g/*3*/lobalVar: n/*2*/umber = 2; +//// +////class fooCls { +//// static clsS/*5*/Var = 1; +//// //Declare +//// cls/*4*/Var = 1; +//// +//// constructor (public clsParam: number) { +//// //Increments +//// globalVar++; +//// this.clsVar++; +//// fooCls.clsSVar++; +//// this.cls/*7*/Param++; +//// modTest.modVar++; +//// } +////} +//// +////function foo(/*8*/x: number) { +//// //Declare +//// var fn/*6*/Var = 1; +//// +//// //Increments +//// fooCls.clsSVar++; +//// globalVar++; +//// modTest.modVar++; +//// fnVar++; +//// +//// //Return +//// return x++; +////} +//// +////module modTest { +//// //Declare +//// export var modVar:number; +//// +//// //Increments +//// globalVar++; +//// fooCls.clsSVar++; +//// modVar++; +//// +//// class testCls { +//// static boo = foo; +//// } +//// +//// function testFn(){ +//// static boo = foo; +//// +//// //Increments +//// globalVar++; +//// fooCls.clsSVar++; +//// modVar++; +//// } +//// +//// module testMod { +//// var boo = foo; +//// } +////} +//// +//////Type test +////var clsTest: fooCls; +//// +//////Arguments +////clsTest = new fooCls(globalV/*10*/ar); +////foo(glo/*9*/balVar); +//// +//////Increments +////fooCls.clsSVar++; +////modTest.modVar++; +////globalVar = globalVar + globalVar; +//// +//////ETC - Other cases +////globalVar = 3; +/////*11*/foo = foo + 1; +/////*12*/err = err++; +/////*13*/ +//////Shadowed fn Parameter +////function shdw(globa/*14*/lVar: number) { +//// //Increments +//// globalVar++; +//// return globalVar; +////} +//// +//////Remotes +//////Type test +////var remoteclsTest: remotefooCls; +//// +//////Arguments +////remoteclsTest = new remotefooCls(remoteglobalVar); +////remotefoo(remoteglobalVar); +//// +//////Increments +////remotefooCls.remoteclsSVar++; +////remotemodTest.remotemodVar++; +////remoteglobalVar = remoteglobalVar + remoteglobalVar; +//// +//////ETC - Other cases +////remoteglobalVar = 3; +//// +//////Find References misses method param +////var +//// +//// +//// +//// array = ["f", "o", "o"]; +//// +////array.forEach( +//// +//// +////function(str) { +//// +//// +//// +//// return /*15*/str + " "; +//// +////}); + +// @Filename: localGetReferences_2.ts +////var remoteglobalVar: number = 2; +//// +////class remotefooCls { +//// //Declare +//// remoteclsVar = 1; +//// static remoteclsSVar = 1; +//// +//// constructor(public remoteclsParam: number) { +//// //Increments +//// remoteglobalVar++; +//// this.remoteclsVar++; +//// remotefooCls.remoteclsSVar++; +//// this.remoteclsParam++; +//// remotemodTest.remotemodVar++; +//// } +////} +//// +////function remotefoo(remotex: number) { +//// //Declare +//// var remotefnVar = 1; +//// +//// //Increments +//// remotefooCls.remoteclsSVar++; +//// remoteglobalVar++; +//// remotemodTest.remotemodVar++; +//// remotefnVar++; +//// +//// //Return +//// return remotex++; +////} +//// +////module remotemodTest { +//// //Declare +//// export var remotemodVar: number; +//// +//// //Increments +//// remoteglobalVar++; +//// remotefooCls.remoteclsSVar++; +//// remotemodVar++; +//// +//// class remotetestCls { +//// static remoteboo = remotefoo; +//// } +//// +//// function remotetestFn(){ +//// static remoteboo = remotefoo; +//// +//// //Increments +//// remoteglobalVar++; +//// remotefooCls.remoteclsSVar++; +//// remotemodVar++; +//// } +//// +//// module remotetestMod { +//// var remoteboo = remotefoo; +//// } +////} + +// References to comment. +goTo.marker("1"); +verify.referencesCountIs(0); + +// References to type. +goTo.marker("2"); +verify.referencesCountIs(0); + +// References to a variable declared in global. +goTo.marker("3"); +verify.referencesCountIs(11); + +// References to a variable declared in a class. +goTo.marker("4"); +verify.referencesCountIs(2); + +// References to static variable declared in a class. +goTo.marker("5"); +verify.referencesCountIs(6); + +// References to a variable declared in a function. +goTo.marker("6"); +verify.referencesCountIs(2); + +// References to a class parameter. +goTo.marker("7"); +verify.referencesCountIs(2); + +// References to a function parameter. +goTo.marker("8"); +verify.referencesCountIs(2); + +// References to a function argument. +goTo.marker("9"); +verify.referencesCountIs(11); + +// References to a class argument. +goTo.marker("10"); +verify.referencesCountIs(11); + +// References to illegal assignment. +goTo.marker("11"); +verify.referencesCountIs(7); + +// References to unresolved symbol. +goTo.marker("12"); +verify.referencesCountIs(1); + +// References to no context. +goTo.marker("13"); +verify.referencesCountIs(0); + +// References to shadowed function parameter. +goTo.marker("14"); +verify.referencesCountIs(3); + +// Reference misses function parameter. +goTo.marker("15"); verify.referencesCountIs(2); \ No newline at end of file diff --git a/tests/cases/fourslash/malformedObjectLiteral.ts b/tests/cases/fourslash/malformedObjectLiteral.ts index dd0690c4ca7..85d1a956188 100644 --- a/tests/cases/fourslash/malformedObjectLiteral.ts +++ b/tests/cases/fourslash/malformedObjectLiteral.ts @@ -1,10 +1,10 @@ -/// - -////var tt = { aa };/**/ -////var y = /*1*/"unclosed string literal -/////*2*/var x = "closed string literal" -verify.errorExistsBeforeMarker(); -verify.errorExistsAfterMarker("1"); -verify.not.errorExistsAfterMarker("2"); - - +/// + +////var tt = { aa };/**/ +////var y = /*1*/"unclosed string literal +/////*2*/var x = "closed string literal" +verify.errorExistsBeforeMarker(); +verify.errorExistsAfterMarker("1"); +verify.not.errorExistsAfterMarker("2"); + + diff --git a/tests/cases/fourslash/memberCompletionFromFunctionCall.ts b/tests/cases/fourslash/memberCompletionFromFunctionCall.ts index a60a2d37b2f..56629a3b510 100644 --- a/tests/cases/fourslash/memberCompletionFromFunctionCall.ts +++ b/tests/cases/fourslash/memberCompletionFromFunctionCall.ts @@ -1,12 +1,12 @@ -/// - -////declare interface ifoo { -//// text: (value: any) => ifoo; -////} -////declare var foo: ifoo; -////foo.text(function() { })/**/ - -goTo.marker(); -edit.insert("."); -verify.not.memberListIsEmpty(); +/// + +////declare interface ifoo { +//// text: (value: any) => ifoo; +////} +////declare var foo: ifoo; +////foo.text(function() { })/**/ + +goTo.marker(); +edit.insert("."); +verify.not.memberListIsEmpty(); verify.memberListContains("text"); \ No newline at end of file diff --git a/tests/cases/fourslash/memberConstructorEdits.ts b/tests/cases/fourslash/memberConstructorEdits.ts index 2bc2018cd89..45d631cd2b8 100644 --- a/tests/cases/fourslash/memberConstructorEdits.ts +++ b/tests/cases/fourslash/memberConstructorEdits.ts @@ -1,26 +1,26 @@ -/// - -//// module M { -//// export class A { -//// constructor(a: string) {} -//// public m(n: number) { -//// return 0; -//// } -//// public n() { -//// return this.m(0); -//// } -//// } -//// export class B extends A { -//// constructor(a: string) { -//// super(a); -//// } -//// /*1*/ -//// } -//// var a = new A("s"); -//// var b = new B("s"); -//// } - -verify.numberOfErrorsInCurrentFile(0); -goTo.marker('1'); -edit.insert("public m(n: number) { return 0; }"); +/// + +//// module M { +//// export class A { +//// constructor(a: string) {} +//// public m(n: number) { +//// return 0; +//// } +//// public n() { +//// return this.m(0); +//// } +//// } +//// export class B extends A { +//// constructor(a: string) { +//// super(a); +//// } +//// /*1*/ +//// } +//// var a = new A("s"); +//// var b = new B("s"); +//// } + +verify.numberOfErrorsInCurrentFile(0); +goTo.marker('1'); +edit.insert("public m(n: number) { return 0; }"); verify.numberOfErrorsInCurrentFile(0); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListAfterSingleDot.ts b/tests/cases/fourslash/memberListAfterSingleDot.ts index e6e5d8ad0e8..0bc5107f2c1 100644 --- a/tests/cases/fourslash/memberListAfterSingleDot.ts +++ b/tests/cases/fourslash/memberListAfterSingleDot.ts @@ -1,6 +1,6 @@ -/// - -////./**/ - -goTo.marker(); +/// + +////./**/ + +goTo.marker(); verify.not.memberListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListErrorRecovery.ts b/tests/cases/fourslash/memberListErrorRecovery.ts index d1957ba3e4a..74bd25464f6 100644 --- a/tests/cases/fourslash/memberListErrorRecovery.ts +++ b/tests/cases/fourslash/memberListErrorRecovery.ts @@ -1,10 +1,10 @@ -/// - -////class Foo { static fun() { }; } -//// -////Foo./**/; -/////*1*/var bar; - -goTo.marker(); -verify.memberListContains("fun"); +/// + +////class Foo { static fun() { }; } +//// +////Foo./**/; +/////*1*/var bar; + +goTo.marker(); +verify.memberListContains("fun"); verify.not.errorExistsAfterMarker("1"); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListInsideObjectLiterals.ts b/tests/cases/fourslash/memberListInsideObjectLiterals.ts index 6da0ac5b562..99d62cbc6e5 100644 --- a/tests/cases/fourslash/memberListInsideObjectLiterals.ts +++ b/tests/cases/fourslash/memberListInsideObjectLiterals.ts @@ -1,41 +1,41 @@ -/// - -////module ObjectLiterals { -//// interface MyPoint { -//// x1: number; -//// y1: number; -//// } -//// -//// var p1: MyPoint = { -//// /*1*/ -//// }; -//// -//// var p2: MyPoint = { -//// x1: 5, -//// /*2*/ -//// }; -//// -//// var p3: MyPoint = { -//// x1/*3*/: -//// }; -//// -//// var p4: MyPoint = { -//// /*4*/y1 -//// }; -////} - -// Literal member completion inside empty literal. -goTo.marker("1"); -verify.memberListContains("x1", "(property) MyPoint.x1: number"); -verify.memberListContains("y1", "(property) MyPoint.y1: number"); - -// Literal member completion for 2nd member name. -goTo.marker("2"); -verify.memberListContains("y1", "(property) MyPoint.y1: number"); - -// Literal member completion at existing member name location. -goTo.marker("3"); -verify.memberListContains("y1", "(property) MyPoint.y1: number"); - -goTo.marker("4"); +/// + +////module ObjectLiterals { +//// interface MyPoint { +//// x1: number; +//// y1: number; +//// } +//// +//// var p1: MyPoint = { +//// /*1*/ +//// }; +//// +//// var p2: MyPoint = { +//// x1: 5, +//// /*2*/ +//// }; +//// +//// var p3: MyPoint = { +//// x1/*3*/: +//// }; +//// +//// var p4: MyPoint = { +//// /*4*/y1 +//// }; +////} + +// Literal member completion inside empty literal. +goTo.marker("1"); +verify.memberListContains("x1", "(property) MyPoint.x1: number"); +verify.memberListContains("y1", "(property) MyPoint.y1: number"); + +// Literal member completion for 2nd member name. +goTo.marker("2"); +verify.memberListContains("y1", "(property) MyPoint.y1: number"); + +// Literal member completion at existing member name location. +goTo.marker("3"); +verify.memberListContains("y1", "(property) MyPoint.y1: number"); + +goTo.marker("4"); verify.memberListContains("x1", "(property) MyPoint.x1: number"); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListOfClass.ts b/tests/cases/fourslash/memberListOfClass.ts index c12e781a852..6c93a0536d9 100644 --- a/tests/cases/fourslash/memberListOfClass.ts +++ b/tests/cases/fourslash/memberListOfClass.ts @@ -1,15 +1,15 @@ -/// - -////class C1 { -//// public pubMeth() { } -//// private privMeth() { } -//// public pubProp = 0; -//// private privProp = 0; -////} -////var f = new C1(); -////f./**/ - -goTo.marker(); -verify.memberListCount(2); -verify.memberListContains('pubMeth', '(method) C1.pubMeth(): void'); +/// + +////class C1 { +//// public pubMeth() { } +//// private privMeth() { } +//// public pubProp = 0; +//// private privProp = 0; +////} +////var f = new C1(); +////f./**/ + +goTo.marker(); +verify.memberListCount(2); +verify.memberListContains('pubMeth', '(method) C1.pubMeth(): void'); verify.memberListContains('pubProp', '(property) C1.pubProp: number'); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListOfEnumInModule.ts b/tests/cases/fourslash/memberListOfEnumInModule.ts index 09db5d24617..f92c5d43ea8 100644 --- a/tests/cases/fourslash/memberListOfEnumInModule.ts +++ b/tests/cases/fourslash/memberListOfEnumInModule.ts @@ -1,13 +1,13 @@ -/// - -////module Fixes { -//// enum Foo { -//// bar, -//// baz -//// } -//// var f: Foo = Foo./**/; -////} - -goTo.marker(); -verify.memberListContains("bar"); +/// + +////module Fixes { +//// enum Foo { +//// bar, +//// baz +//// } +//// var f: Foo = Foo./**/; +////} + +goTo.marker(); +verify.memberListContains("bar"); verify.memberListContains("baz"); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListOfExportedClass.ts b/tests/cases/fourslash/memberListOfExportedClass.ts index eaebab14f27..f6632bfe7b0 100644 --- a/tests/cases/fourslash/memberListOfExportedClass.ts +++ b/tests/cases/fourslash/memberListOfExportedClass.ts @@ -1,15 +1,15 @@ -/// - -////module M { -//// export class C { public pub = 0; private priv = 1; } -//// export var V = 0; -////} -//// -//// -////var c = new M.C(); -//// -////c./**/ // test on c. - -goTo.marker(); -verify.memberListCount(1); +/// + +////module M { +//// export class C { public pub = 0; private priv = 1; } +//// export var V = 0; +////} +//// +//// +////var c = new M.C(); +//// +////c./**/ // test on c. + +goTo.marker(); +verify.memberListCount(1); verify.memberListContains('pub', '(property) M.C.pub: number'); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListOfModule.ts b/tests/cases/fourslash/memberListOfModule.ts index be6066043d1..f09dfd67dbd 100644 --- a/tests/cases/fourslash/memberListOfModule.ts +++ b/tests/cases/fourslash/memberListOfModule.ts @@ -1,19 +1,19 @@ -/// - -////module Foo { -//// export class Bar { -//// -//// } -//// -//// -//// export module Blah { -//// -//// } -////} -//// -////var x: Foo./**/ - -goTo.marker(); -verify.memberListCount(2); -verify.memberListContains('Bar'); +/// + +////module Foo { +//// export class Bar { +//// +//// } +//// +//// +//// export module Blah { +//// +//// } +////} +//// +////var x: Foo./**/ + +goTo.marker(); +verify.memberListCount(2); +verify.memberListContains('Bar'); verify.memberListContains('Blah'); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListOfModuleAfterInvalidCharater.ts b/tests/cases/fourslash/memberListOfModuleAfterInvalidCharater.ts index a571c519c0f..b5bd4fb6bb5 100644 --- a/tests/cases/fourslash/memberListOfModuleAfterInvalidCharater.ts +++ b/tests/cases/fourslash/memberListOfModuleAfterInvalidCharater.ts @@ -1,10 +1,10 @@ -/// - -////module testModule { -//// export var foo = 1; -////} -////@ -////testModule./**/ - -goTo.marker(); +/// + +////module testModule { +//// export var foo = 1; +////} +////@ +////testModule./**/ + +goTo.marker(); verify.completionListContains('foo', '(var) testModule.foo: number'); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListOfModuleBeforeKeyword.ts b/tests/cases/fourslash/memberListOfModuleBeforeKeyword.ts index 33f085cde03..0ea07e87a0a 100644 --- a/tests/cases/fourslash/memberListOfModuleBeforeKeyword.ts +++ b/tests/cases/fourslash/memberListOfModuleBeforeKeyword.ts @@ -1,24 +1,24 @@ -/// - -////module TypeModule1 { -//// export class C1 { } -//// export class C2 { } -////} -////var x: TypeModule1./*namedType*/ -////module TypeModule2 { -//// export class Test3 {} -////} -//// -////TypeModule1./*dotedExpression*/ -////module TypeModule3 { -//// export class Test3 {} -////} - -// Verify the memberlist of module when the following line has a keyword -goTo.marker('namedType'); -verify.completionListContains('C1'); -verify.completionListContains('C2'); - -goTo.marker('dotedExpression'); -verify.completionListContains('C1'); +/// + +////module TypeModule1 { +//// export class C1 { } +//// export class C2 { } +////} +////var x: TypeModule1./*namedType*/ +////module TypeModule2 { +//// export class Test3 {} +////} +//// +////TypeModule1./*dotedExpression*/ +////module TypeModule3 { +//// export class Test3 {} +////} + +// Verify the memberlist of module when the following line has a keyword +goTo.marker('namedType'); +verify.completionListContains('C1'); +verify.completionListContains('C2'); + +goTo.marker('dotedExpression'); +verify.completionListContains('C1'); verify.completionListContains('C2'); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListOfModuleInAnotherModule.ts b/tests/cases/fourslash/memberListOfModuleInAnotherModule.ts index 96044ffcc8a..4ac2778ac5a 100644 --- a/tests/cases/fourslash/memberListOfModuleInAnotherModule.ts +++ b/tests/cases/fourslash/memberListOfModuleInAnotherModule.ts @@ -1,37 +1,37 @@ -/// - -////module mod1 { -//// var mX = 1; -//// function mFunc() { } -//// class mClass { } -//// module mMod { } -//// interface mInt {} -//// export var meX = 1; -//// export function meFunc() { } -//// export class meClass { } -//// export module meMod { export var iMex = 1; } -//// export interface meInt {} -////} -//// -////module frmConfirm { -//// import Mod1 = mod1; -//// import iMod1 = mod1./*1*/meMod; -//// Mod1./*2*/meX = 1; -//// iMod1./*3*/iMex = 1; -////} - -goTo.marker('1'); -verify.completionListContains('meX', '(var) mod1.meX: number'); -verify.completionListContains('meFunc', '(function) mod1.meFunc(): void'); -verify.completionListContains('meClass', 'class mod1.meClass'); -verify.completionListContains('meMod', 'module mod1.meMod'); -verify.completionListContains('meInt', 'interface mod1.meInt'); - -goTo.marker('2'); -verify.completionListContains('meX', '(var) mod1.meX: number'); -verify.completionListContains('meFunc', '(function) mod1.meFunc(): void'); -verify.completionListContains('meClass', 'class mod1.meClass'); -verify.completionListContains('meMod', 'module mod1.meMod'); - -goTo.marker('3'); +/// + +////module mod1 { +//// var mX = 1; +//// function mFunc() { } +//// class mClass { } +//// module mMod { } +//// interface mInt {} +//// export var meX = 1; +//// export function meFunc() { } +//// export class meClass { } +//// export module meMod { export var iMex = 1; } +//// export interface meInt {} +////} +//// +////module frmConfirm { +//// import Mod1 = mod1; +//// import iMod1 = mod1./*1*/meMod; +//// Mod1./*2*/meX = 1; +//// iMod1./*3*/iMex = 1; +////} + +goTo.marker('1'); +verify.completionListContains('meX', '(var) mod1.meX: number'); +verify.completionListContains('meFunc', '(function) mod1.meFunc(): void'); +verify.completionListContains('meClass', 'class mod1.meClass'); +verify.completionListContains('meMod', 'module mod1.meMod'); +verify.completionListContains('meInt', 'interface mod1.meInt'); + +goTo.marker('2'); +verify.completionListContains('meX', '(var) mod1.meX: number'); +verify.completionListContains('meFunc', '(function) mod1.meFunc(): void'); +verify.completionListContains('meClass', 'class mod1.meClass'); +verify.completionListContains('meMod', 'module mod1.meMod'); + +goTo.marker('3'); verify.completionListContains('iMex', '(var) mod1.meMod.iMex: number'); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListOnConstructorType.ts b/tests/cases/fourslash/memberListOnConstructorType.ts index 071b597955e..3d5596f2e58 100644 --- a/tests/cases/fourslash/memberListOnConstructorType.ts +++ b/tests/cases/fourslash/memberListOnConstructorType.ts @@ -1,8 +1,8 @@ -/// - -////var f: new () => void; -////f./*1*/ - -goTo.marker('1'); -verify.completionListContains('apply'); +/// + +////var f: new () => void; +////f./*1*/ + +goTo.marker('1'); +verify.completionListContains('apply'); verify.completionListContains('arguments'); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListOnFunctionParameter.ts b/tests/cases/fourslash/memberListOnFunctionParameter.ts index add2ed442be..ee33cdc95e5 100644 --- a/tests/cases/fourslash/memberListOnFunctionParameter.ts +++ b/tests/cases/fourslash/memberListOnFunctionParameter.ts @@ -1,13 +1,13 @@ -/// - -////module Test10 { -//// var x: string[] = []; -//// x.forEach(function (y) { y./**/} ); -////} - -goTo.marker(); -verify.memberListContains("charAt"); -verify.memberListContains("charCodeAt"); -verify.memberListContains("length"); -verify.memberListContains("concat"); +/// + +////module Test10 { +//// var x: string[] = []; +//// x.forEach(function (y) { y./**/} ); +////} + +goTo.marker(); +verify.memberListContains("charAt"); +verify.memberListContains("charCodeAt"); +verify.memberListContains("length"); +verify.memberListContains("concat"); verify.not.memberListContains("toFixed"); \ No newline at end of file diff --git a/tests/cases/fourslash/memberListOnThisInClassWithPrivates.ts b/tests/cases/fourslash/memberListOnThisInClassWithPrivates.ts index 15686b4f7b8..341605e391c 100644 --- a/tests/cases/fourslash/memberListOnThisInClassWithPrivates.ts +++ b/tests/cases/fourslash/memberListOnThisInClassWithPrivates.ts @@ -1,13 +1,13 @@ -/// - -////class C1 { -//// public pubMeth() {this./**/} // test on 'this.' -//// private privMeth() {} -//// public pubProp = 0; -//// private privProp = 0; -////} - -goTo.marker(); -verify.memberListContains('privMeth', '(method) C1.privMeth(): void'); -verify.memberListContains('pubMeth', '(method) C1.pubMeth(): void'); +/// + +////class C1 { +//// public pubMeth() {this./**/} // test on 'this.' +//// private privMeth() {} +//// public pubProp = 0; +//// private privProp = 0; +////} + +goTo.marker(); +verify.memberListContains('privMeth', '(method) C1.privMeth(): void'); +verify.memberListContains('pubMeth', '(method) C1.pubMeth(): void'); verify.memberListContains('pubProp', '(property) C1.pubProp: number'); \ No newline at end of file diff --git a/tests/cases/fourslash/memberOverloadEdits.ts b/tests/cases/fourslash/memberOverloadEdits.ts index 95184027bdd..43553a81179 100644 --- a/tests/cases/fourslash/memberOverloadEdits.ts +++ b/tests/cases/fourslash/memberOverloadEdits.ts @@ -1,18 +1,18 @@ -/// - -//// module M { -//// export class A { -//// public m(n: number) { -//// return 0; -//// } -//// public n() { -//// return this.m(0); -//// } -//// } -//// export class B extends A { /*1*/ } -//// } - -verify.numberOfErrorsInCurrentFile(0); -goTo.marker('1'); -edit.insert("public m(n: number) { return 0; }"); +/// + +//// module M { +//// export class A { +//// public m(n: number) { +//// return 0; +//// } +//// public n() { +//// return this.m(0); +//// } +//// } +//// export class B extends A { /*1*/ } +//// } + +verify.numberOfErrorsInCurrentFile(0); +goTo.marker('1'); +edit.insert("public m(n: number) { return 0; }"); verify.numberOfErrorsInCurrentFile(0); \ No newline at end of file diff --git a/tests/cases/fourslash/mispeltVariableForInLoopErrorRecovery.ts b/tests/cases/fourslash/mispeltVariableForInLoopErrorRecovery.ts index 38636f88424..48d6aedac84 100644 --- a/tests/cases/fourslash/mispeltVariableForInLoopErrorRecovery.ts +++ b/tests/cases/fourslash/mispeltVariableForInLoopErrorRecovery.ts @@ -1,8 +1,8 @@ -/// - -////var alpha = [1, 2, 3]; -////for (var beta in alpha) { -//// alpha[beat/**/]++; -////} - -verify.not.errorExistsAfterMarker(); +/// + +////var alpha = [1, 2, 3]; +////for (var beta in alpha) { +//// alpha[beat/**/]++; +////} + +verify.not.errorExistsAfterMarker(); diff --git a/tests/cases/fourslash/moduleRenamingErrorRecovery.ts b/tests/cases/fourslash/moduleRenamingErrorRecovery.ts index f8d83a9e407..ada428d03bd 100644 --- a/tests/cases/fourslash/moduleRenamingErrorRecovery.ts +++ b/tests/cases/fourslash/moduleRenamingErrorRecovery.ts @@ -1,9 +1,9 @@ -/// - -////module Alpha/*1*//*2*/ { class Foo { public bar() { } } } - -goTo.marker("1"); -edit.backspace(5); -edit.insert("Pizza"); -verify.currentLineContentIs("module Pizza { class Foo { public bar() { } } }"); +/// + +////module Alpha/*1*//*2*/ { class Foo { public bar() { } } } + +goTo.marker("1"); +edit.backspace(5); +edit.insert("Pizza"); +verify.currentLineContentIs("module Pizza { class Foo { public bar() { } } }"); verify.not.errorExistsAfterMarker("2"); \ No newline at end of file diff --git a/tests/cases/fourslash/multipleExportAssignmentsErrorList0.ts b/tests/cases/fourslash/multipleExportAssignmentsErrorList0.ts index 721d110ce68..bb13973cc82 100644 --- a/tests/cases/fourslash/multipleExportAssignmentsErrorList0.ts +++ b/tests/cases/fourslash/multipleExportAssignmentsErrorList0.ts @@ -1,27 +1,27 @@ -/// - -//// interface connectModule { -//// (res, req, next): void; -//// } -//// interface connectExport { -//// use: (mod: connectModule) => connectExport; -//// listen: (port: number) => void; -//// } -//// var server: { -//// (): connectExport; -//// test1: connectModule; -//// test2(): connectModule; -//// }; -//// export = server; -//// /*1*/export = connectExport; -//// -//// - -edit.disableFormatting(); -goTo.marker('1'); - -edit.deleteAtCaret(24); - -goTo.marker('1'); - -edit.insert("export = connectExport;\n"); +/// + +//// interface connectModule { +//// (res, req, next): void; +//// } +//// interface connectExport { +//// use: (mod: connectModule) => connectExport; +//// listen: (port: number) => void; +//// } +//// var server: { +//// (): connectExport; +//// test1: connectModule; +//// test2(): connectModule; +//// }; +//// export = server; +//// /*1*/export = connectExport; +//// +//// + +edit.disableFormatting(); +goTo.marker('1'); + +edit.deleteAtCaret(24); + +goTo.marker('1'); + +edit.insert("export = connectExport;\n"); diff --git a/tests/cases/fourslash/nameOfRetypedClassInModule.ts b/tests/cases/fourslash/nameOfRetypedClassInModule.ts index 4faddd2b686..7dea74020f8 100644 --- a/tests/cases/fourslash/nameOfRetypedClassInModule.ts +++ b/tests/cases/fourslash/nameOfRetypedClassInModule.ts @@ -1,32 +1,32 @@ -/// - -//// module M { -//// } -//// -//// module M { -//// /*A*/class A {} -//// /*B*/export class B {} -//// class Check { /*check*/constructor(val) {} } -//// export class Check2 { /*check2*/constructor(val) {} } -//// } -//// - -edit.disableFormatting(); - -goTo.marker('check'); -verify.quickInfoIs('(constructor) Check(val: any): Check'); - -goTo.marker('check2'); -verify.quickInfoIs('(constructor) M.Check2(val: any): Check2'); - -goTo.marker('A'); -edit.deleteAtCaret('class A {}'.length); -edit.insert('class A { constructor(val) {} }'); -edit.moveLeft('constructor(val) {} }'.length); -verify.quickInfoIs('(constructor) A(val: any): A'); - -goTo.marker('B'); -edit.deleteAtCaret('export class B {}'.length); -edit.insert('export class B { constructor(val) {} }'); -edit.moveLeft('constructor(val) {} }'.length); -verify.quickInfoIs('(constructor) M.B(val: any): B'); +/// + +//// module M { +//// } +//// +//// module M { +//// /*A*/class A {} +//// /*B*/export class B {} +//// class Check { /*check*/constructor(val) {} } +//// export class Check2 { /*check2*/constructor(val) {} } +//// } +//// + +edit.disableFormatting(); + +goTo.marker('check'); +verify.quickInfoIs('(constructor) Check(val: any): Check'); + +goTo.marker('check2'); +verify.quickInfoIs('(constructor) M.Check2(val: any): Check2'); + +goTo.marker('A'); +edit.deleteAtCaret('class A {}'.length); +edit.insert('class A { constructor(val) {} }'); +edit.moveLeft('constructor(val) {} }'.length); +verify.quickInfoIs('(constructor) A(val: any): A'); + +goTo.marker('B'); +edit.deleteAtCaret('export class B {}'.length); +edit.insert('export class B { constructor(val) {} }'); +edit.moveLeft('constructor(val) {} }'.length); +verify.quickInfoIs('(constructor) M.B(val: any): B'); diff --git a/tests/cases/fourslash/nameOrDottedNameClasses.ts b/tests/cases/fourslash/nameOrDottedNameClasses.ts index 9aa63a7a473..7a0fd8c19c3 100644 --- a/tests/cases/fourslash/nameOrDottedNameClasses.ts +++ b/tests/cases/fourslash/nameOrDottedNameClasses.ts @@ -3,37 +3,37 @@ // @BaselineFile: nameOrDottedSpan_classes.baseline // @Filename: nameOrDottedSpan_classes.ts ////module Foo.Bar { -//// "use strict"; -//// +//// "use strict"; +//// //// class Greeter { //// constructor(public greeting: string) { //// } -//// +//// //// greet() { //// return "

" + this.greeting + "

"; //// } -//// } -//// -//// +//// } +//// +//// //// function foo(greeting: string): Greeter { //// return new Greeter(greeting); -//// } -//// -//// var greeter = new Greeter("Hello, world!"); -//// var str = greeter.greet(); -//// +//// } +//// +//// var greeter = new Greeter("Hello, world!"); +//// var str = greeter.greet(); +//// //// function foo2(greeting: string, ...restGreetings /* more greeting */: string[]) { //// var greeters: Greeter[] = []; /* inline block comment */ //// greeters[0] = new Greeter(greeting); //// for (var i = 0; i < restGreetings.length; i++) { //// greeters.push(new Greeter(restGreetings[i])); //// } -//// +//// //// return greeters; -//// } -//// -//// var b = foo2("Hello", "World", "!"); -//// // This is simple signle line comment +//// } +//// +//// var b = foo2("Hello", "World", "!"); +//// // This is simple signle line comment //// for (var j = 0; j < b.length; j++) { //// b[j].greet(); //// } diff --git a/tests/cases/fourslash/navigateItemsConst.ts b/tests/cases/fourslash/navigateItemsConst.ts index d5ccb31066d..a20c0192874 100644 --- a/tests/cases/fourslash/navigateItemsConst.ts +++ b/tests/cases/fourslash/navigateItemsConst.ts @@ -1,9 +1,9 @@ /// -////{| "itemName": "c", "kind": "const", "parentName": "" |}const c = 10; -////function foo() { -//// {| "itemName": "d", "kind": "const", "parentName": "foo" |}const d = 10; -////} +////{| "itemName": "c", "kind": "const", "parentName": "" |}const c = 10; +////function foo() { +//// {| "itemName": "d", "kind": "const", "parentName": "foo" |}const d = 10; +////} test.markers().forEach(marker => { verify.navigationItemsListContains( diff --git a/tests/cases/fourslash/navigationItemsExactMatch.ts b/tests/cases/fourslash/navigationItemsExactMatch.ts index 9658c52324c..5481f4295cb 100644 --- a/tests/cases/fourslash/navigationItemsExactMatch.ts +++ b/tests/cases/fourslash/navigationItemsExactMatch.ts @@ -1,27 +1,27 @@ -/// - -/////// Module -////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes { -//// -//// // Class -//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point { -//// // Instance member -//// {| "itemName": "origin", "kind": "property", "parentName": "Point", "matchKind": "exact"|}private origin = 0.0; -//// -//// {| "itemName": "distFromZero", "kind": "property", "parentName": "Point", "matchKind": "exact"|}private distFromZero = 0.0; -//// -//// // Getter -//// {| "itemName": "distance", "kind": "getter", "parentName": "Point", "matchKind": "exact" |}get distance(): number { return 0; } -//// } -////} -//// -////// Local variables -////{| "itemName": "point", "kind": "var", "parentName": "", "matchKind": "exact"|}var point = new Shapes.Point(); - -//// Testing for exact matching of navigationItems - -test.markers().forEach((marker) => { - if (marker.data) { - verify.navigationItemsListContains(marker.data.itemName, marker.data.kind, marker.data.itemName, marker.data.matchKind, marker.fileName, marker.data.parentName); - } -}); +/// + +/////// Module +////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes { +//// +//// // Class +//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point { +//// // Instance member +//// {| "itemName": "origin", "kind": "property", "parentName": "Point", "matchKind": "exact"|}private origin = 0.0; +//// +//// {| "itemName": "distFromZero", "kind": "property", "parentName": "Point", "matchKind": "exact"|}private distFromZero = 0.0; +//// +//// // Getter +//// {| "itemName": "distance", "kind": "getter", "parentName": "Point", "matchKind": "exact" |}get distance(): number { return 0; } +//// } +////} +//// +////// Local variables +////{| "itemName": "point", "kind": "var", "parentName": "", "matchKind": "exact"|}var point = new Shapes.Point(); + +//// Testing for exact matching of navigationItems + +test.markers().forEach((marker) => { + if (marker.data) { + verify.navigationItemsListContains(marker.data.itemName, marker.data.kind, marker.data.itemName, marker.data.matchKind, marker.fileName, marker.data.parentName); + } +}); diff --git a/tests/cases/fourslash/navigationItemsExactMatch2.ts b/tests/cases/fourslash/navigationItemsExactMatch2.ts index adf8e69761e..e96d4f65ed4 100644 --- a/tests/cases/fourslash/navigationItemsExactMatch2.ts +++ b/tests/cases/fourslash/navigationItemsExactMatch2.ts @@ -1,28 +1,28 @@ -/// -// @Filename: navigationItemsContainsNoAnonymousFunctions_0.ts -/////*file1*/ -////module Shapes { -//// class Point { -//// private _origin = 0.0; -//// private distanceFromA = 0.0; -//// -//// get distance1(distanceParam): number { -//// var distanceLocal; -//// return 0; -//// } -//// } -////} -//// -////var point = new Shapes.Point(); -////function distance2(distanceParam1): void { -//// var distanceLocal1; -////} -debugger; -goTo.marker("file1"); -verify.navigationItemsListCount(2, "point", "exact"); -verify.navigationItemsListCount(5, "distance", "prefix"); -verify.navigationItemsListCount(1, "origin", "substring"); - -verify.navigationItemsListCount(0, "square", "exact"); -verify.navigationItemsListCount(0, "square", "prefix"); +/// +// @Filename: navigationItemsContainsNoAnonymousFunctions_0.ts +/////*file1*/ +////module Shapes { +//// class Point { +//// private _origin = 0.0; +//// private distanceFromA = 0.0; +//// +//// get distance1(distanceParam): number { +//// var distanceLocal; +//// return 0; +//// } +//// } +////} +//// +////var point = new Shapes.Point(); +////function distance2(distanceParam1): void { +//// var distanceLocal1; +////} +debugger; +goTo.marker("file1"); +verify.navigationItemsListCount(2, "point", "exact"); +verify.navigationItemsListCount(5, "distance", "prefix"); +verify.navigationItemsListCount(1, "origin", "substring"); + +verify.navigationItemsListCount(0, "square", "exact"); +verify.navigationItemsListCount(0, "square", "prefix"); verify.navigationItemsListCount(0, "square", "substring"); \ No newline at end of file diff --git a/tests/cases/fourslash/navigationItemsInConstructorsExactMatch.ts b/tests/cases/fourslash/navigationItemsInConstructorsExactMatch.ts index 68bb7db5c72..10397813fd0 100644 --- a/tests/cases/fourslash/navigationItemsInConstructorsExactMatch.ts +++ b/tests/cases/fourslash/navigationItemsInConstructorsExactMatch.ts @@ -1,12 +1,12 @@ -/// - -////class Test { -//// private search1: number; -//// constructor(public search2: boolean, search3: string) { -//// } -////} - -// Search for properties defined in the constructor, but not other constructor paramters -var searchValue = "search"; -verify.navigationItemsListContains("search1", "property", searchValue, "prefix"); -verify.navigationItemsListContains("search2", "property", searchValue, "prefix"); +/// + +////class Test { +//// private search1: number; +//// constructor(public search2: boolean, search3: string) { +//// } +////} + +// Search for properties defined in the constructor, but not other constructor paramters +var searchValue = "search"; +verify.navigationItemsListContains("search1", "property", searchValue, "prefix"); +verify.navigationItemsListContains("search2", "property", searchValue, "prefix"); diff --git a/tests/cases/fourslash/navigationItemsOverloads1.ts b/tests/cases/fourslash/navigationItemsOverloads1.ts index 5f1981fe917..68d0c8d1f83 100644 --- a/tests/cases/fourslash/navigationItemsOverloads1.ts +++ b/tests/cases/fourslash/navigationItemsOverloads1.ts @@ -1,30 +1,30 @@ -/// - -////function overload(a: string): boolean; -////function overload(b: boolean): boolean; -////function overload(b: number): boolean; -////function overload(f: typeof overload): boolean; -////function overload(x: any, b = (function overload() { return false })): boolean { -//// throw overload; -////} -//// -////interface I { -//// interfaceMethodSignature(a: string): boolean; -//// interfaceMethodSignature(b: boolean): boolean; -//// interfaceMethodSignature(b: number): boolean; -//// interfaceMethodSignature(f: I): boolean; -////} -//// -////class C { -//// methodOverload(a: string): boolean; -//// methodOverload(b: boolean): boolean; -//// methodOverload(b: number): boolean; -//// methodOverload(f: I): boolean; -//// methodOverload(x: any, b = (function overload() { return false })): boolean { -//// throw C; -//// } -////} - -verify.navigationItemsListCount(1, "overload", "exact"); -verify.navigationItemsListCount(1, "interfaceMethodSignature", "exact"); -verify.navigationItemsListCount(1, "methodOverload", "exact"); +/// + +////function overload(a: string): boolean; +////function overload(b: boolean): boolean; +////function overload(b: number): boolean; +////function overload(f: typeof overload): boolean; +////function overload(x: any, b = (function overload() { return false })): boolean { +//// throw overload; +////} +//// +////interface I { +//// interfaceMethodSignature(a: string): boolean; +//// interfaceMethodSignature(b: boolean): boolean; +//// interfaceMethodSignature(b: number): boolean; +//// interfaceMethodSignature(f: I): boolean; +////} +//// +////class C { +//// methodOverload(a: string): boolean; +//// methodOverload(b: boolean): boolean; +//// methodOverload(b: number): boolean; +//// methodOverload(f: I): boolean; +//// methodOverload(x: any, b = (function overload() { return false })): boolean { +//// throw C; +//// } +////} + +verify.navigationItemsListCount(1, "overload", "exact"); +verify.navigationItemsListCount(1, "interfaceMethodSignature", "exact"); +verify.navigationItemsListCount(1, "methodOverload", "exact"); diff --git a/tests/cases/fourslash/navigationItemsOverloads2.ts b/tests/cases/fourslash/navigationItemsOverloads2.ts index c5824b639bc..2c33ef65f0d 100644 --- a/tests/cases/fourslash/navigationItemsOverloads2.ts +++ b/tests/cases/fourslash/navigationItemsOverloads2.ts @@ -1,12 +1,12 @@ -/// - -////interface I { -//// interfaceMethodSignature(a: string): boolean; -//// interfaceMethodSignature(b: number): boolean; -//// interfaceMethodSignature(f: I): boolean; -////} -////interface I { -//// interfaceMethodSignature(b: boolean): boolean; -////} - -verify.navigationItemsListCount(2, "interfaceMethodSignature", "exact"); +/// + +////interface I { +//// interfaceMethodSignature(a: string): boolean; +//// interfaceMethodSignature(b: number): boolean; +//// interfaceMethodSignature(f: I): boolean; +////} +////interface I { +//// interfaceMethodSignature(b: boolean): boolean; +////} + +verify.navigationItemsListCount(2, "interfaceMethodSignature", "exact"); diff --git a/tests/cases/fourslash/navigationItemsOverloadsBroken1.ts b/tests/cases/fourslash/navigationItemsOverloadsBroken1.ts index 7b8ebc9181f..d2a9ec8e25f 100644 --- a/tests/cases/fourslash/navigationItemsOverloadsBroken1.ts +++ b/tests/cases/fourslash/navigationItemsOverloadsBroken1.ts @@ -1,29 +1,29 @@ -/// - -////function overload1(a: string): boolean; -////function overload1(b: boolean): boolean; -////function overload1(b: number): boolean; -//// -////var heyImNotInterruptingAnythingAmI = '?'; -//// -////function overload1(f: typeof overload): boolean; -////function overload1(x: any, b = (function overload() { return false })): boolean { -//// throw overload; -////} - -////function overload2(a: string): boolean; -////function overload2(b: boolean): boolean; -////function overload2(b: number): boolean; -//// -////function iJustRuinEverything(x: any, b = (function overload() { return false })): boolean { -//// throw overload; -////} -//// -////function overload2(f: typeof overload): boolean; -////function overload2(x: any, b = (function overload() { return false })): boolean { -//// throw overload; -////} - -verify.navigationItemsListCount(2, "overload1", "exact"); -verify.navigationItemsListCount(2, "overload2", "exact"); +/// + +////function overload1(a: string): boolean; +////function overload1(b: boolean): boolean; +////function overload1(b: number): boolean; +//// +////var heyImNotInterruptingAnythingAmI = '?'; +//// +////function overload1(f: typeof overload): boolean; +////function overload1(x: any, b = (function overload() { return false })): boolean { +//// throw overload; +////} + +////function overload2(a: string): boolean; +////function overload2(b: boolean): boolean; +////function overload2(b: number): boolean; +//// +////function iJustRuinEverything(x: any, b = (function overload() { return false })): boolean { +//// throw overload; +////} +//// +////function overload2(f: typeof overload): boolean; +////function overload2(x: any, b = (function overload() { return false })): boolean { +//// throw overload; +////} + +verify.navigationItemsListCount(2, "overload1", "exact"); +verify.navigationItemsListCount(2, "overload2", "exact"); verify.navigationItemsListCount(4, "overload", "prefix"); \ No newline at end of file diff --git a/tests/cases/fourslash/navigationItemsOverloadsBroken2.ts b/tests/cases/fourslash/navigationItemsOverloadsBroken2.ts index c1f6ccae2f5..6b039322419 100644 --- a/tests/cases/fourslash/navigationItemsOverloadsBroken2.ts +++ b/tests/cases/fourslash/navigationItemsOverloadsBroken2.ts @@ -1,23 +1,23 @@ -/// - -////function overload1(a: string): boolean; -////function overload1(b: boolean): boolean; -////function overload1(x: any, b = (function overload() { return false })): boolean { -//// throw overload1; -////} -////function overload1(b: number): boolean; -////function overload1(f: typeof overload): boolean; - -////function overload2(a: string): boolean; -////function overload2(b: boolean): boolean; -////function overload2(x: any, b = (function overload() { return false })): boolean { -//// function overload2(): boolean; -//// function overload2(x: any): boolean; -//// throw overload2; -////} -////function overload2(b: number): boolean; -////function overload2(f: typeof overload): boolean; - -verify.navigationItemsListCount(1, "overload1", "exact"); -verify.navigationItemsListCount(3, "overload2", "exact"); +/// + +////function overload1(a: string): boolean; +////function overload1(b: boolean): boolean; +////function overload1(x: any, b = (function overload() { return false })): boolean { +//// throw overload1; +////} +////function overload1(b: number): boolean; +////function overload1(f: typeof overload): boolean; + +////function overload2(a: string): boolean; +////function overload2(b: boolean): boolean; +////function overload2(x: any, b = (function overload() { return false })): boolean { +//// function overload2(): boolean; +//// function overload2(x: any): boolean; +//// throw overload2; +////} +////function overload2(b: number): boolean; +////function overload2(f: typeof overload): boolean; + +verify.navigationItemsListCount(1, "overload1", "exact"); +verify.navigationItemsListCount(3, "overload2", "exact"); verify.navigationItemsListCount(4, "overload", "prefix"); \ No newline at end of file diff --git a/tests/cases/fourslash/navigationItemsPrefixMatch.ts b/tests/cases/fourslash/navigationItemsPrefixMatch.ts index b6ae4af0f33..b295def114f 100644 --- a/tests/cases/fourslash/navigationItemsPrefixMatch.ts +++ b/tests/cases/fourslash/navigationItemsPrefixMatch.ts @@ -1,29 +1,29 @@ -/// - -/////// Module -////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes { -//// -//// // Class -//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point { -//// // Instance member -//// {| "itemName": "originality", "kind": "property", "parentName": "Point", "matchKind": "prefix"|}private originality = 0.0; -//// -//// {| "itemName": "distanceFromOrig", "kind": "property", "parentName": "Point", "matchKind": "prefix"|}private distanceFromOrig = 0.0; -//// -//// // Getter -//// {| "itemName": "distanceFarFarAway", "kind": "getter", "parentName": "Point", "matchKind": "prefix" |}get distanceFarFarAway(): number { return 0; } -//// } -////} -//// -////// Local variables -////{| "itemName": "pointsSquareBox", "kind": "var", "parentName": "", "matchKind": "prefix" |}var pointsSquareBox = new Shapes.Point(); - -//// Testing for exact matching of navigationItems -// var searchValue = "origin distance points shape"; - -test.markers().forEach((marker) => { - if (marker.data) { - var itemName = marker.data.itemName; - verify.navigationItemsListContains(itemName, marker.data.kind, itemName.substr(0, itemName.length - 1), marker.data.matchKind, marker.fileName, marker.data.parentName); - } -}); +/// + +/////// Module +////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes { +//// +//// // Class +//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point { +//// // Instance member +//// {| "itemName": "originality", "kind": "property", "parentName": "Point", "matchKind": "prefix"|}private originality = 0.0; +//// +//// {| "itemName": "distanceFromOrig", "kind": "property", "parentName": "Point", "matchKind": "prefix"|}private distanceFromOrig = 0.0; +//// +//// // Getter +//// {| "itemName": "distanceFarFarAway", "kind": "getter", "parentName": "Point", "matchKind": "prefix" |}get distanceFarFarAway(): number { return 0; } +//// } +////} +//// +////// Local variables +////{| "itemName": "pointsSquareBox", "kind": "var", "parentName": "", "matchKind": "prefix" |}var pointsSquareBox = new Shapes.Point(); + +//// Testing for exact matching of navigationItems +// var searchValue = "origin distance points shape"; + +test.markers().forEach((marker) => { + if (marker.data) { + var itemName = marker.data.itemName; + verify.navigationItemsListContains(itemName, marker.data.kind, itemName.substr(0, itemName.length - 1), marker.data.matchKind, marker.fileName, marker.data.parentName); + } +}); diff --git a/tests/cases/fourslash/navigationItemsPrefixMatch2.ts b/tests/cases/fourslash/navigationItemsPrefixMatch2.ts index 282d0e2414f..0bce1f36b33 100644 --- a/tests/cases/fourslash/navigationItemsPrefixMatch2.ts +++ b/tests/cases/fourslash/navigationItemsPrefixMatch2.ts @@ -1,32 +1,32 @@ -/// -// @Filename: navigationItemsContainsNoAnonymousFunctions_0.ts -/////*file1*/ -////module Shapes { -//// export class Point { -//// private originality = 0.0; -//// private distanceFromOrig = 0.0; -//// get distanceFarFarAway(distanceFarFarAwayParam: number): number { -//// var distanceFarFarAwayLocal; -//// return 0; -//// } -//// } -////} -////var pointsSquareBox = new Shapes.Point(); -////function PointsFunc(): void { -//// var pointFuncLocal; -////} -////interface OriginI { -//// var 123; -//// var origin1; -//// public _distance(distanceParam): void; -////} - -var notFoundSearchValue = "mPointThatIJustInitiated wrongKeyWord"; - -goTo.marker("file1"); -verify.navigationItemsListCount(3, "origin", "prefix"); -verify.navigationItemsListCount(3, "distance", "prefix"); - -verify.navigationItemsListCount(0, notFoundSearchValue, "exact"); -verify.navigationItemsListCount(0, notFoundSearchValue, "prefix"); +/// +// @Filename: navigationItemsContainsNoAnonymousFunctions_0.ts +/////*file1*/ +////module Shapes { +//// export class Point { +//// private originality = 0.0; +//// private distanceFromOrig = 0.0; +//// get distanceFarFarAway(distanceFarFarAwayParam: number): number { +//// var distanceFarFarAwayLocal; +//// return 0; +//// } +//// } +////} +////var pointsSquareBox = new Shapes.Point(); +////function PointsFunc(): void { +//// var pointFuncLocal; +////} +////interface OriginI { +//// var 123; +//// var origin1; +//// public _distance(distanceParam): void; +////} + +var notFoundSearchValue = "mPointThatIJustInitiated wrongKeyWord"; + +goTo.marker("file1"); +verify.navigationItemsListCount(3, "origin", "prefix"); +verify.navigationItemsListCount(3, "distance", "prefix"); + +verify.navigationItemsListCount(0, notFoundSearchValue, "exact"); +verify.navigationItemsListCount(0, notFoundSearchValue, "prefix"); verify.navigationItemsListCount(0, notFoundSearchValue, "substring"); \ No newline at end of file diff --git a/tests/cases/fourslash/navigationItemsSubStringMatch.ts b/tests/cases/fourslash/navigationItemsSubStringMatch.ts index b90a2a2f33e..4be74953142 100644 --- a/tests/cases/fourslash/navigationItemsSubStringMatch.ts +++ b/tests/cases/fourslash/navigationItemsSubStringMatch.ts @@ -1,26 +1,26 @@ -/// - -/////// Module -////{| "itemName": "MyShapes", "kind": "module", "parentName": "", "matchKind": "substring" |}module MyShapes { -//// -//// // Class -//// {| "itemName": "MyPoint", "kind": "class", "parentName": "MyShapes", "matchKind": "substring" |}export class MyPoint { -//// // Instance member -//// {| "itemName": "MyoriginPointAttheHorizon", "kind": "property", "parentName": "MyPoint", "matchKind": "substring"|}private MyoriginPointAttheHorizon = 0.0; -//// -//// // Getter -//// {| "itemName": "MydistanceFromOrigin", "kind": "getter", "parentName": "MyPoint", "matchKind": "substring" |}get MydistanceFromOrigin(): number { return 0; } -//// -//// } -////} -//// -////// Local variables -////{| "itemName": "MymyPointThatIJustInitiated", "kind": "var", "parentName": "", "matchKind": "substring"|}var MymyPointThatIJustInitiated = new Shapes.Point(); - -debugger; -test.markers().forEach((marker) => { - if (marker.data) { - var name = marker.data.itemName; - verify.navigationItemsListContains(name, marker.data.kind, name.substr(2), marker.data.matchKind, marker.fileName, marker.data.parentName); - } +/// + +/////// Module +////{| "itemName": "MyShapes", "kind": "module", "parentName": "", "matchKind": "substring" |}module MyShapes { +//// +//// // Class +//// {| "itemName": "MyPoint", "kind": "class", "parentName": "MyShapes", "matchKind": "substring" |}export class MyPoint { +//// // Instance member +//// {| "itemName": "MyoriginPointAttheHorizon", "kind": "property", "parentName": "MyPoint", "matchKind": "substring"|}private MyoriginPointAttheHorizon = 0.0; +//// +//// // Getter +//// {| "itemName": "MydistanceFromOrigin", "kind": "getter", "parentName": "MyPoint", "matchKind": "substring" |}get MydistanceFromOrigin(): number { return 0; } +//// +//// } +////} +//// +////// Local variables +////{| "itemName": "MymyPointThatIJustInitiated", "kind": "var", "parentName": "", "matchKind": "substring"|}var MymyPointThatIJustInitiated = new Shapes.Point(); + +debugger; +test.markers().forEach((marker) => { + if (marker.data) { + var name = marker.data.itemName; + verify.navigationItemsListContains(name, marker.data.kind, name.substr(2), marker.data.matchKind, marker.fileName, marker.data.parentName); + } }); \ No newline at end of file diff --git a/tests/cases/fourslash/navigationItemsSubStringMatch2.ts b/tests/cases/fourslash/navigationItemsSubStringMatch2.ts index edce5ad761d..7ea901c9de3 100644 --- a/tests/cases/fourslash/navigationItemsSubStringMatch2.ts +++ b/tests/cases/fourslash/navigationItemsSubStringMatch2.ts @@ -1,36 +1,36 @@ -/// -// @Filename: navigationItemsContainsNoAnonymousFunctions_0.ts -/////*file1*/ -////module Shapes { -//// export class Point { -//// private originPointAttheHorizon = 0.0; -//// -//// get distanceFromOrigin(distanceParam): number { -//// var distanceLocal; -//// return 0; -//// } -//// } -////} -//// -////var myPointThatIJustInitiated = new Shapes.Point(); -////interface IDistance{ -//// INITIATED123; -//// public horizon(): void; -////} -debugger; -var notFoundSearchValue = "mPointThatIJustInitiated wrongKeyWord"; - -goTo.marker("file1"); -// case sensitive matching for 'Horizon' will fail -verify.navigationItemsListCount(1, "Horizon", "exact"); -// case insensitive matching will find 'horizon' -verify.navigationItemsListCount(1, "horizon", "exact"); -// case sensitive matching will find 'Distance' and INITIATED -verify.navigationItemsListCount(1, "Distance", "substring"); -// case sensitive matching will find 'INITIATED' -verify.navigationItemsListCount(1, "INITIATED", "prefix"); - - -verify.navigationItemsListCount(0, notFoundSearchValue, "exact"); -verify.navigationItemsListCount(0, notFoundSearchValue, "prefix"); +/// +// @Filename: navigationItemsContainsNoAnonymousFunctions_0.ts +/////*file1*/ +////module Shapes { +//// export class Point { +//// private originPointAttheHorizon = 0.0; +//// +//// get distanceFromOrigin(distanceParam): number { +//// var distanceLocal; +//// return 0; +//// } +//// } +////} +//// +////var myPointThatIJustInitiated = new Shapes.Point(); +////interface IDistance{ +//// INITIATED123; +//// public horizon(): void; +////} +debugger; +var notFoundSearchValue = "mPointThatIJustInitiated wrongKeyWord"; + +goTo.marker("file1"); +// case sensitive matching for 'Horizon' will fail +verify.navigationItemsListCount(1, "Horizon", "exact"); +// case insensitive matching will find 'horizon' +verify.navigationItemsListCount(1, "horizon", "exact"); +// case sensitive matching will find 'Distance' and INITIATED +verify.navigationItemsListCount(1, "Distance", "substring"); +// case sensitive matching will find 'INITIATED' +verify.navigationItemsListCount(1, "INITIATED", "prefix"); + + +verify.navigationItemsListCount(0, notFoundSearchValue, "exact"); +verify.navigationItemsListCount(0, notFoundSearchValue, "prefix"); verify.navigationItemsListCount(0, notFoundSearchValue, "substring"); \ No newline at end of file diff --git a/tests/cases/fourslash/noCompletionListOnCommentsInsideObjectLiterals.ts b/tests/cases/fourslash/noCompletionListOnCommentsInsideObjectLiterals.ts index 15affd3b61e..38f9133149e 100644 --- a/tests/cases/fourslash/noCompletionListOnCommentsInsideObjectLiterals.ts +++ b/tests/cases/fourslash/noCompletionListOnCommentsInsideObjectLiterals.ts @@ -1,18 +1,18 @@ -/// - -////module ObjectLiterals { -//// interface MyPoint { -//// x1: number; -//// y1: number; -//// } -//// -//// var p1: MyPoint = { -//// /* /*1*/ Comment /*2*/ */ -//// }; -////} - -goTo.marker("1"); -verify.completionListIsEmpty(); - -goTo.marker("2"); +/// + +////module ObjectLiterals { +//// interface MyPoint { +//// x1: number; +//// y1: number; +//// } +//// +//// var p1: MyPoint = { +//// /* /*1*/ Comment /*2*/ */ +//// }; +////} + +goTo.marker("1"); +verify.completionListIsEmpty(); + +goTo.marker("2"); verify.completionListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/noSignatureHelpOnNewKeyword.ts b/tests/cases/fourslash/noSignatureHelpOnNewKeyword.ts index 30314b1c665..8dc942f2758 100644 --- a/tests/cases/fourslash/noSignatureHelpOnNewKeyword.ts +++ b/tests/cases/fourslash/noSignatureHelpOnNewKeyword.ts @@ -1,4 +1,4 @@ -/// +/// ////class Foo { } ////new/*1*/ Foo diff --git a/tests/cases/fourslash/noSmartIndentInsideMultilineString.ts b/tests/cases/fourslash/noSmartIndentInsideMultilineString.ts index 692dfe70758..06c0fb6e44a 100644 --- a/tests/cases/fourslash/noSmartIndentInsideMultilineString.ts +++ b/tests/cases/fourslash/noSmartIndentInsideMultilineString.ts @@ -1,11 +1,11 @@ -/// - -////window.onload = () => { -//// var el = document.getElementById('content\/*1*/'); -//// var greeter = new Greeter(el); -////greeter.start(); -////}; - -goTo.marker("1"); -edit.insert("\r\n"); +/// + +////window.onload = () => { +//// var el = document.getElementById('content\/*1*/'); +//// var greeter = new Greeter(el); +////greeter.start(); +////}; + +goTo.marker("1"); +edit.insert("\r\n"); verify.indentationIs(0); \ No newline at end of file diff --git a/tests/cases/fourslash/overloadObjectLiteralCrash.ts b/tests/cases/fourslash/overloadObjectLiteralCrash.ts index 91f081a54fe..f98469443bb 100644 --- a/tests/cases/fourslash/overloadObjectLiteralCrash.ts +++ b/tests/cases/fourslash/overloadObjectLiteralCrash.ts @@ -1,12 +1,12 @@ -/// - -//// interface Foo { -//// extend(...objs: any[]): T; -//// extend(deep, target: T): T; -//// } -//// var $: Foo; -//// $.extend({ /**/foo: 0 }, ""); -//// - -goTo.marker(); -verify.quickInfoExists(); +/// + +//// interface Foo { +//// extend(...objs: any[]): T; +//// extend(deep, target: T): T; +//// } +//// var $: Foo; +//// $.extend({ /**/foo: 0 }, ""); +//// + +goTo.marker(); +verify.quickInfoExists(); diff --git a/tests/cases/fourslash/parenthesisFatArrows.ts b/tests/cases/fourslash/parenthesisFatArrows.ts index e4bdc2c1f97..1751e50afc8 100644 --- a/tests/cases/fourslash/parenthesisFatArrows.ts +++ b/tests/cases/fourslash/parenthesisFatArrows.ts @@ -1,11 +1,11 @@ -/// - -////x => x; -////(y) => y; -/////**/ -////(y) => y; -////x => x; - -verify.numberOfErrorsInCurrentFile(0); -verify.not.errorExistsBeforeMarker(); +/// + +////x => x; +////(y) => y; +/////**/ +////(y) => y; +////x => x; + +verify.numberOfErrorsInCurrentFile(0); +verify.not.errorExistsBeforeMarker(); verify.not.errorExistsAfterMarker(); \ No newline at end of file diff --git a/tests/cases/fourslash/publicBreak.ts b/tests/cases/fourslash/publicBreak.ts index 630e5714a40..26407184b48 100644 --- a/tests/cases/fourslash/publicBreak.ts +++ b/tests/cases/fourslash/publicBreak.ts @@ -1,7 +1,7 @@ -/// - -//// public break; -//// /**/ - -goTo.marker(); -edit.insert(' '); +/// + +//// public break; +//// /**/ + +goTo.marker(); +edit.insert(' '); diff --git a/tests/cases/fourslash/qualifiedName_import-declaration-with-variable-entity-names.ts b/tests/cases/fourslash/qualifiedName_import-declaration-with-variable-entity-names.ts index fa57a17f98a..b6f64e4be42 100644 --- a/tests/cases/fourslash/qualifiedName_import-declaration-with-variable-entity-names.ts +++ b/tests/cases/fourslash/qualifiedName_import-declaration-with-variable-entity-names.ts @@ -1,5 +1,5 @@ -/// - +/// + ////module Alpha { //// export var [|{| "name" : "def" |}x|] = 100; ////} @@ -7,20 +7,20 @@ ////module Beta { //// import p = Alpha.[|{| "name" : "import" |}x|]; ////} -//// -////var x = Alpha.[|{| "name" : "mem" |}x|] - -goTo.marker('import'); -verify.completionListContains('x', '(var) Alpha.x: number'); +//// +////var x = Alpha.[|{| "name" : "mem" |}x|] + +goTo.marker('import'); +verify.completionListContains('x', '(var) Alpha.x: number'); var def: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "def")[0]; -var imp: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "import")[0]; -var mem: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "mem")[0]; - +var imp: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "import")[0]; +var mem: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "mem")[0]; + verify.occurrencesAtPositionContains(def); -verify.occurrencesAtPositionContains(imp); -verify.occurrencesAtPositionContains(mem); - -goTo.definition(); - +verify.occurrencesAtPositionContains(imp); +verify.occurrencesAtPositionContains(mem); + +goTo.definition(); + verify.caretAtMarker('def'); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoForContextuallyTypedArrowFunctionInSuperCall.ts b/tests/cases/fourslash/quickInfoForContextuallyTypedArrowFunctionInSuperCall.ts index e24a484979a..51eb59378a9 100644 --- a/tests/cases/fourslash/quickInfoForContextuallyTypedArrowFunctionInSuperCall.ts +++ b/tests/cases/fourslash/quickInfoForContextuallyTypedArrowFunctionInSuperCall.ts @@ -1,4 +1,4 @@ -/// +/// ////class A { //// constructor(private map: (value: T1) => T2) { diff --git a/tests/cases/fourslash/quickInfoForShorthandProperty.ts b/tests/cases/fourslash/quickInfoForShorthandProperty.ts index 21ba9db683d..d4b30b0d736 100644 --- a/tests/cases/fourslash/quickInfoForShorthandProperty.ts +++ b/tests/cases/fourslash/quickInfoForShorthandProperty.ts @@ -1,4 +1,4 @@ -/// +/// //// var name1 = undefined, id1 = undefined; //// var /*obj1*/obj1 = {/*name1*/name1, /*id1*/id1}; diff --git a/tests/cases/fourslash/quickInfoInInvalidIndexSignature.ts b/tests/cases/fourslash/quickInfoInInvalidIndexSignature.ts index b08fb92b8b6..0aa634d0896 100644 --- a/tests/cases/fourslash/quickInfoInInvalidIndexSignature.ts +++ b/tests/cases/fourslash/quickInfoInInvalidIndexSignature.ts @@ -1,6 +1,6 @@ -/// - -//// function method() { var /**/dictionary = <{ [index]: string; }>{}; } - -goTo.marker(); -verify.quickInfoIs('(local var) dictionary: {}'); +/// + +//// function method() { var /**/dictionary = <{ [index]: string; }>{}; } + +goTo.marker(); +verify.quickInfoIs('(local var) dictionary: {}'); diff --git a/tests/cases/fourslash/quickInfoOfLablledForStatementIterator.ts b/tests/cases/fourslash/quickInfoOfLablledForStatementIterator.ts index d1fd6994f77..5091dd0c1c3 100644 --- a/tests/cases/fourslash/quickInfoOfLablledForStatementIterator.ts +++ b/tests/cases/fourslash/quickInfoOfLablledForStatementIterator.ts @@ -1,6 +1,6 @@ -/// - -//// label1: for(var /**/i = 0; i < 1; i++) { } - -goTo.marker(); +/// + +//// label1: for(var /**/i = 0; i < 1; i++) { } + +goTo.marker(); verify.quickInfoExists(); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoOnCatchVariable.ts b/tests/cases/fourslash/quickInfoOnCatchVariable.ts index 5d0af595e91..1ca0aa670d3 100644 --- a/tests/cases/fourslash/quickInfoOnCatchVariable.ts +++ b/tests/cases/fourslash/quickInfoOnCatchVariable.ts @@ -1,9 +1,9 @@ -/// - -//// function f() { -//// try { } catch (/**/e) { } -//// } - -goTo.marker(); -verify.quickInfoExists(); -verify.quickInfoIs("(local var) e: any"); +/// + +//// function f() { +//// try { } catch (/**/e) { } +//// } + +goTo.marker(); +verify.quickInfoExists(); +verify.quickInfoIs("(local var) e: any"); diff --git a/tests/cases/fourslash/recursiveGenerics2.ts b/tests/cases/fourslash/recursiveGenerics2.ts index 6db5e03fc3a..171bc310691 100644 --- a/tests/cases/fourslash/recursiveGenerics2.ts +++ b/tests/cases/fourslash/recursiveGenerics2.ts @@ -1,5 +1,5 @@ -/// - +/// + //// class S18 extends S18 { } //// /**/ diff --git a/tests/cases/fourslash/recursiveInternalModuleImport.ts b/tests/cases/fourslash/recursiveInternalModuleImport.ts index 3f377cb5795..afd94a1de27 100644 --- a/tests/cases/fourslash/recursiveInternalModuleImport.ts +++ b/tests/cases/fourslash/recursiveInternalModuleImport.ts @@ -1,11 +1,11 @@ -/// - -//// module M { -//// import A = B; -//// import /**/B = A; -//// } -//// - -goTo.marker(); -verify.quickInfoExists(); - +/// + +//// module M { +//// import A = B; +//// import /**/B = A; +//// } +//// + +goTo.marker(); +verify.quickInfoExists(); + diff --git a/tests/cases/fourslash/referenceToClass.ts b/tests/cases/fourslash/referenceToClass.ts index 2dd0bdc3e7e..2907a468577 100644 --- a/tests/cases/fourslash/referenceToClass.ts +++ b/tests/cases/fourslash/referenceToClass.ts @@ -1,36 +1,36 @@ -/// - -// Class references should work across file and not find local variables. - -// @Filename: referenceToClass_1.ts -////class /*1*/foo { -//// public n: /*2*/foo; -//// public foo: number; -////} -//// -////class bar { -//// public n: fo/*3*/o; -//// public k = new foo(); -////} -//// -////module mod { -//// var k: foo = null; -////} - -// @Filename: referenceToClass_2.ts -////var k: /*4*/foo; - -goTo.marker("1"); -verify.referencesCountIs(6); - -goTo.marker("2"); - -verify.referencesCountIs(6); - -goTo.marker("3"); - -verify.referencesCountIs(6); - -goTo.marker("4"); - +/// + +// Class references should work across file and not find local variables. + +// @Filename: referenceToClass_1.ts +////class /*1*/foo { +//// public n: /*2*/foo; +//// public foo: number; +////} +//// +////class bar { +//// public n: fo/*3*/o; +//// public k = new foo(); +////} +//// +////module mod { +//// var k: foo = null; +////} + +// @Filename: referenceToClass_2.ts +////var k: /*4*/foo; + +goTo.marker("1"); +verify.referencesCountIs(6); + +goTo.marker("2"); + +verify.referencesCountIs(6); + +goTo.marker("3"); + +verify.referencesCountIs(6); + +goTo.marker("4"); + verify.referencesCountIs(6); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesBloomFilters.ts b/tests/cases/fourslash/referencesBloomFilters.ts index ea7dcfaaf07..3961d557e89 100644 --- a/tests/cases/fourslash/referencesBloomFilters.ts +++ b/tests/cases/fourslash/referencesBloomFilters.ts @@ -1,20 +1,20 @@ -/// - -// Ensure BloomFilter building logic is correct, by having one reference per file - -// @Filename: declaration.ts -////var container = { /*1*/searchProp : 1 }; - -// @Filename: expression.ts -////function blah() { return (1 + 2 + container./*2*/searchProp()) === 2; }; - -// @Filename: stringIndexer.ts -////function blah2() { container[/*3*/"searchProp"] }; - -// @Filename: redeclaration.ts -////container = { /*4*/"searchProp" : 18 }; - -test.markers().forEach(m => { - goTo.position(m.position, m.fileName); - verify.referencesCountIs(4); +/// + +// Ensure BloomFilter building logic is correct, by having one reference per file + +// @Filename: declaration.ts +////var container = { /*1*/searchProp : 1 }; + +// @Filename: expression.ts +////function blah() { return (1 + 2 + container./*2*/searchProp()) === 2; }; + +// @Filename: stringIndexer.ts +////function blah2() { container[/*3*/"searchProp"] }; + +// @Filename: redeclaration.ts +////container = { /*4*/"searchProp" : 18 }; + +test.markers().forEach(m => { + goTo.position(m.position, m.fileName); + verify.referencesCountIs(4); }); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesBloomFilters2.ts b/tests/cases/fourslash/referencesBloomFilters2.ts index 7599e2fe96f..ef7643e0215 100644 --- a/tests/cases/fourslash/referencesBloomFilters2.ts +++ b/tests/cases/fourslash/referencesBloomFilters2.ts @@ -1,20 +1,20 @@ -/// - -// Ensure BloomFilter building logic is correct, by having one reference per file - -// @Filename: declaration.ts -////var container = { /*1*/42 : 1 }; - -// @Filename: expression.ts -////function blah() { return (container[/*2*/42]) === 2; }; - -// @Filename: stringIndexer.ts -////function blah2() { container[/*3*/"42"] }; - -// @Filename: redeclaration.ts -////container = { /*4*/"42" : 18 }; - -test.markers().forEach(m => { - goTo.position(m.position, m.fileName); - verify.referencesCountIs(4); +/// + +// Ensure BloomFilter building logic is correct, by having one reference per file + +// @Filename: declaration.ts +////var container = { /*1*/42 : 1 }; + +// @Filename: expression.ts +////function blah() { return (container[/*2*/42]) === 2; }; + +// @Filename: stringIndexer.ts +////function blah2() { container[/*3*/"42"] }; + +// @Filename: redeclaration.ts +////container = { /*4*/"42" : 18 }; + +test.markers().forEach(m => { + goTo.position(m.position, m.fileName); + verify.referencesCountIs(4); }); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesBloomFilters3.ts b/tests/cases/fourslash/referencesBloomFilters3.ts index 7056bab2393..65215469950 100644 --- a/tests/cases/fourslash/referencesBloomFilters3.ts +++ b/tests/cases/fourslash/referencesBloomFilters3.ts @@ -1,16 +1,16 @@ -/// - -// Ensure BloomFilter building logic is correct, by having one reference per file - - -// @Filename: declaration.ts -////enum Test { /*1*/"42" = 1 }; - -// @Filename: expression.ts -////(Test[/*2*/42]); - - -test.markers().forEach(m => { - goTo.position(m.position, m.fileName); - verify.referencesCountIs(2); +/// + +// Ensure BloomFilter building logic is correct, by having one reference per file + + +// @Filename: declaration.ts +////enum Test { /*1*/"42" = 1 }; + +// @Filename: expression.ts +////(Test[/*2*/42]); + + +test.markers().forEach(m => { + goTo.position(m.position, m.fileName); + verify.referencesCountIs(2); }); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForClassParameter.ts b/tests/cases/fourslash/referencesForClassParameter.ts index 2d0bdf9f9cd..48cdbbf1e41 100644 --- a/tests/cases/fourslash/referencesForClassParameter.ts +++ b/tests/cases/fourslash/referencesForClassParameter.ts @@ -1,26 +1,26 @@ -/// - -// Reference to a class parameter. - -////var p = 2; -//// -////class p { } -//// -////class foo { -//// constructor (public p: any) { -//// } -//// -//// public f(p) { -//// this./*1*/p = p; -//// } -//// -////} -//// -////var n = new foo(undefined); -////n./*2*/p = null; - -goTo.marker("1"); -verify.referencesCountIs(3); - -goTo.marker("2"); +/// + +// Reference to a class parameter. + +////var p = 2; +//// +////class p { } +//// +////class foo { +//// constructor (public p: any) { +//// } +//// +//// public f(p) { +//// this./*1*/p = p; +//// } +//// +////} +//// +////var n = new foo(undefined); +////n./*2*/p = null; + +goTo.marker("1"); +verify.referencesCountIs(3); + +goTo.marker("2"); verify.referencesCountIs(3); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForFunctionOverloads.ts b/tests/cases/fourslash/referencesForFunctionOverloads.ts index f27dd8e8461..2a4981ff4a3 100644 --- a/tests/cases/fourslash/referencesForFunctionOverloads.ts +++ b/tests/cases/fourslash/referencesForFunctionOverloads.ts @@ -1,17 +1,17 @@ -/// - -// Function overloads should be highlighted together. - -////function /*1*/foo(x: string); -////function /*2*/foo(x: string, y: number) { -//// /*3*/foo('', 43); -////} - -goTo.marker("1"); -verify.referencesCountIs(3); - -goTo.marker("2"); -verify.referencesCountIs(3); - -goTo.marker("3"); +/// + +// Function overloads should be highlighted together. + +////function /*1*/foo(x: string); +////function /*2*/foo(x: string, y: number) { +//// /*3*/foo('', 43); +////} + +goTo.marker("1"); +verify.referencesCountIs(3); + +goTo.marker("2"); +verify.referencesCountIs(3); + +goTo.marker("3"); verify.referencesCountIs(3); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForFunctionParameter.ts b/tests/cases/fourslash/referencesForFunctionParameter.ts index b8ffc5f639a..fd9189d1b72 100644 --- a/tests/cases/fourslash/referencesForFunctionParameter.ts +++ b/tests/cases/fourslash/referencesForFunctionParameter.ts @@ -1,15 +1,15 @@ -/// - -////var x; -////var n; -//// -////function n(x: number, /*1*/n: number) { -//// /*2*/n = 32; -//// x = n; -////} - -goTo.marker("1"); -verify.referencesCountIs(3); - -goTo.marker("2"); +/// + +////var x; +////var n; +//// +////function n(x: number, /*1*/n: number) { +//// /*2*/n = 32; +//// x = n; +////} + +goTo.marker("1"); +verify.referencesCountIs(3); + +goTo.marker("2"); verify.referencesCountIs(3); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts b/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts index 4afaedf93e8..b76007624bb 100644 --- a/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts +++ b/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts @@ -1,24 +1,24 @@ -/// - -// Global variable reference. - -////var /*1*/topLevelVar = 2; -////var topLevelVar2 = topLevelVar; -//// -////class /*2*/topLevelClass { } -////var c = new topLevelClass(); -//// -////interface topLevelInterface { } -////var i: /*3*/topLevelInterface; -//// -////module topLevelModule { -//// export var x; -////} -////var x = /*4*/topLevelModule.x; -//// -////export = x; - -test.markers().forEach(m => { - goTo.position(m.position, m.fileName); - verify.referencesCountIs(2); +/// + +// Global variable reference. + +////var /*1*/topLevelVar = 2; +////var topLevelVar2 = topLevelVar; +//// +////class /*2*/topLevelClass { } +////var c = new topLevelClass(); +//// +////interface topLevelInterface { } +////var i: /*3*/topLevelInterface; +//// +////module topLevelModule { +//// export var x; +////} +////var x = /*4*/topLevelModule.x; +//// +////export = x; + +test.markers().forEach(m => { + goTo.position(m.position, m.fileName); + verify.referencesCountIs(2); }); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForIllegalAssignment.ts b/tests/cases/fourslash/referencesForIllegalAssignment.ts index 6c7d228d3e7..81a45f64153 100644 --- a/tests/cases/fourslash/referencesForIllegalAssignment.ts +++ b/tests/cases/fourslash/referencesForIllegalAssignment.ts @@ -1,21 +1,21 @@ -/// - -////f/*1*/oo = fo/*2*/o; - -////var /*3*/bar = function () { }; -////ba/*4*/r = b/*5*/ar + 1; - -goTo.marker("1"); -verify.referencesCountIs(1); - -goTo.marker("2"); -verify.referencesCountIs(1); - -goTo.marker("3"); -verify.referencesCountIs(3); - -goTo.marker("4"); -verify.referencesCountIs(3); - -goTo.marker("5"); +/// + +////f/*1*/oo = fo/*2*/o; + +////var /*3*/bar = function () { }; +////ba/*4*/r = b/*5*/ar + 1; + +goTo.marker("1"); +verify.referencesCountIs(1); + +goTo.marker("2"); +verify.referencesCountIs(1); + +goTo.marker("3"); +verify.referencesCountIs(3); + +goTo.marker("4"); +verify.referencesCountIs(3); + +goTo.marker("5"); verify.referencesCountIs(3); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForIndexProperty.ts b/tests/cases/fourslash/referencesForIndexProperty.ts index 96ae1ff05e3..89084a2ef05 100644 --- a/tests/cases/fourslash/referencesForIndexProperty.ts +++ b/tests/cases/fourslash/referencesForIndexProperty.ts @@ -1,18 +1,18 @@ -/// - -// References a class property using string index access - -////class Foo { -//// property: number; -//// method(): void { } -////} -//// -////var f: Foo; -////f[/*1*/"property"]; -////f[/*2*/"method"]; - -goTo.marker("1"); -verify.referencesCountIs(2); - -goTo.marker("2"); -verify.referencesCountIs(2); +/// + +// References a class property using string index access + +////class Foo { +//// property: number; +//// method(): void { } +////} +//// +////var f: Foo; +////f[/*1*/"property"]; +////f[/*2*/"method"]; + +goTo.marker("1"); +verify.referencesCountIs(2); + +goTo.marker("2"); +verify.referencesCountIs(2); diff --git a/tests/cases/fourslash/referencesForIndexProperty2.ts b/tests/cases/fourslash/referencesForIndexProperty2.ts index a84adf672a1..fd9cf0e7183 100644 --- a/tests/cases/fourslash/referencesForIndexProperty2.ts +++ b/tests/cases/fourslash/referencesForIndexProperty2.ts @@ -1,9 +1,9 @@ -/// - -// References to a unknown index property - -////var a; -////a[/*1*/"blah"]; - -goTo.marker("1"); +/// + +// References to a unknown index property + +////var a; +////a[/*1*/"blah"]; + +goTo.marker("1"); verify.referencesCountIs(1); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForIndexProperty3.ts b/tests/cases/fourslash/referencesForIndexProperty3.ts index 72a2b560b4f..07081f8c17d 100644 --- a/tests/cases/fourslash/referencesForIndexProperty3.ts +++ b/tests/cases/fourslash/referencesForIndexProperty3.ts @@ -1,19 +1,19 @@ -/// - -// References to a property of the apparent type using string indexer - -////interface Object { -//// toMyString(); -////} -//// -////var y: Object; -////y./*1*/toMyString(); -//// -////var x = {}; -////x[/*2*/"toMyString"](); - -goTo.marker("1"); -verify.referencesCountIs(3); - -goTo.marker("2"); -verify.referencesCountIs(3); +/// + +// References to a property of the apparent type using string indexer + +////interface Object { +//// toMyString(); +////} +//// +////var y: Object; +////y./*1*/toMyString(); +//// +////var x = {}; +////x[/*2*/"toMyString"](); + +goTo.marker("1"); +verify.referencesCountIs(3); + +goTo.marker("2"); +verify.referencesCountIs(3); diff --git a/tests/cases/fourslash/referencesForLabel.ts b/tests/cases/fourslash/referencesForLabel.ts index ee5df8049c0..f79e038ca0a 100644 --- a/tests/cases/fourslash/referencesForLabel.ts +++ b/tests/cases/fourslash/referencesForLabel.ts @@ -1,23 +1,23 @@ -/// - -// Valid References for a label - -/////*1*/label: while (true) { -//// if (false) break /*2*/label; -//// if (true) continue /*3*/label; -////} -//// -/////*4*/label: while (false) { } -////var label = "label"; - -goTo.marker("1"); -verify.referencesCountIs(3); - -goTo.marker("2"); -verify.referencesCountIs(3); - -goTo.marker("3"); -verify.referencesCountIs(3); - -goTo.marker("4"); +/// + +// Valid References for a label + +/////*1*/label: while (true) { +//// if (false) break /*2*/label; +//// if (true) continue /*3*/label; +////} +//// +/////*4*/label: while (false) { } +////var label = "label"; + +goTo.marker("1"); +verify.referencesCountIs(3); + +goTo.marker("2"); +verify.referencesCountIs(3); + +goTo.marker("3"); +verify.referencesCountIs(3); + +goTo.marker("4"); verify.referencesCountIs(1); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForLabel2.ts b/tests/cases/fourslash/referencesForLabel2.ts index 96467158cca..054ce562864 100644 --- a/tests/cases/fourslash/referencesForLabel2.ts +++ b/tests/cases/fourslash/referencesForLabel2.ts @@ -1,12 +1,12 @@ -/// - -// References to undefined label - -////var label = "label"; -////while (true) { -//// if (false) break /*1*/label; -//// if (true) continue label; -////} - -goTo.marker("1"); -verify.referencesCountIs(1); +/// + +// References to undefined label + +////var label = "label"; +////while (true) { +//// if (false) break /*1*/label; +//// if (true) continue label; +////} + +goTo.marker("1"); +verify.referencesCountIs(1); diff --git a/tests/cases/fourslash/referencesForLabel3.ts b/tests/cases/fourslash/referencesForLabel3.ts index 5a4c3893211..9c621909c34 100644 --- a/tests/cases/fourslash/referencesForLabel3.ts +++ b/tests/cases/fourslash/referencesForLabel3.ts @@ -1,10 +1,10 @@ -/// - -// References to unused label - -/////*1*/label: while (true) { -//// var label = "label"; -////} - -goTo.marker("1"); -verify.referencesCountIs(1); +/// + +// References to unused label + +/////*1*/label: while (true) { +//// var label = "label"; +////} + +goTo.marker("1"); +verify.referencesCountIs(1); diff --git a/tests/cases/fourslash/referencesForLabel4.ts b/tests/cases/fourslash/referencesForLabel4.ts index 4288046ecec..d9817b2d857 100644 --- a/tests/cases/fourslash/referencesForLabel4.ts +++ b/tests/cases/fourslash/referencesForLabel4.ts @@ -1,15 +1,15 @@ -/// - -// References to a label outside function bounderies - -/////*1*/label: function foo(label) { -//// while (true) { -//// break /*2*/label; -//// } -////} - -goTo.marker("1"); -verify.referencesCountIs(2); - -goTo.marker("2"); -verify.referencesCountIs(2); +/// + +// References to a label outside function bounderies + +/////*1*/label: function foo(label) { +//// while (true) { +//// break /*2*/label; +//// } +////} + +goTo.marker("1"); +verify.referencesCountIs(2); + +goTo.marker("2"); +verify.referencesCountIs(2); diff --git a/tests/cases/fourslash/referencesForLabel5.ts b/tests/cases/fourslash/referencesForLabel5.ts index 0a465a89f2f..dba59ec79ab 100644 --- a/tests/cases/fourslash/referencesForLabel5.ts +++ b/tests/cases/fourslash/referencesForLabel5.ts @@ -1,28 +1,28 @@ -/// - -// References to shadowed label - -/////*outer1*/label: while (true) { -//// if (false) break /*outer2*/label; -//// function blah() { -/////*inner1*/label: while (true) { -//// if (false) break /*inner2*/label; -//// } -//// } -//// if (false) break /*outer3*/label; -//// } - -goTo.marker("outer1"); -verify.referencesCountIs(3); - -goTo.marker("outer2"); -verify.referencesCountIs(3); - -goTo.marker("outer3"); -verify.referencesCountIs(3); - -goTo.marker("inner1"); -verify.referencesCountIs(2); - -goTo.marker("inner2"); -verify.referencesCountIs(2); +/// + +// References to shadowed label + +/////*outer1*/label: while (true) { +//// if (false) break /*outer2*/label; +//// function blah() { +/////*inner1*/label: while (true) { +//// if (false) break /*inner2*/label; +//// } +//// } +//// if (false) break /*outer3*/label; +//// } + +goTo.marker("outer1"); +verify.referencesCountIs(3); + +goTo.marker("outer2"); +verify.referencesCountIs(3); + +goTo.marker("outer3"); +verify.referencesCountIs(3); + +goTo.marker("inner1"); +verify.referencesCountIs(2); + +goTo.marker("inner2"); +verify.referencesCountIs(2); diff --git a/tests/cases/fourslash/referencesForLabel6.ts b/tests/cases/fourslash/referencesForLabel6.ts index 83c3c8a2fc1..a9aab59c467 100644 --- a/tests/cases/fourslash/referencesForLabel6.ts +++ b/tests/cases/fourslash/referencesForLabel6.ts @@ -1,14 +1,14 @@ -/// - -// References to lable wiht close names - -/////*1*/labela: while (true) { -/////*2*/labelb: while (false) { break labelb; } -//// break labelc; -////} - -goTo.marker("1"); -verify.referencesCountIs(1); - -goTo.marker("2"); +/// + +// References to lable wiht close names + +/////*1*/labela: while (true) { +/////*2*/labelb: while (false) { break labelb; } +//// break labelc; +////} + +goTo.marker("1"); +verify.referencesCountIs(1); + +goTo.marker("2"); verify.referencesCountIs(2); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForMergedDeclarations.ts b/tests/cases/fourslash/referencesForMergedDeclarations.ts index 51ad4ea8ce8..a475780b66e 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations.ts @@ -1,5 +1,5 @@ -/// - +/// + ////interface /*type1*/Foo { ////} //// @@ -12,10 +12,10 @@ //// ////var f1: /*namespace2*/Foo.Bar; ////var f2: /*type2*/Foo; -/////*value2*/Foo.bind(this); - - -test.markers().forEach(m => { - goTo.position(m.position, m.fileName); - verify.referencesCountIs(2); -}); +/////*value2*/Foo.bind(this); + + +test.markers().forEach(m => { + goTo.position(m.position, m.fileName); + verify.referencesCountIs(2); +}); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations3.ts b/tests/cases/fourslash/referencesForMergedDeclarations3.ts index c673f89179e..80cf1fb9e42 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations3.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations3.ts @@ -1,4 +1,4 @@ -/// +/// // class and uninstanciated module @@ -18,22 +18,22 @@ /////*class2*/testClass.staticMethod(); /////*class3*/testClass.prototype.method(); /////*class4*/testClass.bind(this); -////new /*class5*/testClass(); - -goTo.marker("module"); -verify.referencesCountIs(2); - -goTo.marker("class1"); -verify.referencesCountIs(6); - -goTo.marker("class2"); -verify.referencesCountIs(6); - -goTo.marker("class3"); -verify.referencesCountIs(6); - -goTo.marker("class4"); -verify.referencesCountIs(6); - -goTo.marker("class5"); +////new /*class5*/testClass(); + +goTo.marker("module"); +verify.referencesCountIs(2); + +goTo.marker("class1"); +verify.referencesCountIs(6); + +goTo.marker("class2"); +verify.referencesCountIs(6); + +goTo.marker("class3"); +verify.referencesCountIs(6); + +goTo.marker("class4"); +verify.referencesCountIs(6); + +goTo.marker("class5"); verify.referencesCountIs(6); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForMergedDeclarations4.ts b/tests/cases/fourslash/referencesForMergedDeclarations4.ts index 18386594631..88faf672fcc 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations4.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations4.ts @@ -1,4 +1,4 @@ -/// +/// // class and instanciated module @@ -20,10 +20,10 @@ /////*4*/testClass.prototype.method(); /////*5*/testClass.bind(this); /////*6*/testClass.s; -////new /*7*/testClass(); - -// Instanciated Module and class intersect in the value space, so we consider them all one group -test.markers().forEach(m => { - goTo.position(m.position, m.fileName); - verify.referencesCountIs(9); -}); +////new /*7*/testClass(); + +// Instanciated Module and class intersect in the value space, so we consider them all one group +test.markers().forEach(m => { + goTo.position(m.position, m.fileName); + verify.referencesCountIs(9); +}); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations5.ts b/tests/cases/fourslash/referencesForMergedDeclarations5.ts index cf4ddea31d7..deb7ad321c9 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations5.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations5.ts @@ -1,10 +1,10 @@ -/// - -////interface Foo { } -////module Foo { export interface Bar { } } -////function Foo() { } -//// -////export = /*1*/Foo; - -goTo.marker("1"); +/// + +////interface Foo { } +////module Foo { export interface Bar { } } +////function Foo() { } +//// +////export = /*1*/Foo; + +goTo.marker("1"); verify.referencesCountIs(4); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForMergedDeclarations7.ts b/tests/cases/fourslash/referencesForMergedDeclarations7.ts index 7a86362907c..1c6d730797f 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations7.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations7.ts @@ -1,14 +1,14 @@ -/// - -////interface Foo { } -////module Foo { +/// + +////interface Foo { } +////module Foo { //// export interface Bar { } //// export module Bar { export interface Baz { } } //// export function Bar() { } -////} -//// -////// module, value and type -////import a2 = Foo./*1*/Bar; - -goTo.marker("1"); +////} +//// +////// module, value and type +////import a2 = Foo./*1*/Bar; + +goTo.marker("1"); verify.referencesCountIs(4); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForNoContext.ts b/tests/cases/fourslash/referencesForNoContext.ts index 4fe0753da6f..ee9391e5416 100644 --- a/tests/cases/fourslash/referencesForNoContext.ts +++ b/tests/cases/fourslash/referencesForNoContext.ts @@ -1,34 +1,34 @@ -/// - -////module modTest { -//// //Declare -//// export var modVar:number; -//// /*1*/ -//// -//// //Increments -//// modVar++; -//// -//// class testCls{ -//// /*2*/ -//// } -//// -//// function testFn(){ -//// //Increments -//// modVar++; -//// } /*3*/ -/////*4*/ -//// module testMod { -//// } -////} - -goTo.marker("1"); -verify.referencesCountIs(0); - -goTo.marker("2"); -verify.referencesCountIs(0); - -goTo.marker("3"); -verify.referencesCountIs(0); - -goTo.marker("4"); -verify.referencesCountIs(0); +/// + +////module modTest { +//// //Declare +//// export var modVar:number; +//// /*1*/ +//// +//// //Increments +//// modVar++; +//// +//// class testCls{ +//// /*2*/ +//// } +//// +//// function testFn(){ +//// //Increments +//// modVar++; +//// } /*3*/ +/////*4*/ +//// module testMod { +//// } +////} + +goTo.marker("1"); +verify.referencesCountIs(0); + +goTo.marker("2"); +verify.referencesCountIs(0); + +goTo.marker("3"); +verify.referencesCountIs(0); + +goTo.marker("4"); +verify.referencesCountIs(0); diff --git a/tests/cases/fourslash/referencesForObjectLiteralProperties.ts b/tests/cases/fourslash/referencesForObjectLiteralProperties.ts index c606e2f13f3..8515a5487b7 100644 --- a/tests/cases/fourslash/referencesForObjectLiteralProperties.ts +++ b/tests/cases/fourslash/referencesForObjectLiteralProperties.ts @@ -1,15 +1,15 @@ -/// - -// References to an object literal property - +/// + +// References to an object literal property + ////var x = { /*1*/add: 0, b: "string" }; ////x["add"]; ////x./*2*/add; ////var y = x; -////y.add; - -goTo.marker("1"); -verify.referencesCountIs(4); - -goTo.marker("2"); +////y.add; + +goTo.marker("1"); +verify.referencesCountIs(4); + +goTo.marker("2"); verify.referencesCountIs(4); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForOverrides.ts b/tests/cases/fourslash/referencesForOverrides.ts index df3a6f208a0..2b67269a6f3 100644 --- a/tests/cases/fourslash/referencesForOverrides.ts +++ b/tests/cases/fourslash/referencesForOverrides.ts @@ -1,84 +1,84 @@ -/// - -////module FindRef3 { -//// module SimpleClassTest { -//// export class Foo { -//// public foo(): void { -//// } -//// } -//// export class Bar extends Foo { -//// public foo(): void { -//// } -//// } -//// } -//// -//// module SimpleInterfaceTest { -//// export interface IFoo { -//// foo(): void; -//// } -//// export interface IBar extends IFoo { -//// foo(): void; -//// } -//// } -//// -//// module SimpleClassInterfaceTest { -//// export interface IFoo { -//// foo(): void; -//// } -//// export class Bar implements IFoo { -//// public foo(): void { -//// } -//// } -//// } -//// -//// module Test { -//// export interface IBase { -//// field: string; -//// method(): void; -//// } -//// -//// export interface IBlah extends IBase { -//// field: string; -//// } -//// -//// export interface IBlah2 extends IBlah { -//// field: string; -//// } -//// -//// export interface IDerived extends IBlah2 { -//// method(): void; -//// } -//// -//// export class Bar implements IDerived { -//// public field: string; -//// public method(): void { } -//// } -//// -//// export class BarBlah extends Bar { -//// public field: string; -//// } -//// } -//// -//// function test() { -//// var x = new SimpleClassTest.Bar(); -//// x.fo/*1*/o(); -//// -//// var y: SimpleInterfaceTest.IBar = null; -//// y.fo/*2*/o(); -//// -//// var z = new Test.BarBlah(); -//// z.fi/*3*/eld = ""; -//// } -////} - -// References to a field declared in a base class. -goTo.marker("1"); -verify.referencesCountIs(3); - -// References to a field declared in a base interface. -goTo.marker("2"); -verify.referencesCountIs(3); - -// References to a field declared in a chain of base class and interfaces. -goTo.marker("3"); -verify.referencesCountIs(6); +/// + +////module FindRef3 { +//// module SimpleClassTest { +//// export class Foo { +//// public foo(): void { +//// } +//// } +//// export class Bar extends Foo { +//// public foo(): void { +//// } +//// } +//// } +//// +//// module SimpleInterfaceTest { +//// export interface IFoo { +//// foo(): void; +//// } +//// export interface IBar extends IFoo { +//// foo(): void; +//// } +//// } +//// +//// module SimpleClassInterfaceTest { +//// export interface IFoo { +//// foo(): void; +//// } +//// export class Bar implements IFoo { +//// public foo(): void { +//// } +//// } +//// } +//// +//// module Test { +//// export interface IBase { +//// field: string; +//// method(): void; +//// } +//// +//// export interface IBlah extends IBase { +//// field: string; +//// } +//// +//// export interface IBlah2 extends IBlah { +//// field: string; +//// } +//// +//// export interface IDerived extends IBlah2 { +//// method(): void; +//// } +//// +//// export class Bar implements IDerived { +//// public field: string; +//// public method(): void { } +//// } +//// +//// export class BarBlah extends Bar { +//// public field: string; +//// } +//// } +//// +//// function test() { +//// var x = new SimpleClassTest.Bar(); +//// x.fo/*1*/o(); +//// +//// var y: SimpleInterfaceTest.IBar = null; +//// y.fo/*2*/o(); +//// +//// var z = new Test.BarBlah(); +//// z.fi/*3*/eld = ""; +//// } +////} + +// References to a field declared in a base class. +goTo.marker("1"); +verify.referencesCountIs(3); + +// References to a field declared in a base interface. +goTo.marker("2"); +verify.referencesCountIs(3); + +// References to a field declared in a chain of base class and interfaces. +goTo.marker("3"); +verify.referencesCountIs(6); diff --git a/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts b/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts index e5428df0d5d..c611c40fc89 100644 --- a/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts +++ b/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts @@ -1,5 +1,5 @@ -/// - +/// + ////interface IFoo { //// /*1*/doSomething(v: T): T; ////} @@ -8,8 +8,8 @@ ////x.doSomething("ss"); //// ////var y: IFoo; -////y.doSomething(12); - - -goTo.marker("1"); +////y.doSomething(12); + + +goTo.marker("1"); verify.referencesCountIs(3); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForStatic.ts b/tests/cases/fourslash/referencesForStatic.ts index 97a88a92782..34b34e2d474 100644 --- a/tests/cases/fourslash/referencesForStatic.ts +++ b/tests/cases/fourslash/referencesForStatic.ts @@ -1,40 +1,40 @@ -/// - -// Reference a class static. - -// @Filename: referencesOnStatic_1.ts -////var n = 43; -//// -////class foo { -//// static n = ''; -//// -//// public bar() { -//// foo./*1*/n = "'"; -//// if(foo.n) { -//// var x = foo.n; -//// } -//// } -////} -//// -////class foo2 { -//// private x = foo./*2*/n; -//// constructor() { -//// foo./*3*/n = x; -//// } -//// -//// function b(n) { -//// n = foo.n; -//// } -////} - -// @Filename: referencesOnStatic_2.ts -////var q = foo.n; - -goTo.marker("1"); -verify.referencesCountIs(8); - -goTo.marker("2"); -verify.referencesCountIs(8); - -goTo.marker("3"); +/// + +// Reference a class static. + +// @Filename: referencesOnStatic_1.ts +////var n = 43; +//// +////class foo { +//// static n = ''; +//// +//// public bar() { +//// foo./*1*/n = "'"; +//// if(foo.n) { +//// var x = foo.n; +//// } +//// } +////} +//// +////class foo2 { +//// private x = foo./*2*/n; +//// constructor() { +//// foo./*3*/n = x; +//// } +//// +//// function b(n) { +//// n = foo.n; +//// } +////} + +// @Filename: referencesOnStatic_2.ts +////var q = foo.n; + +goTo.marker("1"); +verify.referencesCountIs(8); + +goTo.marker("2"); +verify.referencesCountIs(8); + +goTo.marker("3"); verify.referencesCountIs(8); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts b/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts index 15ae06e0560..fe83f47757b 100644 --- a/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts +++ b/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts @@ -1,49 +1,49 @@ -/// - -////module FindRef4 { -//// module MixedStaticsClassTest { -//// export class Foo { -//// b/*3*/ar: Foo; -//// static b/*4*/ar: Foo; -//// -//// public f/*1*/oo(): void { -//// } -//// public static f/*2*/oo(): void { -//// } -//// } -//// } -//// -//// function test() { -//// // instance function -//// var x = new MixedStaticsClassTest.Foo(); -//// x.foo(); -//// x.bar; -//// -//// var y = new MixedStaticsClassTest.Foo(); -//// y.foo(); -//// y.bar; -//// -//// // static function -//// MixedStaticsClassTest.Foo.foo(); -//// MixedStaticsClassTest.Foo.bar; -//// } -////} - +/// + +////module FindRef4 { +//// module MixedStaticsClassTest { +//// export class Foo { +//// b/*3*/ar: Foo; +//// static b/*4*/ar: Foo; +//// +//// public f/*1*/oo(): void { +//// } +//// public static f/*2*/oo(): void { +//// } +//// } +//// } +//// +//// function test() { +//// // instance function +//// var x = new MixedStaticsClassTest.Foo(); +//// x.foo(); +//// x.bar; +//// +//// var y = new MixedStaticsClassTest.Foo(); +//// y.foo(); +//// y.bar; +//// +//// // static function +//// MixedStaticsClassTest.Foo.foo(); +//// MixedStaticsClassTest.Foo.bar; +//// } +////} + // this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - -// References to a member method with the same name as a static. -goTo.marker("1"); -verify.referencesCountIs(3); - -// References to a static method with the same name as a member. -goTo.marker("2"); -verify.referencesCountIs(2); - -// References to a member property with the same name as a static. -goTo.marker("3"); -verify.referencesCountIs(3); - -// References to a static property with the same name as a member. -goTo.marker("4"); -verify.referencesCountIs(2); +edit.insert(''); + +// References to a member method with the same name as a static. +goTo.marker("1"); +verify.referencesCountIs(3); + +// References to a static method with the same name as a member. +goTo.marker("2"); +verify.referencesCountIs(2); + +// References to a member property with the same name as a static. +goTo.marker("3"); +verify.referencesCountIs(3); + +// References to a static property with the same name as a member. +goTo.marker("4"); +verify.referencesCountIs(2); diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts index 86ce18abb84..67b956dcd02 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts @@ -1,15 +1,15 @@ -/// - +/// + ////class Foo { //// /*1*/"blah"() { return 0; } ////} //// ////var x: Foo; ////x./*2*/blah; - - -goTo.marker("1"); -verify.referencesCountIs(2); - -goTo.marker("2"); -verify.referencesCountIs(2); + + +goTo.marker("1"); +verify.referencesCountIs(2); + +goTo.marker("2"); +verify.referencesCountIs(2); diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts index 59ab77e584b..3288aec9b92 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts @@ -1,15 +1,15 @@ -/// - +/// + ////class Foo2 { //// get /*1*/"42"() { return 0; } //// set /*2*/42(n) { } ////} //// ////var y: Foo2; -////y[42]; - -goTo.marker("1"); -verify.referencesCountIs(3); - -goTo.marker("2"); +////y[42]; + +goTo.marker("1"); +verify.referencesCountIs(3); + +goTo.marker("2"); verify.referencesCountIs(3); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts index 8c6292143ab..08d04188ee9 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts @@ -1,8 +1,8 @@ -/// - -////var x = { "[|someProperty|]": 0 } -////x["[|someProperty|]"] = 3; -////x./*1*/[|someProperty|] = 5; - -goTo.marker("1"); +/// + +////var x = { "[|someProperty|]": 0 } +////x["[|someProperty|]"] = 3; +////x./*1*/[|someProperty|] = 5; + +goTo.marker("1"); test.ranges().forEach(r => verify.referencesAtPositionContains(r)); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForUnionProperties.ts b/tests/cases/fourslash/referencesForUnionProperties.ts index f4ef85e8e4e..d5f0a2fd516 100644 --- a/tests/cases/fourslash/referencesForUnionProperties.ts +++ b/tests/cases/fourslash/referencesForUnionProperties.ts @@ -4,15 +4,15 @@ //// common: { /*1*/a: number; }; ////} //// -////interface Base { -//// /*2*/a: string; -//// b: string; -////} +////interface Base { +//// /*2*/a: string; +//// b: string; +////} //// -////interface HasAOrB extends Base { -//// /*3*/a: string; -//// b: string; -////} +////interface HasAOrB extends Base { +//// /*3*/a: string; +//// b: string; +////} //// ////interface Two { //// common: HasAOrB; diff --git a/tests/cases/fourslash/referencesInComment.ts b/tests/cases/fourslash/referencesInComment.ts index f6a9fcdb0f1..7ae9fdec9d2 100644 --- a/tests/cases/fourslash/referencesInComment.ts +++ b/tests/cases/fourslash/referencesInComment.ts @@ -1,18 +1,18 @@ -/// - -////// References to /*1*/foo or b/*2*/ar -/////* in comments should not find fo/*3*/o or bar/*4*/ */ -////class foo { } -////var bar = 0; - -goTo.marker("1"); -verify.referencesCountIs(0); - -goTo.marker("2"); -verify.referencesCountIs(0); - -goTo.marker("3"); -verify.referencesCountIs(0); - -goTo.marker("4"); +/// + +////// References to /*1*/foo or b/*2*/ar +/////* in comments should not find fo/*3*/o or bar/*4*/ */ +////class foo { } +////var bar = 0; + +goTo.marker("1"); +verify.referencesCountIs(0); + +goTo.marker("2"); +verify.referencesCountIs(0); + +goTo.marker("3"); +verify.referencesCountIs(0); + +goTo.marker("4"); verify.referencesCountIs(0); \ No newline at end of file diff --git a/tests/cases/fourslash/regexDetection.ts b/tests/cases/fourslash/regexDetection.ts index 03ad81f63b0..585e25cebac 100644 --- a/tests/cases/fourslash/regexDetection.ts +++ b/tests/cases/fourslash/regexDetection.ts @@ -1,15 +1,15 @@ -/// - -//// /*1*/15 / /*2*/Math.min(61 / /*3*/42, 32 / 15) / /*4*/15; - -goTo.marker("1"); -verify.not.quickInfoExists(); - -goTo.marker("2"); -verify.not.quickInfoIs('RegExp'); - -goTo.marker("3"); -verify.not.quickInfoExists(); - -goTo.marker("4"); +/// + +//// /*1*/15 / /*2*/Math.min(61 / /*3*/42, 32 / 15) / /*4*/15; + +goTo.marker("1"); +verify.not.quickInfoExists(); + +goTo.marker("2"); +verify.not.quickInfoIs('RegExp'); + +goTo.marker("3"); +verify.not.quickInfoExists(); + +goTo.marker("4"); verify.not.quickInfoExists(); \ No newline at end of file diff --git a/tests/cases/fourslash/regexErrorRecovery.ts b/tests/cases/fourslash/regexErrorRecovery.ts index 8b5a0e5e65e..4f46249552e 100644 --- a/tests/cases/fourslash/regexErrorRecovery.ts +++ b/tests/cases/fourslash/regexErrorRecovery.ts @@ -1,13 +1,13 @@ -/// - -//// // test code -//////var x = //**/a/;/*1*/ -//////x.exec("bab"); - -//goTo.marker(""); -//debug.printCurrentFileState(); -//verify.quickInfoIs("RegExp"); -//// Bug 579071: Parser no longer detects a Regex when an open bracket is inserted -edit.insert("("); -////verify.quickInfoIs("RegExp"); +/// + +//// // test code +//////var x = //**/a/;/*1*/ +//////x.exec("bab"); + +//goTo.marker(""); +//debug.printCurrentFileState(); +//verify.quickInfoIs("RegExp"); +//// Bug 579071: Parser no longer detects a Regex when an open bracket is inserted +edit.insert("("); +////verify.quickInfoIs("RegExp"); ////verify.not.errorExistsAfterMarker("1"); \ No newline at end of file diff --git a/tests/cases/fourslash/remoteGetReferences.ts b/tests/cases/fourslash/remoteGetReferences.ts index 1bf857f24f5..cdc4ab035a3 100644 --- a/tests/cases/fourslash/remoteGetReferences.ts +++ b/tests/cases/fourslash/remoteGetReferences.ts @@ -1,202 +1,202 @@ -/// - -// @Filename: remoteGetReferences_1.ts -////// Comment Refence Test: globalVar -////var globalVar: number = 2; -//// -////class fooCls { -//// static clsSVar = 1; -//// //Declare -//// clsVar = 1; -//// -//// constructor (public clsParam: number) { -//// //Increments -//// globalVar++; -//// this.clsVar++; -//// fooCls.clsSVar++; -//// this.clsParam++; -//// modTest.modVar++; -//// } -////} -//// -////function foo(x: number) { -//// //Declare -//// var fnVar = 1; -//// -//// //Increments -//// fooCls.clsSVar++; -//// globalVar++; -//// modTest.modVar++; -//// fnVar++; -//// -//// //Return -//// return x++; -////} -//// -////module modTest { -//// //Declare -//// export var modVar:number; -//// -//// //Increments -//// globalVar++; -//// fooCls.clsSVar++; -//// modVar++; -//// -//// class testCls { -//// static boo = foo; -//// } -//// -//// function testFn(){ -//// static boo = foo; -//// -//// //Increments -//// globalVar++; -//// fooCls.clsSVar++; -//// modVar++; -//// } -//// -//// module testMod { -//// var boo = foo; -//// } -////} -//// -//////Type test -////var clsTest: fooCls; -//// -//////Arguments -////clsTest = new fooCls(globalVar); -////foo(globalVar); -//// -//////Increments -////fooCls.clsSVar++; -////modTest.modVar++; -////globalVar = globalVar + globalVar; -//// -//////ETC - Other cases -////globalVar = 3; -////foo = foo + 1; -////err = err++; -//// -//////Shadowed fn Parameter -////function shdw(globalVar: number) { -//// //Increments -//// globalVar++; -//// return globalVar; -////} -//// -//////Remotes -//////Type test -////var remoteclsTest: rem/*2*/otefooCls; -//// -//////Arguments -////remoteclsTest = new remotefooCls(remoteglo/*4*/balVar); -////remotefoo(remotegl/*3*/obalVar); -//// -//////Increments -////remotefooCls.remoteclsSVar++; -////remotemodTest.remotemodVar++; -/////*1*/remoteglobalVar = remoteglobalVar + remoteglobalVar; -//// -//////ETC - Other cases -////remoteglobalVar = 3; -//// -//////Find References misses method param -////var -//// -//// -//// -//// array = ["f", "o", "o"]; -//// -////array.forEach( -//// -//// -////function(str) { -//// -//// -//// -//// return str + " "; -//// -////}); - -// @Filename: remoteGetReferences_2.ts -////var remoteglobalVar: number = 2; -//// -////class remotefooCls { -//// //Declare -//// rem/*5*/oteclsVar = 1; -//// static r/*6*/emoteclsSVar = 1; -//// -//// constructor(public remoteclsParam: number) { -//// //Increments -//// remoteglobalVar++; -//// this.remoteclsVar++; -//// remotefooCls.remoteclsSVar++; -//// this.remoteclsParam++; -//// remotemodTest.remotemodVar++; -//// } -////} -//// -////function remotefoo(remotex: number) { -//// //Declare -//// var remotefnVar = 1; -//// -//// //Increments -//// remotefooCls.remoteclsSVar++; -//// remoteglobalVar++; -//// remotemodTest.remotemodVar++; -//// remotefnVar++; -//// -//// //Return -//// return remotex++; -////} -//// -////module remotemodTest { -//// //Declare -//// export var remotemodVar: number; -//// -//// //Increments -//// remoteglobalVar++; -//// remotefooCls.remoteclsSVar++; -//// remotemodVar++; -//// -//// class remotetestCls { -//// static remoteboo = remotefoo; -//// } -//// -//// function remotetestFn(){ -//// static remoteboo = remotefoo; -//// -//// //Increments -//// remoteglobalVar++; -//// remotefooCls.remoteclsSVar++; -//// remotemodVar++; -//// } -//// -//// module remotetestMod { -//// var remoteboo = remotefoo; -//// } -////} - -// References to a variable declared in global. -goTo.marker("1"); -verify.referencesCountIs(11); - -// References to a type. -goTo.marker("2"); -verify.referencesCountIs(8); - -// References to a function argument. -goTo.marker("3"); -verify.referencesCountIs(11); - -// References to a class argument. -goTo.marker("4"); -verify.referencesCountIs(11); - -// References to a variable declared in a class. -goTo.marker("5"); -verify.referencesCountIs(2); - -// References to static variable declared in a class. -goTo.marker("6"); +/// + +// @Filename: remoteGetReferences_1.ts +////// Comment Refence Test: globalVar +////var globalVar: number = 2; +//// +////class fooCls { +//// static clsSVar = 1; +//// //Declare +//// clsVar = 1; +//// +//// constructor (public clsParam: number) { +//// //Increments +//// globalVar++; +//// this.clsVar++; +//// fooCls.clsSVar++; +//// this.clsParam++; +//// modTest.modVar++; +//// } +////} +//// +////function foo(x: number) { +//// //Declare +//// var fnVar = 1; +//// +//// //Increments +//// fooCls.clsSVar++; +//// globalVar++; +//// modTest.modVar++; +//// fnVar++; +//// +//// //Return +//// return x++; +////} +//// +////module modTest { +//// //Declare +//// export var modVar:number; +//// +//// //Increments +//// globalVar++; +//// fooCls.clsSVar++; +//// modVar++; +//// +//// class testCls { +//// static boo = foo; +//// } +//// +//// function testFn(){ +//// static boo = foo; +//// +//// //Increments +//// globalVar++; +//// fooCls.clsSVar++; +//// modVar++; +//// } +//// +//// module testMod { +//// var boo = foo; +//// } +////} +//// +//////Type test +////var clsTest: fooCls; +//// +//////Arguments +////clsTest = new fooCls(globalVar); +////foo(globalVar); +//// +//////Increments +////fooCls.clsSVar++; +////modTest.modVar++; +////globalVar = globalVar + globalVar; +//// +//////ETC - Other cases +////globalVar = 3; +////foo = foo + 1; +////err = err++; +//// +//////Shadowed fn Parameter +////function shdw(globalVar: number) { +//// //Increments +//// globalVar++; +//// return globalVar; +////} +//// +//////Remotes +//////Type test +////var remoteclsTest: rem/*2*/otefooCls; +//// +//////Arguments +////remoteclsTest = new remotefooCls(remoteglo/*4*/balVar); +////remotefoo(remotegl/*3*/obalVar); +//// +//////Increments +////remotefooCls.remoteclsSVar++; +////remotemodTest.remotemodVar++; +/////*1*/remoteglobalVar = remoteglobalVar + remoteglobalVar; +//// +//////ETC - Other cases +////remoteglobalVar = 3; +//// +//////Find References misses method param +////var +//// +//// +//// +//// array = ["f", "o", "o"]; +//// +////array.forEach( +//// +//// +////function(str) { +//// +//// +//// +//// return str + " "; +//// +////}); + +// @Filename: remoteGetReferences_2.ts +////var remoteglobalVar: number = 2; +//// +////class remotefooCls { +//// //Declare +//// rem/*5*/oteclsVar = 1; +//// static r/*6*/emoteclsSVar = 1; +//// +//// constructor(public remoteclsParam: number) { +//// //Increments +//// remoteglobalVar++; +//// this.remoteclsVar++; +//// remotefooCls.remoteclsSVar++; +//// this.remoteclsParam++; +//// remotemodTest.remotemodVar++; +//// } +////} +//// +////function remotefoo(remotex: number) { +//// //Declare +//// var remotefnVar = 1; +//// +//// //Increments +//// remotefooCls.remoteclsSVar++; +//// remoteglobalVar++; +//// remotemodTest.remotemodVar++; +//// remotefnVar++; +//// +//// //Return +//// return remotex++; +////} +//// +////module remotemodTest { +//// //Declare +//// export var remotemodVar: number; +//// +//// //Increments +//// remoteglobalVar++; +//// remotefooCls.remoteclsSVar++; +//// remotemodVar++; +//// +//// class remotetestCls { +//// static remoteboo = remotefoo; +//// } +//// +//// function remotetestFn(){ +//// static remoteboo = remotefoo; +//// +//// //Increments +//// remoteglobalVar++; +//// remotefooCls.remoteclsSVar++; +//// remotemodVar++; +//// } +//// +//// module remotetestMod { +//// var remoteboo = remotefoo; +//// } +////} + +// References to a variable declared in global. +goTo.marker("1"); +verify.referencesCountIs(11); + +// References to a type. +goTo.marker("2"); +verify.referencesCountIs(8); + +// References to a function argument. +goTo.marker("3"); +verify.referencesCountIs(11); + +// References to a class argument. +goTo.marker("4"); +verify.referencesCountIs(11); + +// References to a variable declared in a class. +goTo.marker("5"); +verify.referencesCountIs(2); + +// References to static variable declared in a class. +goTo.marker("6"); verify.referencesCountIs(6); \ No newline at end of file diff --git a/tests/cases/fourslash/removeDeclareParamTypeAnnotation.ts b/tests/cases/fourslash/removeDeclareParamTypeAnnotation.ts index c78c681e517..ec04d1f362c 100644 --- a/tests/cases/fourslash/removeDeclareParamTypeAnnotation.ts +++ b/tests/cases/fourslash/removeDeclareParamTypeAnnotation.ts @@ -1,8 +1,8 @@ -/// - -//// declare class T { } -//// declare function parseInt(/**/s:T):T; -//// parseInt('2'); - -goTo.marker(); -edit.deleteAtCaret('s:T'.length); +/// + +//// declare class T { } +//// declare function parseInt(/**/s:T):T; +//// parseInt('2'); + +goTo.marker(); +edit.deleteAtCaret('s:T'.length); diff --git a/tests/cases/fourslash/removeExportFromInterfaceError0.ts b/tests/cases/fourslash/removeExportFromInterfaceError0.ts index f10180d53b3..103f51ff419 100644 --- a/tests/cases/fourslash/removeExportFromInterfaceError0.ts +++ b/tests/cases/fourslash/removeExportFromInterfaceError0.ts @@ -1,15 +1,15 @@ -/// - -//// module M { -//// export class C1 { } -//// /*1*/export interface I { n: number; } -//// } -//// module M { -//// function f(): I { return null; } } -//// - -edit.disableFormatting(); - -goTo.marker("1"); - -edit.deleteAtCaret(6); +/// + +//// module M { +//// export class C1 { } +//// /*1*/export interface I { n: number; } +//// } +//// module M { +//// function f(): I { return null; } } +//// + +edit.disableFormatting(); + +goTo.marker("1"); + +edit.deleteAtCaret(6); diff --git a/tests/cases/fourslash/removeExportFromInterfaceError1.ts b/tests/cases/fourslash/removeExportFromInterfaceError1.ts index f10180d53b3..103f51ff419 100644 --- a/tests/cases/fourslash/removeExportFromInterfaceError1.ts +++ b/tests/cases/fourslash/removeExportFromInterfaceError1.ts @@ -1,15 +1,15 @@ -/// - -//// module M { -//// export class C1 { } -//// /*1*/export interface I { n: number; } -//// } -//// module M { -//// function f(): I { return null; } } -//// - -edit.disableFormatting(); - -goTo.marker("1"); - -edit.deleteAtCaret(6); +/// + +//// module M { +//// export class C1 { } +//// /*1*/export interface I { n: number; } +//// } +//// module M { +//// function f(): I { return null; } } +//// + +edit.disableFormatting(); + +goTo.marker("1"); + +edit.deleteAtCaret(6); diff --git a/tests/cases/fourslash/removeExportedClassFromReopenedModule.ts b/tests/cases/fourslash/removeExportedClassFromReopenedModule.ts index 3d5ce9cb559..701a19074f9 100644 --- a/tests/cases/fourslash/removeExportedClassFromReopenedModule.ts +++ b/tests/cases/fourslash/removeExportedClassFromReopenedModule.ts @@ -1,16 +1,16 @@ -/// - -//// module multiM { } -//// -//// module multiM { -//// /*1*/export class c { } -//// } -//// - -goTo.marker('1'); -edit.deleteAtCaret('export class c { }'.length); - -goTo.eof(); - -edit.insert("new multiM.c();"); -verify.numberOfErrorsInCurrentFile(1); +/// + +//// module multiM { } +//// +//// module multiM { +//// /*1*/export class c { } +//// } +//// + +goTo.marker('1'); +edit.deleteAtCaret('export class c { }'.length); + +goTo.eof(); + +edit.insert("new multiM.c();"); +verify.numberOfErrorsInCurrentFile(1); diff --git a/tests/cases/fourslash/removeInterfaceUsedAsGenericTypeArgument.ts b/tests/cases/fourslash/removeInterfaceUsedAsGenericTypeArgument.ts index 200f21fa788..86d25e167c1 100644 --- a/tests/cases/fourslash/removeInterfaceUsedAsGenericTypeArgument.ts +++ b/tests/cases/fourslash/removeInterfaceUsedAsGenericTypeArgument.ts @@ -1,8 +1,8 @@ -/// - -//// /**/interface A { a: string; } -//// interface G { } -//// var v1: G; - -goTo.marker(); -edit.deleteAtCaret('interface A { a: string; }'.length); +/// + +//// /**/interface A { a: string; } +//// interface G { } +//// var v1: G; + +goTo.marker(); +edit.deleteAtCaret('interface A { a: string; }'.length); diff --git a/tests/cases/fourslash/removeParameterBetweenCommentAndParameter.ts b/tests/cases/fourslash/removeParameterBetweenCommentAndParameter.ts index d145e16febd..29de69b8ef3 100644 --- a/tests/cases/fourslash/removeParameterBetweenCommentAndParameter.ts +++ b/tests/cases/fourslash/removeParameterBetweenCommentAndParameter.ts @@ -1,6 +1,6 @@ -/// - -//// function fn(/* comment! */ /**/a: number, c) { } - -goTo.marker(); -edit.deleteAtCaret('a: number,'.length); +/// + +//// function fn(/* comment! */ /**/a: number, c) { } + +goTo.marker(); +edit.deleteAtCaret('a: number,'.length); diff --git a/tests/cases/fourslash/removeVarFromModuleWithReopenedEnums.ts b/tests/cases/fourslash/removeVarFromModuleWithReopenedEnums.ts index b25cbfde3a3..ef0012a62e7 100644 --- a/tests/cases/fourslash/removeVarFromModuleWithReopenedEnums.ts +++ b/tests/cases/fourslash/removeVarFromModuleWithReopenedEnums.ts @@ -1,16 +1,16 @@ -/// - -//// module A { -//// /**/var o; -//// } -//// enum A { -//// } -//// enum A { -//// } -//// module A { -//// var p; -//// } - -goTo.marker(); -edit.deleteAtCaret('var o;'.length); - +/// + +//// module A { +//// /**/var o; +//// } +//// enum A { +//// } +//// enum A { +//// } +//// module A { +//// var p; +//// } + +goTo.marker(); +edit.deleteAtCaret('var o;'.length); + diff --git a/tests/cases/fourslash/renameCommentsAndStrings1.ts b/tests/cases/fourslash/renameCommentsAndStrings1.ts index b5c8ac6aacc..b7a1f5d61ae 100644 --- a/tests/cases/fourslash/renameCommentsAndStrings1.ts +++ b/tests/cases/fourslash/renameCommentsAndStrings1.ts @@ -1,5 +1,5 @@ -/// - +/// + /////// ////function /**/[|Bar|]() { diff --git a/tests/cases/fourslash/scriptLexicalStructureEmptyConstructors.ts b/tests/cases/fourslash/scriptLexicalStructureEmptyConstructors.ts index 27bae4ab6bf..570b2f7518c 100644 --- a/tests/cases/fourslash/scriptLexicalStructureEmptyConstructors.ts +++ b/tests/cases/fourslash/scriptLexicalStructureEmptyConstructors.ts @@ -1,12 +1,12 @@ -/// - -////class Test { -//// constructor() { -//// } -////} - -verify.getScriptLexicalStructureListContains("Test", "class"); -verify.getScriptLexicalStructureListContains("constructor", "constructor"); - -// no other items +/// + +////class Test { +//// constructor() { +//// } +////} + +verify.getScriptLexicalStructureListContains("Test", "class"); +verify.getScriptLexicalStructureListContains("constructor", "constructor"); + +// no other items verify.getScriptLexicalStructureListCount(2); \ No newline at end of file diff --git a/tests/cases/fourslash/scriptLexicalStructureExports.ts b/tests/cases/fourslash/scriptLexicalStructureExports.ts index f2a4adfa0d1..d9db125b9b0 100644 --- a/tests/cases/fourslash/scriptLexicalStructureExports.ts +++ b/tests/cases/fourslash/scriptLexicalStructureExports.ts @@ -1,18 +1,18 @@ -/// - - -////export { {| "itemName": "a", "kind": "alias", "parentName": "" |}a } from "a"; -//// -////export { {| "itemName": "B", "kind": "alias", "parentName": "" |}b as B } from "a" -//// -////{| "itemName": "e", "kind": "alias", "parentName": "" |} export import e = require("a"); -//// -////export * from "a"; // no bindings here - -test.markers().forEach((marker) => { - if (marker.data) { - verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); - } -}); - -verify.getScriptLexicalStructureListCount(4); +/// + + +////export { {| "itemName": "a", "kind": "alias", "parentName": "" |}a } from "a"; +//// +////export { {| "itemName": "B", "kind": "alias", "parentName": "" |}b as B } from "a" +//// +////{| "itemName": "e", "kind": "alias", "parentName": "" |} export import e = require("a"); +//// +////export * from "a"; // no bindings here + +test.markers().forEach((marker) => { + if (marker.data) { + verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); + } +}); + +verify.getScriptLexicalStructureListCount(4); diff --git a/tests/cases/fourslash/scriptLexicalStructureImports.ts b/tests/cases/fourslash/scriptLexicalStructureImports.ts index 9d9e3e8b468..8b0d02bd9f5 100644 --- a/tests/cases/fourslash/scriptLexicalStructureImports.ts +++ b/tests/cases/fourslash/scriptLexicalStructureImports.ts @@ -1,25 +1,25 @@ -/// - - -////import {| "itemName": "d1", "kind": "alias", "parentName": "" |}d1 from "a"; -//// -////import { {| "itemName": "a", "kind": "alias", "parentName": "" |}a } from "a"; -//// -////import { {| "itemName": "B", "kind": "alias", "parentName": "" |}b as B } from "a" -//// -////import {| "itemName": "d2", "kind": "alias", "parentName": "" |}d2, -//// { {| "itemName": "c", "kind": "alias", "parentName": "" |}c, -//// {| "itemName": "D", "kind": "alias", "parentName": "" |} d as D } from "a" -//// -////{| "itemName": "e", "kind": "alias", "parentName": "" |}import e = require("a"); -//// -////import {| "itemName": "ns", "kind": "alias", "parentName": "" |}* as ns from "a"; - - -test.markers().forEach((marker) => { - if (marker.data) { - verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); - } -}); - -verify.getScriptLexicalStructureListCount(9); +/// + + +////import {| "itemName": "d1", "kind": "alias", "parentName": "" |}d1 from "a"; +//// +////import { {| "itemName": "a", "kind": "alias", "parentName": "" |}a } from "a"; +//// +////import { {| "itemName": "B", "kind": "alias", "parentName": "" |}b as B } from "a" +//// +////import {| "itemName": "d2", "kind": "alias", "parentName": "" |}d2, +//// { {| "itemName": "c", "kind": "alias", "parentName": "" |}c, +//// {| "itemName": "D", "kind": "alias", "parentName": "" |} d as D } from "a" +//// +////{| "itemName": "e", "kind": "alias", "parentName": "" |}import e = require("a"); +//// +////import {| "itemName": "ns", "kind": "alias", "parentName": "" |}* as ns from "a"; + + +test.markers().forEach((marker) => { + if (marker.data) { + verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); + } +}); + +verify.getScriptLexicalStructureListCount(9); diff --git a/tests/cases/fourslash/scriptLexicalStructureItems.ts b/tests/cases/fourslash/scriptLexicalStructureItems.ts index e18f49c1db9..67e14fe1009 100644 --- a/tests/cases/fourslash/scriptLexicalStructureItems.ts +++ b/tests/cases/fourslash/scriptLexicalStructureItems.ts @@ -1,52 +1,52 @@ -/// - -////// Interface -////{| "itemName": "IPoint", "kind": "interface", "parentName": "" |}interface IPoint { -//// {| "itemName": "getDist", "kind": "method", "parentName": "IPoint" |}getDist(): number; -//// {| "itemName": "new()", "kind": "construct", "parentName": "IPoint" |}new(): IPoint; -//// {| "itemName": "()", "kind": "call", "parentName": "IPoint" |}(): any; -//// {| "itemName": "[]", "kind": "index", "parentName": "IPoint" |}[x:string]: number; -//// {| "itemName": "prop", "kind": "property", "parentName": "IPoint" |}prop: string; -////} -//// -/////// Module -////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes { -//// -//// // Class -//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point implements IPoint { -//// {| "itemName": "constructor", "kind": "constructor", "parentName": "Shapes.Point" |}constructor (public x: number, public y: number) { } -//// -//// // Instance member -//// {| "itemName": "getDist", "kind": "method", "parentName": "Shapes.Point" |}getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } -//// -//// // Getter -//// {| "itemName": "value", "kind": "getter", "parentName": "Shapes.Point" |}get value(): number { return 0; } -//// -//// // Setter -//// {| "itemName": "value", "kind": "setter", "parentName": "Shapes.Point" |}set value(newValue: number) { return; } -//// -//// // Static member -//// {| "itemName": "origin", "kind": "property", "parentName": "Shapes.Point" |}static origin = new Point(0, 0); -//// -//// // Static method -//// {| "itemName": "getOrigin", "kind": "method", "parentName": "Shapes.Point" |}private static getOrigin() { return Point.origin;} -//// } -//// -//// {| "itemName": "Values", "kind": "enum", "parentName": "Shapes" |}enum Values { -//// value1, -//// {| "itemName": "value2", "kind": "property", "parentName": "Shapes.Values" |}value2, -//// value3, -//// } -////} -//// -////// Local variables -////{| "itemName": "p", "kind": "var", "parentName": "" |}var p: IPoint = new Shapes.Point(3, 4); -////{| "itemName": "dist", "kind": "var", "parentName": "" |}var dist = p.getDist(); - -test.markers().forEach((marker) => { - if (marker.data) { - verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); - } -}); - -verify.getScriptLexicalStructureListCount(23); +/// + +////// Interface +////{| "itemName": "IPoint", "kind": "interface", "parentName": "" |}interface IPoint { +//// {| "itemName": "getDist", "kind": "method", "parentName": "IPoint" |}getDist(): number; +//// {| "itemName": "new()", "kind": "construct", "parentName": "IPoint" |}new(): IPoint; +//// {| "itemName": "()", "kind": "call", "parentName": "IPoint" |}(): any; +//// {| "itemName": "[]", "kind": "index", "parentName": "IPoint" |}[x:string]: number; +//// {| "itemName": "prop", "kind": "property", "parentName": "IPoint" |}prop: string; +////} +//// +/////// Module +////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes { +//// +//// // Class +//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point implements IPoint { +//// {| "itemName": "constructor", "kind": "constructor", "parentName": "Shapes.Point" |}constructor (public x: number, public y: number) { } +//// +//// // Instance member +//// {| "itemName": "getDist", "kind": "method", "parentName": "Shapes.Point" |}getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } +//// +//// // Getter +//// {| "itemName": "value", "kind": "getter", "parentName": "Shapes.Point" |}get value(): number { return 0; } +//// +//// // Setter +//// {| "itemName": "value", "kind": "setter", "parentName": "Shapes.Point" |}set value(newValue: number) { return; } +//// +//// // Static member +//// {| "itemName": "origin", "kind": "property", "parentName": "Shapes.Point" |}static origin = new Point(0, 0); +//// +//// // Static method +//// {| "itemName": "getOrigin", "kind": "method", "parentName": "Shapes.Point" |}private static getOrigin() { return Point.origin;} +//// } +//// +//// {| "itemName": "Values", "kind": "enum", "parentName": "Shapes" |}enum Values { +//// value1, +//// {| "itemName": "value2", "kind": "property", "parentName": "Shapes.Values" |}value2, +//// value3, +//// } +////} +//// +////// Local variables +////{| "itemName": "p", "kind": "var", "parentName": "" |}var p: IPoint = new Shapes.Point(3, 4); +////{| "itemName": "dist", "kind": "var", "parentName": "" |}var dist = p.getDist(); + +test.markers().forEach((marker) => { + if (marker.data) { + verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); + } +}); + +verify.getScriptLexicalStructureListCount(23); diff --git a/tests/cases/fourslash/scriptLexicalStructureItems2.ts b/tests/cases/fourslash/scriptLexicalStructureItems2.ts index 092527ec937..7022c082ced 100644 --- a/tests/cases/fourslash/scriptLexicalStructureItems2.ts +++ b/tests/cases/fourslash/scriptLexicalStructureItems2.ts @@ -1,12 +1,12 @@ -/// - - -/////**/ - -goTo.marker(); -edit.insertLine("module A"); -edit.insert("export class "); - -// should not crash -verify.getScriptLexicalStructureListCount(1); - +/// + + +/////**/ + +goTo.marker(); +edit.insertLine("module A"); +edit.insert("export class "); + +// should not crash +verify.getScriptLexicalStructureListCount(1); + diff --git a/tests/cases/fourslash/scriptLexicalStructureItemsContainsNoAnonymousFunctions.ts b/tests/cases/fourslash/scriptLexicalStructureItemsContainsNoAnonymousFunctions.ts index a4086450176..b7430ad03de 100644 --- a/tests/cases/fourslash/scriptLexicalStructureItemsContainsNoAnonymousFunctions.ts +++ b/tests/cases/fourslash/scriptLexicalStructureItemsContainsNoAnonymousFunctions.ts @@ -1,44 +1,44 @@ -/// -// @Filename: scriptLexicalStructureItemsContainsNoAnonymouseFunctions_0.ts -/////*file1*/ -////(function() { -//// // this should not be included -//// var x = 0; -//// -//// // this should not be included either -//// function foo() { -//// -//// } -////})(); -//// -// @Filename: scriptLexicalStructureItemsContainsNoAnonymouseFunctions_1.ts -/////*file2*/ -////var x = function() { -//// // this should not be included -//// var x = 0; -//// -//// // this should not be included either -//// function foo() { -////}; -//// -// @Filename: scriptLexicalStructureItemsContainsNoAnonymouseFunctions_2.ts -////// Named functions should still show up -/////*file3*/ -////function foo() { -////} -////function bar() { -////} - -goTo.marker("file1"); -verify.getScriptLexicalStructureListCount(0); - -goTo.marker("file2"); -verify.getScriptLexicalStructureListContains("", "module"); -verify.getScriptLexicalStructureListContains("x", "var"); -verify.getScriptLexicalStructureListCount(2); - -goTo.marker("file3"); -verify.getScriptLexicalStructureListContains("", "module"); -verify.getScriptLexicalStructureListContains("foo", "function"); -verify.getScriptLexicalStructureListContains("bar", "function"); +/// +// @Filename: scriptLexicalStructureItemsContainsNoAnonymouseFunctions_0.ts +/////*file1*/ +////(function() { +//// // this should not be included +//// var x = 0; +//// +//// // this should not be included either +//// function foo() { +//// +//// } +////})(); +//// +// @Filename: scriptLexicalStructureItemsContainsNoAnonymouseFunctions_1.ts +/////*file2*/ +////var x = function() { +//// // this should not be included +//// var x = 0; +//// +//// // this should not be included either +//// function foo() { +////}; +//// +// @Filename: scriptLexicalStructureItemsContainsNoAnonymouseFunctions_2.ts +////// Named functions should still show up +/////*file3*/ +////function foo() { +////} +////function bar() { +////} + +goTo.marker("file1"); +verify.getScriptLexicalStructureListCount(0); + +goTo.marker("file2"); +verify.getScriptLexicalStructureListContains("", "module"); +verify.getScriptLexicalStructureListContains("x", "var"); +verify.getScriptLexicalStructureListCount(2); + +goTo.marker("file3"); +verify.getScriptLexicalStructureListContains("", "module"); +verify.getScriptLexicalStructureListContains("foo", "function"); +verify.getScriptLexicalStructureListContains("bar", "function"); verify.getScriptLexicalStructureListCount(5); \ No newline at end of file diff --git a/tests/cases/fourslash/scriptLexicalStructureMissingName1.ts b/tests/cases/fourslash/scriptLexicalStructureMissingName1.ts index 60d858b6089..c5282d696f3 100644 --- a/tests/cases/fourslash/scriptLexicalStructureMissingName1.ts +++ b/tests/cases/fourslash/scriptLexicalStructureMissingName1.ts @@ -1,4 +1,4 @@ -////export function +////export function /////** //// * This is a class. //// */ diff --git a/tests/cases/fourslash/scriptLexicalStructureMissingName2.ts b/tests/cases/fourslash/scriptLexicalStructureMissingName2.ts index 0ee0d1197bf..b805427ff63 100644 --- a/tests/cases/fourslash/scriptLexicalStructureMissingName2.ts +++ b/tests/cases/fourslash/scriptLexicalStructureMissingName2.ts @@ -1,4 +1,4 @@ -/////** +/////** //// * This is a class. //// */ ////class /* But it has no name! */ { diff --git a/tests/cases/fourslash/scriptLexicalStructureModules.ts b/tests/cases/fourslash/scriptLexicalStructureModules.ts index ee0f91cc73c..a5fc9b641f9 100644 --- a/tests/cases/fourslash/scriptLexicalStructureModules.ts +++ b/tests/cases/fourslash/scriptLexicalStructureModules.ts @@ -1,4 +1,4 @@ - + ////{| "itemName": "\"X.Y.Z\"", "kind": "module" |} ////declare module "X.Y.Z" { ////} diff --git a/tests/cases/fourslash/scriptLexicalStructureMultilineStringIdentifiers.ts b/tests/cases/fourslash/scriptLexicalStructureMultilineStringIdentifiers.ts index 796a4caa2d8..59eca486b62 100644 --- a/tests/cases/fourslash/scriptLexicalStructureMultilineStringIdentifiers.ts +++ b/tests/cases/fourslash/scriptLexicalStructureMultilineStringIdentifiers.ts @@ -1,4 +1,4 @@ - + ////{| "itemName": "\"Multiline\\r\\nMadness\"", "kind": "module" |} ////declare module "Multiline\r\nMadness" { ////} diff --git a/tests/cases/fourslash/scriptLexicalStructurePropertiesDefinedInConstructors.ts b/tests/cases/fourslash/scriptLexicalStructurePropertiesDefinedInConstructors.ts index e73db067bf9..adda43066a3 100644 --- a/tests/cases/fourslash/scriptLexicalStructurePropertiesDefinedInConstructors.ts +++ b/tests/cases/fourslash/scriptLexicalStructurePropertiesDefinedInConstructors.ts @@ -1,15 +1,15 @@ -/// - -////class List { -//// constructor(public a: boolean, public b: T, c: number) { -//// var local = 0; -//// } -////} - -verify.getScriptLexicalStructureListContains("List", "class"); -verify.getScriptLexicalStructureListContains("constructor", "constructor"); -verify.getScriptLexicalStructureListContains("a", "property"); -verify.getScriptLexicalStructureListContains("b", "property"); - -// no other items +/// + +////class List { +//// constructor(public a: boolean, public b: T, c: number) { +//// var local = 0; +//// } +////} + +verify.getScriptLexicalStructureListContains("List", "class"); +verify.getScriptLexicalStructureListContains("constructor", "constructor"); +verify.getScriptLexicalStructureListContains("a", "property"); +verify.getScriptLexicalStructureListContains("b", "property"); + +// no other items verify.getScriptLexicalStructureListCount(4); \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassificationInTemplateExpressions.ts b/tests/cases/fourslash/semanticClassificationInTemplateExpressions.ts index 19f6d1062cb..7ac8bec2820 100644 --- a/tests/cases/fourslash/semanticClassificationInTemplateExpressions.ts +++ b/tests/cases/fourslash/semanticClassificationInTemplateExpressions.ts @@ -1,4 +1,4 @@ -/// +/// ////module /*0*/M { //// export class /*1*/C { diff --git a/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName1.ts b/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName1.ts index 2b8b6824558..2061c218eac 100644 --- a/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName1.ts +++ b/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName1.ts @@ -1,4 +1,4 @@ -/// +/// ////module /*0*/M { //// export interface /*1*/I { diff --git a/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName2.ts b/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName2.ts index 5d2ed9844cc..f1f4fa8e670 100644 --- a/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName2.ts +++ b/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName2.ts @@ -1,4 +1,4 @@ -/// +/// ////module /*0*/M { //// export interface /*1*/I { diff --git a/tests/cases/fourslash/semanticClassificationModules.ts b/tests/cases/fourslash/semanticClassificationModules.ts index 86c2819983a..6992639e4c3 100644 --- a/tests/cases/fourslash/semanticClassificationModules.ts +++ b/tests/cases/fourslash/semanticClassificationModules.ts @@ -1,4 +1,4 @@ -/// +/// ////module /*0*/M { //// export var v; diff --git a/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName1.ts b/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName1.ts index e7486c2c0cb..6c98c8340c3 100644 --- a/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName1.ts +++ b/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName1.ts @@ -1,4 +1,4 @@ -/// +/// ////declare module /*0*/M { //// interface /*1*/I { diff --git a/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName2.ts b/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName2.ts index f90efd7518d..419692b98ce 100644 --- a/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName2.ts +++ b/tests/cases/fourslash/semanticClassificationUninstantiatedModuleWithVariableOfSameName2.ts @@ -1,4 +1,4 @@ -/// +/// ////module /*0*/M { //// export interface /*1*/I { diff --git a/tests/cases/fourslash/semanticClassificationWithUnionTypes.ts b/tests/cases/fourslash/semanticClassificationWithUnionTypes.ts index 40a7f409685..bc55c5d8253 100644 --- a/tests/cases/fourslash/semanticClassificationWithUnionTypes.ts +++ b/tests/cases/fourslash/semanticClassificationWithUnionTypes.ts @@ -1,4 +1,4 @@ -////module /*0*/M { +////module /*0*/M { //// export interface /*1*/I { //// } ////} diff --git a/tests/cases/fourslash/server/definition.ts b/tests/cases/fourslash/server/definition.ts index 531e4562843..f403965fe12 100644 --- a/tests/cases/fourslash/server/definition.ts +++ b/tests/cases/fourslash/server/definition.ts @@ -1,4 +1,4 @@ -/// +/// // @Filename: b.ts ////import n = require('a/*1*/'); diff --git a/tests/cases/fourslash/server/navbar.ts b/tests/cases/fourslash/server/navbar.ts index e18f49c1db9..67e14fe1009 100644 --- a/tests/cases/fourslash/server/navbar.ts +++ b/tests/cases/fourslash/server/navbar.ts @@ -1,52 +1,52 @@ -/// - -////// Interface -////{| "itemName": "IPoint", "kind": "interface", "parentName": "" |}interface IPoint { -//// {| "itemName": "getDist", "kind": "method", "parentName": "IPoint" |}getDist(): number; -//// {| "itemName": "new()", "kind": "construct", "parentName": "IPoint" |}new(): IPoint; -//// {| "itemName": "()", "kind": "call", "parentName": "IPoint" |}(): any; -//// {| "itemName": "[]", "kind": "index", "parentName": "IPoint" |}[x:string]: number; -//// {| "itemName": "prop", "kind": "property", "parentName": "IPoint" |}prop: string; -////} -//// -/////// Module -////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes { -//// -//// // Class -//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point implements IPoint { -//// {| "itemName": "constructor", "kind": "constructor", "parentName": "Shapes.Point" |}constructor (public x: number, public y: number) { } -//// -//// // Instance member -//// {| "itemName": "getDist", "kind": "method", "parentName": "Shapes.Point" |}getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } -//// -//// // Getter -//// {| "itemName": "value", "kind": "getter", "parentName": "Shapes.Point" |}get value(): number { return 0; } -//// -//// // Setter -//// {| "itemName": "value", "kind": "setter", "parentName": "Shapes.Point" |}set value(newValue: number) { return; } -//// -//// // Static member -//// {| "itemName": "origin", "kind": "property", "parentName": "Shapes.Point" |}static origin = new Point(0, 0); -//// -//// // Static method -//// {| "itemName": "getOrigin", "kind": "method", "parentName": "Shapes.Point" |}private static getOrigin() { return Point.origin;} -//// } -//// -//// {| "itemName": "Values", "kind": "enum", "parentName": "Shapes" |}enum Values { -//// value1, -//// {| "itemName": "value2", "kind": "property", "parentName": "Shapes.Values" |}value2, -//// value3, -//// } -////} -//// -////// Local variables -////{| "itemName": "p", "kind": "var", "parentName": "" |}var p: IPoint = new Shapes.Point(3, 4); -////{| "itemName": "dist", "kind": "var", "parentName": "" |}var dist = p.getDist(); - -test.markers().forEach((marker) => { - if (marker.data) { - verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); - } -}); - -verify.getScriptLexicalStructureListCount(23); +/// + +////// Interface +////{| "itemName": "IPoint", "kind": "interface", "parentName": "" |}interface IPoint { +//// {| "itemName": "getDist", "kind": "method", "parentName": "IPoint" |}getDist(): number; +//// {| "itemName": "new()", "kind": "construct", "parentName": "IPoint" |}new(): IPoint; +//// {| "itemName": "()", "kind": "call", "parentName": "IPoint" |}(): any; +//// {| "itemName": "[]", "kind": "index", "parentName": "IPoint" |}[x:string]: number; +//// {| "itemName": "prop", "kind": "property", "parentName": "IPoint" |}prop: string; +////} +//// +/////// Module +////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes { +//// +//// // Class +//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point implements IPoint { +//// {| "itemName": "constructor", "kind": "constructor", "parentName": "Shapes.Point" |}constructor (public x: number, public y: number) { } +//// +//// // Instance member +//// {| "itemName": "getDist", "kind": "method", "parentName": "Shapes.Point" |}getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } +//// +//// // Getter +//// {| "itemName": "value", "kind": "getter", "parentName": "Shapes.Point" |}get value(): number { return 0; } +//// +//// // Setter +//// {| "itemName": "value", "kind": "setter", "parentName": "Shapes.Point" |}set value(newValue: number) { return; } +//// +//// // Static member +//// {| "itemName": "origin", "kind": "property", "parentName": "Shapes.Point" |}static origin = new Point(0, 0); +//// +//// // Static method +//// {| "itemName": "getOrigin", "kind": "method", "parentName": "Shapes.Point" |}private static getOrigin() { return Point.origin;} +//// } +//// +//// {| "itemName": "Values", "kind": "enum", "parentName": "Shapes" |}enum Values { +//// value1, +//// {| "itemName": "value2", "kind": "property", "parentName": "Shapes.Values" |}value2, +//// value3, +//// } +////} +//// +////// Local variables +////{| "itemName": "p", "kind": "var", "parentName": "" |}var p: IPoint = new Shapes.Point(3, 4); +////{| "itemName": "dist", "kind": "var", "parentName": "" |}var dist = p.getDist(); + +test.markers().forEach((marker) => { + if (marker.data) { + verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); + } +}); + +verify.getScriptLexicalStructureListCount(23); diff --git a/tests/cases/fourslash/server/navto.ts b/tests/cases/fourslash/server/navto.ts index 0179c168552..ba907e985fd 100644 --- a/tests/cases/fourslash/server/navto.ts +++ b/tests/cases/fourslash/server/navto.ts @@ -1,28 +1,28 @@ -/// - -/////// Module -////{| "itemName": "MyShapes", "kind": "module", "parentName": "", "matchKind": "substring" |}module MyShapes { -//// -//// // Class -//// {| "itemName": "MyPoint", "kind": "class", "parentName": "MyShapes", "matchKind": "substring" |}export class MyPoint { -//// // Instance member -//// {| "itemName": "MyoriginPointAttheHorizon", "kind": "property", "parentName": "MyPoint", "matchKind": "substring"|}private MyoriginPointAttheHorizon = 0.0; -//// -//// // Getter -//// {| "itemName": "MydistanceFromOrigin", "kind": "getter", "parentName": "MyPoint", "matchKind": "substring" |}get MydistanceFromOrigin(): number { return 0; } -//// -//// } -////} -//// -////// Local variables -////{| "itemName": "myPointThatIJustInitiated", "kind": "var", "parentName": "", "matchKind": "substring"|}var myPointThatIJustInitiated = new Shapes.Point(); - -//// Testing for substring matching of navigationItems -//var searchValue = "FromOrigin horizon INITIATED Shape Point"; - -test.markers().forEach((marker) => { - if (marker.data) { - var name = marker.data.itemName; - verify.navigationItemsListContains(name, marker.data.kind, name.substr(2), marker.data.matchKind, marker.fileName, marker.data.parentName); - } +/// + +/////// Module +////{| "itemName": "MyShapes", "kind": "module", "parentName": "", "matchKind": "substring" |}module MyShapes { +//// +//// // Class +//// {| "itemName": "MyPoint", "kind": "class", "parentName": "MyShapes", "matchKind": "substring" |}export class MyPoint { +//// // Instance member +//// {| "itemName": "MyoriginPointAttheHorizon", "kind": "property", "parentName": "MyPoint", "matchKind": "substring"|}private MyoriginPointAttheHorizon = 0.0; +//// +//// // Getter +//// {| "itemName": "MydistanceFromOrigin", "kind": "getter", "parentName": "MyPoint", "matchKind": "substring" |}get MydistanceFromOrigin(): number { return 0; } +//// +//// } +////} +//// +////// Local variables +////{| "itemName": "myPointThatIJustInitiated", "kind": "var", "parentName": "", "matchKind": "substring"|}var myPointThatIJustInitiated = new Shapes.Point(); + +//// Testing for substring matching of navigationItems +//var searchValue = "FromOrigin horizon INITIATED Shape Point"; + +test.markers().forEach((marker) => { + if (marker.data) { + var name = marker.data.itemName; + verify.navigationItemsListContains(name, marker.data.kind, name.substr(2), marker.data.matchKind, marker.fileName, marker.data.parentName); + } }); \ No newline at end of file diff --git a/tests/cases/fourslash/shims/getDefinitionAtPosition.ts b/tests/cases/fourslash/shims/getDefinitionAtPosition.ts index 54b799ba65f..3aa31d1556c 100644 --- a/tests/cases/fourslash/shims/getDefinitionAtPosition.ts +++ b/tests/cases/fourslash/shims/getDefinitionAtPosition.ts @@ -1,29 +1,29 @@ -/// - -// @Filename: goToDefinitionDifferentFile_Definition.ts -////var /*remoteVariableDefinition*/remoteVariable; -/////*remoteFunctionDefinition*/function remoteFunction() { } -/////*remoteClassDefinition*/class remoteClass { } -/////*remoteInterfaceDefinition*/interface remoteInterface{ } -/////*remoteModuleDefinition*/module remoteModule{ export var foo = 1;} - -// @Filename: goToDefinitionDifferentFile_Consumption.ts -/////*remoteVariableReference*/remoteVariable = 1; -/////*remoteFunctionReference*/remoteFunction(); -////var foo = new /*remoteClassReference*/remoteClass(); -////class fooCls implements /*remoteInterfaceReference*/remoteInterface { } -////var fooVar = /*remoteModuleReference*/remoteModule.foo; - -var markerList = [ - "remoteVariable", - "remoteFunction", - "remoteClass", - "remoteInterface", - "remoteModule", -]; - -markerList.forEach((marker) => { - goTo.marker(marker + 'Reference'); - goTo.definition(); - verify.caretAtMarker(marker + 'Definition'); -}); +/// + +// @Filename: goToDefinitionDifferentFile_Definition.ts +////var /*remoteVariableDefinition*/remoteVariable; +/////*remoteFunctionDefinition*/function remoteFunction() { } +/////*remoteClassDefinition*/class remoteClass { } +/////*remoteInterfaceDefinition*/interface remoteInterface{ } +/////*remoteModuleDefinition*/module remoteModule{ export var foo = 1;} + +// @Filename: goToDefinitionDifferentFile_Consumption.ts +/////*remoteVariableReference*/remoteVariable = 1; +/////*remoteFunctionReference*/remoteFunction(); +////var foo = new /*remoteClassReference*/remoteClass(); +////class fooCls implements /*remoteInterfaceReference*/remoteInterface { } +////var fooVar = /*remoteModuleReference*/remoteModule.foo; + +var markerList = [ + "remoteVariable", + "remoteFunction", + "remoteClass", + "remoteInterface", + "remoteModule", +]; + +markerList.forEach((marker) => { + goTo.marker(marker + 'Reference'); + goTo.definition(); + verify.caretAtMarker(marker + 'Definition'); +}); diff --git a/tests/cases/fourslash/shims/getEmitOutput.ts b/tests/cases/fourslash/shims/getEmitOutput.ts index 699514521ed..7e86212d135 100644 --- a/tests/cases/fourslash/shims/getEmitOutput.ts +++ b/tests/cases/fourslash/shims/getEmitOutput.ts @@ -1,22 +1,22 @@ -/// - -// @BaselineFile: getEmitOutput.baseline -// @declaration: true - -// @Filename: inputFile1.ts -// @emitThisFile: true -//// var x: number = 5; -//// class Bar { -//// x : string; -//// y : number -//// } - -// @Filename: inputFile2.ts -// @emitThisFile: true -//// var x1: string = "hello world"; -//// class Foo{ -//// x : string; -//// y : number; -//// } - +/// + +// @BaselineFile: getEmitOutput.baseline +// @declaration: true + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// var x: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.ts +// @emitThisFile: true +//// var x1: string = "hello world"; +//// class Foo{ +//// x : string; +//// y : number; +//// } + verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/shims/getIndentationAtPosition.ts b/tests/cases/fourslash/shims/getIndentationAtPosition.ts index 5e26781357e..ba2936bd702 100644 --- a/tests/cases/fourslash/shims/getIndentationAtPosition.ts +++ b/tests/cases/fourslash/shims/getIndentationAtPosition.ts @@ -1,21 +1,21 @@ -/// - -////class Bar { -//// {| "indentation": 4|} -//// private foo: string = ""; -//// {| "indentation": 4|} -//// private f() { -//// var a: any[] = [[1, 2], [3, 4], 5]; -//// {| "indentation": 8|} -//// return ((1 + 1)); -//// } -//// {| "indentation": 4|} -//// private f2() { -//// if (true) { } { }; -//// } -////} +/// + +////class Bar { +//// {| "indentation": 4|} +//// private foo: string = ""; +//// {| "indentation": 4|} +//// private f() { +//// var a: any[] = [[1, 2], [3, 4], 5]; +//// {| "indentation": 8|} +//// return ((1 + 1)); +//// } +//// {| "indentation": 4|} +//// private f2() { +//// if (true) { } { }; +//// } +////} ////{| "indentation": 0|} test.markers().forEach((marker) => { - verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); -}); + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); +}); diff --git a/tests/cases/fourslash/shims/getNavigateToItems.ts b/tests/cases/fourslash/shims/getNavigateToItems.ts index 9658c52324c..5481f4295cb 100644 --- a/tests/cases/fourslash/shims/getNavigateToItems.ts +++ b/tests/cases/fourslash/shims/getNavigateToItems.ts @@ -1,27 +1,27 @@ -/// - -/////// Module -////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes { -//// -//// // Class -//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point { -//// // Instance member -//// {| "itemName": "origin", "kind": "property", "parentName": "Point", "matchKind": "exact"|}private origin = 0.0; -//// -//// {| "itemName": "distFromZero", "kind": "property", "parentName": "Point", "matchKind": "exact"|}private distFromZero = 0.0; -//// -//// // Getter -//// {| "itemName": "distance", "kind": "getter", "parentName": "Point", "matchKind": "exact" |}get distance(): number { return 0; } -//// } -////} -//// -////// Local variables -////{| "itemName": "point", "kind": "var", "parentName": "", "matchKind": "exact"|}var point = new Shapes.Point(); - -//// Testing for exact matching of navigationItems - -test.markers().forEach((marker) => { - if (marker.data) { - verify.navigationItemsListContains(marker.data.itemName, marker.data.kind, marker.data.itemName, marker.data.matchKind, marker.fileName, marker.data.parentName); - } -}); +/// + +/////// Module +////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes { +//// +//// // Class +//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point { +//// // Instance member +//// {| "itemName": "origin", "kind": "property", "parentName": "Point", "matchKind": "exact"|}private origin = 0.0; +//// +//// {| "itemName": "distFromZero", "kind": "property", "parentName": "Point", "matchKind": "exact"|}private distFromZero = 0.0; +//// +//// // Getter +//// {| "itemName": "distance", "kind": "getter", "parentName": "Point", "matchKind": "exact" |}get distance(): number { return 0; } +//// } +////} +//// +////// Local variables +////{| "itemName": "point", "kind": "var", "parentName": "", "matchKind": "exact"|}var point = new Shapes.Point(); + +//// Testing for exact matching of navigationItems + +test.markers().forEach((marker) => { + if (marker.data) { + verify.navigationItemsListContains(marker.data.itemName, marker.data.kind, marker.data.itemName, marker.data.matchKind, marker.fileName, marker.data.parentName); + } +}); diff --git a/tests/cases/fourslash/shims/getRenameInfo.ts b/tests/cases/fourslash/shims/getRenameInfo.ts index b5c8ac6aacc..b7a1f5d61ae 100644 --- a/tests/cases/fourslash/shims/getRenameInfo.ts +++ b/tests/cases/fourslash/shims/getRenameInfo.ts @@ -1,5 +1,5 @@ -/// - +/// + /////// ////function /**/[|Bar|]() { diff --git a/tests/cases/fourslash/shims/getSemanticDiagnostics.ts b/tests/cases/fourslash/shims/getSemanticDiagnostics.ts index 6345c464213..804abbde33b 100644 --- a/tests/cases/fourslash/shims/getSemanticDiagnostics.ts +++ b/tests/cases/fourslash/shims/getSemanticDiagnostics.ts @@ -1,11 +1,11 @@ -/// - -// @module: CommonJS -// @declaration: true -//// interface privateInterface {} -//// export class Bar implements /*1*/privateInterface/*2*/{ } - -verify.errorExistsBetweenMarkers("1", "2"); -verify.numberOfErrorsInCurrentFile(1); - - +/// + +// @module: CommonJS +// @declaration: true +//// interface privateInterface {} +//// export class Bar implements /*1*/privateInterface/*2*/{ } + +verify.errorExistsBetweenMarkers("1", "2"); +verify.numberOfErrorsInCurrentFile(1); + + diff --git a/tests/cases/fourslash/signatureHelpCallExpression.ts b/tests/cases/fourslash/signatureHelpCallExpression.ts index fd9758cfa54..61606b77bc0 100644 --- a/tests/cases/fourslash/signatureHelpCallExpression.ts +++ b/tests/cases/fourslash/signatureHelpCallExpression.ts @@ -1,16 +1,16 @@ -/// - -////function fnTest(str: string, num: number) { } -////fnTest(/*1*/'', /*2*/5); - -goTo.marker('1'); -verify.signatureHelpCountIs(1); -verify.currentSignatureParameterCountIs(2); -verify.currentSignatureHelpIs('fnTest(str: string, num: number): void'); - -verify.currentParameterHelpArgumentNameIs('str'); -verify.currentParameterSpanIs("str: string"); - -goTo.marker('2'); -verify.currentParameterHelpArgumentNameIs('num'); -verify.currentParameterSpanIs("num: number"); +/// + +////function fnTest(str: string, num: number) { } +////fnTest(/*1*/'', /*2*/5); + +goTo.marker('1'); +verify.signatureHelpCountIs(1); +verify.currentSignatureParameterCountIs(2); +verify.currentSignatureHelpIs('fnTest(str: string, num: number): void'); + +verify.currentParameterHelpArgumentNameIs('str'); +verify.currentParameterSpanIs("str: string"); + +goTo.marker('2'); +verify.currentParameterHelpArgumentNameIs('num'); +verify.currentParameterSpanIs("num: number"); diff --git a/tests/cases/fourslash/signatureHelpConstructExpression.ts b/tests/cases/fourslash/signatureHelpConstructExpression.ts index 00efee0a479..a64c0123e6f 100644 --- a/tests/cases/fourslash/signatureHelpConstructExpression.ts +++ b/tests/cases/fourslash/signatureHelpConstructExpression.ts @@ -1,17 +1,17 @@ -/// - -////class sampleCls { constructor(str: string, num: number) { } } -////var x = new sampleCls(/*1*/"", /*2*/5); - -goTo.marker('1'); -verify.signatureHelpCountIs(1); - -verify.currentSignatureParameterCountIs(2); -verify.currentSignatureHelpIs('sampleCls(str: string, num: number): sampleCls'); - -verify.currentParameterHelpArgumentNameIs('str'); -verify.currentParameterSpanIs("str: string"); - -goTo.marker('2'); -verify.currentParameterHelpArgumentNameIs('num'); -verify.currentParameterSpanIs("num: number"); +/// + +////class sampleCls { constructor(str: string, num: number) { } } +////var x = new sampleCls(/*1*/"", /*2*/5); + +goTo.marker('1'); +verify.signatureHelpCountIs(1); + +verify.currentSignatureParameterCountIs(2); +verify.currentSignatureHelpIs('sampleCls(str: string, num: number): sampleCls'); + +verify.currentParameterHelpArgumentNameIs('str'); +verify.currentParameterSpanIs("str: string"); + +goTo.marker('2'); +verify.currentParameterHelpArgumentNameIs('num'); +verify.currentParameterSpanIs("num: number"); diff --git a/tests/cases/fourslash/signatureHelpConstructorInheritance.ts b/tests/cases/fourslash/signatureHelpConstructorInheritance.ts index a2e683d69bb..23f802f10b5 100644 --- a/tests/cases/fourslash/signatureHelpConstructorInheritance.ts +++ b/tests/cases/fourslash/signatureHelpConstructorInheritance.ts @@ -1,22 +1,22 @@ -/// - -////class base { -//// constructor(s: string); -//// constructor(n: number); -//// constructor(a: any) { } -////} -////class B1 extends base { } -////class B2 extends B1 { } -////class B3 extends B2 { -//// constructor() { -//// super(/*indirectSuperCall*/3); -//// } -////} - - -goTo.marker('indirectSuperCall'); -verify.signatureHelpCountIs(2); -verify.currentSignatureParameterCountIs(1); -verify.currentSignatureHelpIs('B2(n: number): B2'); -verify.currentParameterHelpArgumentNameIs("n"); -verify.currentParameterSpanIs("n: number"); +/// + +////class base { +//// constructor(s: string); +//// constructor(n: number); +//// constructor(a: any) { } +////} +////class B1 extends base { } +////class B2 extends B1 { } +////class B3 extends B2 { +//// constructor() { +//// super(/*indirectSuperCall*/3); +//// } +////} + + +goTo.marker('indirectSuperCall'); +verify.signatureHelpCountIs(2); +verify.currentSignatureParameterCountIs(1); +verify.currentSignatureHelpIs('B2(n: number): B2'); +verify.currentParameterHelpArgumentNameIs("n"); +verify.currentParameterSpanIs("n: number"); diff --git a/tests/cases/fourslash/signatureHelpConstructorOverload.ts b/tests/cases/fourslash/signatureHelpConstructorOverload.ts index 9aab48f71ae..b562d4f54c7 100644 --- a/tests/cases/fourslash/signatureHelpConstructorOverload.ts +++ b/tests/cases/fourslash/signatureHelpConstructorOverload.ts @@ -1,16 +1,16 @@ -/// - -////class clsOverload { constructor(); constructor(test: string); constructor(test?: string) { } } -////var x = new clsOverload(/*1*/); -////var y = new clsOverload(/*2*/''); - -goTo.marker('1'); -verify.signatureHelpCountIs(2); -verify.currentSignatureParameterCountIs(0); -verify.currentSignatureHelpIs('clsOverload(): clsOverload'); - -goTo.marker('2'); -verify.currentSignatureParameterCountIs(1); -verify.currentSignatureHelpIs('clsOverload(test: string): clsOverload'); -verify.currentParameterHelpArgumentNameIs('test'); +/// + +////class clsOverload { constructor(); constructor(test: string); constructor(test?: string) { } } +////var x = new clsOverload(/*1*/); +////var y = new clsOverload(/*2*/''); + +goTo.marker('1'); +verify.signatureHelpCountIs(2); +verify.currentSignatureParameterCountIs(0); +verify.currentSignatureHelpIs('clsOverload(): clsOverload'); + +goTo.marker('2'); +verify.currentSignatureParameterCountIs(1); +verify.currentSignatureHelpIs('clsOverload(test: string): clsOverload'); +verify.currentParameterHelpArgumentNameIs('test'); verify.currentParameterSpanIs("test: string"); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpFunctionOverload.ts b/tests/cases/fourslash/signatureHelpFunctionOverload.ts index cc02ba12570..219e718f811 100644 --- a/tests/cases/fourslash/signatureHelpFunctionOverload.ts +++ b/tests/cases/fourslash/signatureHelpFunctionOverload.ts @@ -1,18 +1,18 @@ -/// - -////function functionOverload(); -////function functionOverload(test: string); -////function functionOverload(test?: string) { } -////functionOverload(/*functionOverload1*/); -////functionOverload(""/*functionOverload2*/); - -goTo.marker('functionOverload1'); -verify.signatureHelpCountIs(2); -verify.currentSignatureParameterCountIs(0); -verify.currentSignatureHelpIs('functionOverload(): any'); - -goTo.marker('functionOverload2'); -verify.currentSignatureParameterCountIs(1); -verify.currentSignatureHelpIs('functionOverload(test: string): any'); -verify.currentParameterHelpArgumentNameIs("test"); +/// + +////function functionOverload(); +////function functionOverload(test: string); +////function functionOverload(test?: string) { } +////functionOverload(/*functionOverload1*/); +////functionOverload(""/*functionOverload2*/); + +goTo.marker('functionOverload1'); +verify.signatureHelpCountIs(2); +verify.currentSignatureParameterCountIs(0); +verify.currentSignatureHelpIs('functionOverload(): any'); + +goTo.marker('functionOverload2'); +verify.currentSignatureParameterCountIs(1); +verify.currentSignatureHelpIs('functionOverload(test: string): any'); +verify.currentParameterHelpArgumentNameIs("test"); verify.currentParameterSpanIs("test: string"); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpFunctionParameter.ts b/tests/cases/fourslash/signatureHelpFunctionParameter.ts index b61e56dedcb..9105ee067ce 100644 --- a/tests/cases/fourslash/signatureHelpFunctionParameter.ts +++ b/tests/cases/fourslash/signatureHelpFunctionParameter.ts @@ -2,16 +2,16 @@ ////function parameterFunction(callback: (a: number, b: string) => void) { //// callback(/*parameterFunction1*/5, /*parameterFunction2*/""); -////} - -goTo.marker('parameterFunction1'); -verify.signatureHelpCountIs(1); -verify.currentSignatureParameterCountIs(2); -verify.currentSignatureHelpIs('callback(a: number, b: string): void'); -verify.currentParameterHelpArgumentNameIs("a"); -verify.currentParameterSpanIs("a: number"); - -goTo.marker('parameterFunction2'); -verify.currentSignatureHelpIs('callback(a: number, b: string): void'); -verify.currentParameterHelpArgumentNameIs("b"); +////} + +goTo.marker('parameterFunction1'); +verify.signatureHelpCountIs(1); +verify.currentSignatureParameterCountIs(2); +verify.currentSignatureHelpIs('callback(a: number, b: string): void'); +verify.currentParameterHelpArgumentNameIs("a"); +verify.currentParameterSpanIs("a: number"); + +goTo.marker('parameterFunction2'); +verify.currentSignatureHelpIs('callback(a: number, b: string): void'); +verify.currentParameterHelpArgumentNameIs("b"); verify.currentParameterSpanIs("b: string"); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpImplicitConstructor.ts b/tests/cases/fourslash/signatureHelpImplicitConstructor.ts index 4324767d00a..c22087b9d1d 100644 --- a/tests/cases/fourslash/signatureHelpImplicitConstructor.ts +++ b/tests/cases/fourslash/signatureHelpImplicitConstructor.ts @@ -2,9 +2,9 @@ ////class ImplicitConstructor { ////} -////var implicitConstructor = new ImplicitConstructor(/**/); - -goTo.marker(); -verify.signatureHelpCountIs(1); -verify.currentSignatureHelpIs("ImplicitConstructor(): ImplicitConstructor"); -verify.currentSignatureParameterCountIs(0); +////var implicitConstructor = new ImplicitConstructor(/**/); + +goTo.marker(); +verify.signatureHelpCountIs(1); +verify.currentSignatureHelpIs("ImplicitConstructor(): ImplicitConstructor"); +verify.currentSignatureParameterCountIs(0); diff --git a/tests/cases/fourslash/signatureHelpInFunctionCall.ts b/tests/cases/fourslash/signatureHelpInFunctionCall.ts index 566acc14fb7..48c3b4a4ccf 100644 --- a/tests/cases/fourslash/signatureHelpInFunctionCall.ts +++ b/tests/cases/fourslash/signatureHelpInFunctionCall.ts @@ -3,7 +3,7 @@ ////var items = []; ////items.forEach(item => { //// for (/**/ -////}); - -goTo.marker(); -verify.not.signatureHelpPresent(); +////}); + +goTo.marker(); +verify.not.signatureHelpPresent(); diff --git a/tests/cases/fourslash/signatureHelpNegativeTests2.ts b/tests/cases/fourslash/signatureHelpNegativeTests2.ts index 28f25063ddf..a7341225c73 100644 --- a/tests/cases/fourslash/signatureHelpNegativeTests2.ts +++ b/tests/cases/fourslash/signatureHelpNegativeTests2.ts @@ -1,10 +1,10 @@ -/// - -////class clsOverload { constructor(); constructor(test: string); constructor(test?: string) { } } -////var x = new clsOverload/*beforeOpenParen*/()/*afterCloseParen*/; - -goTo.marker('beforeOpenParen'); -verify.not.signatureHelpPresent(); - -goTo.marker('afterCloseParen'); +/// + +////class clsOverload { constructor(); constructor(test: string); constructor(test?: string) { } } +////var x = new clsOverload/*beforeOpenParen*/()/*afterCloseParen*/; + +goTo.marker('beforeOpenParen'); +verify.not.signatureHelpPresent(); + +goTo.marker('afterCloseParen'); verify.not.signatureHelpPresent(); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpObjectCreationExpressionNoArgs_NotAvailable.ts b/tests/cases/fourslash/signatureHelpObjectCreationExpressionNoArgs_NotAvailable.ts index aea52719273..40a0a316a0e 100644 --- a/tests/cases/fourslash/signatureHelpObjectCreationExpressionNoArgs_NotAvailable.ts +++ b/tests/cases/fourslash/signatureHelpObjectCreationExpressionNoArgs_NotAvailable.ts @@ -1,8 +1,8 @@ -/// - -////class sampleCls { constructor(str: string, num: number) { } } -////var x = new sampleCls/**/; - -goTo.marker(); -verify.signatureHelpCountIs(0); +/// + +////class sampleCls { constructor(str: string, num: number) { } } +////var x = new sampleCls/**/; + +goTo.marker(); +verify.signatureHelpCountIs(0); verify.not.signatureHelpPresent(); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity.ts b/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity.ts index fe18f655ed4..ff20d2ca5c2 100644 --- a/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity.ts +++ b/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity.ts @@ -1,4 +1,4 @@ -/// +/// ////declare function f(s: string); ////declare function f(n: number); diff --git a/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity2.ts b/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity2.ts index 1f87f3b9a0c..1290859d848 100644 --- a/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity2.ts +++ b/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity2.ts @@ -1,4 +1,4 @@ -/// +/// ////declare function f(s: string); ////declare function f(n: number); diff --git a/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity3.ts b/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity3.ts index f9754c7d1fd..b98cfe6bbfe 100644 --- a/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity3.ts +++ b/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity3.ts @@ -1,4 +1,4 @@ -/// +/// ////declare function f(); ////declare function f(s: string); diff --git a/tests/cases/fourslash/signatureHelpSimpleConstructorCall.ts b/tests/cases/fourslash/signatureHelpSimpleConstructorCall.ts index 81af0422f9a..8a5fa60ace8 100644 --- a/tests/cases/fourslash/signatureHelpSimpleConstructorCall.ts +++ b/tests/cases/fourslash/signatureHelpSimpleConstructorCall.ts @@ -4,14 +4,14 @@ //// constructor(str: string, num: number) { //// } ////} -////var x = new ConstructorCall(/*constructorCall1*/1,/*constructorCall2*/2); - -goTo.marker('constructorCall1'); -verify.signatureHelpCountIs(1); -verify.currentSignatureHelpIs("ConstructorCall(str: string, num: number): ConstructorCall"); -verify.currentParameterHelpArgumentNameIs("str"); -verify.currentParameterSpanIs("str: string"); +////var x = new ConstructorCall(/*constructorCall1*/1,/*constructorCall2*/2); + +goTo.marker('constructorCall1'); +verify.signatureHelpCountIs(1); +verify.currentSignatureHelpIs("ConstructorCall(str: string, num: number): ConstructorCall"); +verify.currentParameterHelpArgumentNameIs("str"); +verify.currentParameterSpanIs("str: string"); goTo.marker('constructorCall2'); -verify.currentSignatureHelpIs("ConstructorCall(str: string, num: number): ConstructorCall"); +verify.currentSignatureHelpIs("ConstructorCall(str: string, num: number): ConstructorCall"); verify.currentParameterHelpArgumentNameIs("num"); verify.currentParameterSpanIs("num: number"); diff --git a/tests/cases/fourslash/signatureHelpSimpleFunctionCall.ts b/tests/cases/fourslash/signatureHelpSimpleFunctionCall.ts index 6e5817ad90d..0dc76c0eb0a 100644 --- a/tests/cases/fourslash/signatureHelpSimpleFunctionCall.ts +++ b/tests/cases/fourslash/signatureHelpSimpleFunctionCall.ts @@ -5,15 +5,15 @@ ////} ////functionCall(/*functionCall1*/); ////functionCall("", /*functionCall2*/1); - - -goTo.marker('functionCall1'); -verify.signatureHelpCountIs(1); -verify.currentSignatureHelpIs("functionCall(str: string, num: number): void"); -verify.currentParameterHelpArgumentNameIs("str"); -verify.currentParameterSpanIs("str: string"); + + +goTo.marker('functionCall1'); +verify.signatureHelpCountIs(1); +verify.currentSignatureHelpIs("functionCall(str: string, num: number): void"); +verify.currentParameterHelpArgumentNameIs("str"); +verify.currentParameterSpanIs("str: string"); goTo.marker('functionCall2'); -verify.currentSignatureHelpIs("functionCall(str: string, num: number): void"); +verify.currentSignatureHelpIs("functionCall(str: string, num: number): void"); verify.currentParameterHelpArgumentNameIs("num"); verify.currentParameterSpanIs("num: number"); diff --git a/tests/cases/fourslash/signatureHelpSuperConstructorOverload.ts b/tests/cases/fourslash/signatureHelpSuperConstructorOverload.ts index aa2e3e4856c..c65ce2824c0 100644 --- a/tests/cases/fourslash/signatureHelpSuperConstructorOverload.ts +++ b/tests/cases/fourslash/signatureHelpSuperConstructorOverload.ts @@ -1,28 +1,28 @@ -/// - -////class SuperOverloadlBase { -//// constructor(); -//// constructor(test: string); -//// constructor(test?: string) { -//// } -////} -////class SuperOverLoad1 extends SuperOverloadlBase { -//// constructor() { -//// super(/*superOverload1*/); -//// } -////} -////class SuperOverLoad2 extends SuperOverloadlBase { -//// constructor() { -//// super(""/*superOverload2*/); -//// } -////} - -goTo.marker('superOverload1'); -verify.signatureHelpCountIs(2); -verify.currentSignatureHelpIs("SuperOverloadlBase(): SuperOverloadlBase"); -verify.currentSignatureParameterCountIs(0); -goTo.marker('superOverload2'); -verify.currentSignatureParameterCountIs(1); -verify.currentSignatureHelpIs("SuperOverloadlBase(test: string): SuperOverloadlBase"); -verify.currentParameterHelpArgumentNameIs("test"); +/// + +////class SuperOverloadlBase { +//// constructor(); +//// constructor(test: string); +//// constructor(test?: string) { +//// } +////} +////class SuperOverLoad1 extends SuperOverloadlBase { +//// constructor() { +//// super(/*superOverload1*/); +//// } +////} +////class SuperOverLoad2 extends SuperOverloadlBase { +//// constructor() { +//// super(""/*superOverload2*/); +//// } +////} + +goTo.marker('superOverload1'); +verify.signatureHelpCountIs(2); +verify.currentSignatureHelpIs("SuperOverloadlBase(): SuperOverloadlBase"); +verify.currentSignatureParameterCountIs(0); +goTo.marker('superOverload2'); +verify.currentSignatureParameterCountIs(1); +verify.currentSignatureHelpIs("SuperOverloadlBase(test: string): SuperOverloadlBase"); +verify.currentParameterHelpArgumentNameIs("test"); verify.currentParameterSpanIs("test: string"); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpWithInterfaceAsIdentifier.ts b/tests/cases/fourslash/signatureHelpWithInterfaceAsIdentifier.ts index 229d42c0524..cf89b4f4769 100644 --- a/tests/cases/fourslash/signatureHelpWithInterfaceAsIdentifier.ts +++ b/tests/cases/fourslash/signatureHelpWithInterfaceAsIdentifier.ts @@ -1,9 +1,9 @@ -/// - +/// + ////interface C { //// (): void; ////} -////C(/*1*/); - -goTo.marker('1'); +////C(/*1*/); + +goTo.marker('1'); verify.not.signatureHelpPresent(); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpWithUnknown.ts b/tests/cases/fourslash/signatureHelpWithUnknown.ts index 00a031b2673..e2ade663484 100644 --- a/tests/cases/fourslash/signatureHelpWithUnknown.ts +++ b/tests/cases/fourslash/signatureHelpWithUnknown.ts @@ -1,6 +1,6 @@ -/// - -////eval(\/*1*/ - -goTo.marker("1"); -verify.signatureHelpCountIs(1); +/// + +////eval(\/*1*/ + +goTo.marker("1"); +verify.signatureHelpCountIs(1); diff --git a/tests/cases/fourslash/smartIndentActualIndentation.ts b/tests/cases/fourslash/smartIndentActualIndentation.ts index b2874d3c1d8..da47aaf1bc1 100644 --- a/tests/cases/fourslash/smartIndentActualIndentation.ts +++ b/tests/cases/fourslash/smartIndentActualIndentation.ts @@ -1,17 +1,17 @@ -/// - -//// class A { -//// /*1*/ -//// } - -////module M { -//// class C { -//// /*2*/ -//// } -////} - -goTo.marker("1"); -verify.indentationIs(12); - -goTo.marker("2"); -verify.indentationIs(16); +/// + +//// class A { +//// /*1*/ +//// } + +////module M { +//// class C { +//// /*2*/ +//// } +////} + +goTo.marker("1"); +verify.indentationIs(12); + +goTo.marker("2"); +verify.indentationIs(16); diff --git a/tests/cases/fourslash/smartIndentAfterAlignedFunctionArgument.ts b/tests/cases/fourslash/smartIndentAfterAlignedFunctionArgument.ts index d5aa2bc4310..76566e996d5 100644 --- a/tests/cases/fourslash/smartIndentAfterAlignedFunctionArgument.ts +++ b/tests/cases/fourslash/smartIndentAfterAlignedFunctionArgument.ts @@ -1,10 +1,10 @@ -/// - -////function foo(bar, -//// blah, baz, -//// /**/ -////) { }; - -goTo.marker(); -// keep indentation of 'blah' -verify.indentationIs(13); +/// + +////function foo(bar, +//// blah, baz, +//// /**/ +////) { }; + +goTo.marker(); +// keep indentation of 'blah' +verify.indentationIs(13); diff --git a/tests/cases/fourslash/smartIndentClass.ts b/tests/cases/fourslash/smartIndentClass.ts index 5e26781357e..ba2936bd702 100644 --- a/tests/cases/fourslash/smartIndentClass.ts +++ b/tests/cases/fourslash/smartIndentClass.ts @@ -1,21 +1,21 @@ -/// - -////class Bar { -//// {| "indentation": 4|} -//// private foo: string = ""; -//// {| "indentation": 4|} -//// private f() { -//// var a: any[] = [[1, 2], [3, 4], 5]; -//// {| "indentation": 8|} -//// return ((1 + 1)); -//// } -//// {| "indentation": 4|} -//// private f2() { -//// if (true) { } { }; -//// } -////} +/// + +////class Bar { +//// {| "indentation": 4|} +//// private foo: string = ""; +//// {| "indentation": 4|} +//// private f() { +//// var a: any[] = [[1, 2], [3, 4], 5]; +//// {| "indentation": 8|} +//// return ((1 + 1)); +//// } +//// {| "indentation": 4|} +//// private f2() { +//// if (true) { } { }; +//// } +////} ////{| "indentation": 0|} test.markers().forEach((marker) => { - verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); -}); + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); +}); diff --git a/tests/cases/fourslash/smartIndentCloseBrace.ts b/tests/cases/fourslash/smartIndentCloseBrace.ts index da2094d76c6..10039075105 100644 --- a/tests/cases/fourslash/smartIndentCloseBrace.ts +++ b/tests/cases/fourslash/smartIndentCloseBrace.ts @@ -1,11 +1,11 @@ -/// - -////class A { -//// {| "indentation": 0|} } -////class B { -//// var x = 1; -//// {| "indentation": 0|} } +/// + +////class A { +//// {| "indentation": 0|} } +////class B { +//// var x = 1; +//// {| "indentation": 0|} } test.markers().forEach((marker) => { - verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); -}); + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); +}); diff --git a/tests/cases/fourslash/smartIndentDoStatement.ts b/tests/cases/fourslash/smartIndentDoStatement.ts index 2dff10f9276..d121344bed0 100644 --- a/tests/cases/fourslash/smartIndentDoStatement.ts +++ b/tests/cases/fourslash/smartIndentDoStatement.ts @@ -1,17 +1,17 @@ /// //// do /*1*/ { //// } while (true) -//// -//// do { /*2*/ -//// } /*3*/while (true)/*4*/ - -function verifyIndentationAfterNewLine(marker: string, indentation: number): void { - goTo.marker(marker); - edit.insert("\r\n"); - verify.indentationIs(indentation); -} - -verifyIndentationAfterNewLine("1", 0); -verifyIndentationAfterNewLine("2", 4); -verifyIndentationAfterNewLine("3", 0); -verifyIndentationAfterNewLine("4", 0); +//// +//// do { /*2*/ +//// } /*3*/while (true)/*4*/ + +function verifyIndentationAfterNewLine(marker: string, indentation: number): void { + goTo.marker(marker); + edit.insert("\r\n"); + verify.indentationIs(indentation); +} + +verifyIndentationAfterNewLine("1", 0); +verifyIndentationAfterNewLine("2", 4); +verifyIndentationAfterNewLine("3", 0); +verifyIndentationAfterNewLine("4", 0); diff --git a/tests/cases/fourslash/smartIndentIfStatement.ts b/tests/cases/fourslash/smartIndentIfStatement.ts index fb377ec9c96..5a8c5014a77 100644 --- a/tests/cases/fourslash/smartIndentIfStatement.ts +++ b/tests/cases/fourslash/smartIndentIfStatement.ts @@ -1,20 +1,20 @@ -/// - -//// if /*1*/(true) { } -//// -//// if (true) /*2*/ { /*3*/ -//// } /*4*/ -//// -//// if (1 === /*5*/ 2) { } - -function verifyIndentationAfterNewLine(marker: string, indentation: number): void { - goTo.marker(marker); - edit.insert("\r\n"); - verify.indentationIs(indentation); -} - -verifyIndentationAfterNewLine("1", 4); -verifyIndentationAfterNewLine("2", 0); -verifyIndentationAfterNewLine("3", 4); -verifyIndentationAfterNewLine("4", 0); +/// + +//// if /*1*/(true) { } +//// +//// if (true) /*2*/ { /*3*/ +//// } /*4*/ +//// +//// if (1 === /*5*/ 2) { } + +function verifyIndentationAfterNewLine(marker: string, indentation: number): void { + goTo.marker(marker); + edit.insert("\r\n"); + verify.indentationIs(indentation); +} + +verifyIndentationAfterNewLine("1", 4); +verifyIndentationAfterNewLine("2", 0); +verifyIndentationAfterNewLine("3", 4); +verifyIndentationAfterNewLine("4", 0); verifyIndentationAfterNewLine("5", 4); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentInCallExpressions.ts b/tests/cases/fourslash/smartIndentInCallExpressions.ts index 1e28932678b..27332507613 100644 --- a/tests/cases/fourslash/smartIndentInCallExpressions.ts +++ b/tests/cases/fourslash/smartIndentInCallExpressions.ts @@ -1,4 +1,4 @@ -/// +/// ////module My.App { //// export var appModule = angular.module("app", [ diff --git a/tests/cases/fourslash/smartIndentInsideBlockInsideCase.ts b/tests/cases/fourslash/smartIndentInsideBlockInsideCase.ts index ecff8e8368c..51c74269446 100644 --- a/tests/cases/fourslash/smartIndentInsideBlockInsideCase.ts +++ b/tests/cases/fourslash/smartIndentInsideBlockInsideCase.ts @@ -1,18 +1,18 @@ -/// - -////module SwitchTest { -//// var a = 3; -//// -//// if (a == 5) { -//// switch (a) { -//// case 1: -//// if (a == 5) { -//// /**/ -//// } -//// break; -//// } -//// } -////} - -goTo.marker(); -verify.indentationIs(20); +/// + +////module SwitchTest { +//// var a = 3; +//// +//// if (a == 5) { +//// switch (a) { +//// case 1: +//// if (a == 5) { +//// /**/ +//// } +//// break; +//// } +//// } +////} + +goTo.marker(); +verify.indentationIs(20); diff --git a/tests/cases/fourslash/smartIndentInterface.ts b/tests/cases/fourslash/smartIndentInterface.ts index 3a481ce759f..29fdf77d11e 100644 --- a/tests/cases/fourslash/smartIndentInterface.ts +++ b/tests/cases/fourslash/smartIndentInterface.ts @@ -1,14 +1,14 @@ -/// - -////interface Foo { -//// {| "indentation" : 4 |} -//// x: number; -//// {| "indentation" : 4 |} -//// foo(): number; -//// {| "indentation" : 4 |} -////} -////{| "indentation" : 0 |} +/// + +////interface Foo { +//// {| "indentation" : 4 |} +//// x: number; +//// {| "indentation" : 4 |} +//// foo(): number; +//// {| "indentation" : 4 |} +////} +////{| "indentation" : 0 |} test.markers().forEach((marker) => { - verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); }); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentModule.ts b/tests/cases/fourslash/smartIndentModule.ts index 8cac1ade9ce..12873c71250 100644 --- a/tests/cases/fourslash/smartIndentModule.ts +++ b/tests/cases/fourslash/smartIndentModule.ts @@ -1,12 +1,12 @@ -/// - -////module Foo { -//// /*insideModule*/ -////} -/////*afterModule*/ - -goTo.marker('insideModule'); -verify.indentationIs(4); - -goTo.marker('afterModule'); -verify.indentationIs(0); +/// + +////module Foo { +//// /*insideModule*/ +////} +/////*afterModule*/ + +goTo.marker('insideModule'); +verify.indentationIs(4); + +goTo.marker('afterModule'); +verify.indentationIs(0); diff --git a/tests/cases/fourslash/smartIndentNonterminatedArgumentListAtEOF.ts b/tests/cases/fourslash/smartIndentNonterminatedArgumentListAtEOF.ts index e4ab33fca37..b2b1f746a32 100644 --- a/tests/cases/fourslash/smartIndentNonterminatedArgumentListAtEOF.ts +++ b/tests/cases/fourslash/smartIndentNonterminatedArgumentListAtEOF.ts @@ -1,7 +1,7 @@ -/// - -////function foo(a, -/////**/ - -goTo.marker(); -verify.indentationIs(0); +/// + +////function foo(a, +/////**/ + +goTo.marker(); +verify.indentationIs(0); diff --git a/tests/cases/fourslash/smartIndentNonterminatedIfStatementAtEOF.ts b/tests/cases/fourslash/smartIndentNonterminatedIfStatementAtEOF.ts index 87989b9d85a..0bf4bca5ecb 100644 --- a/tests/cases/fourslash/smartIndentNonterminatedIfStatementAtEOF.ts +++ b/tests/cases/fourslash/smartIndentNonterminatedIfStatementAtEOF.ts @@ -1,7 +1,7 @@ -/// - -////if (true) -/////**/ - -goTo.marker(); -verify.indentationIs(4); +/// + +////if (true) +/////**/ + +goTo.marker(); +verify.indentationIs(4); diff --git a/tests/cases/fourslash/smartIndentOnFunctionParameters.ts b/tests/cases/fourslash/smartIndentOnFunctionParameters.ts index 012c4d93b4a..8823bf46917 100644 --- a/tests/cases/fourslash/smartIndentOnFunctionParameters.ts +++ b/tests/cases/fourslash/smartIndentOnFunctionParameters.ts @@ -1,31 +1,31 @@ -/// - -////function foo(a, -//// /*2*/b,/*0*/ -//// //comment/*3*/ -//// /*4*/c -//// ) { -////}; -////var x = [ -//// /*5*///comment/*1*/ -//// 1,/*6*/ -//// 2/*7*/ -////] -goTo.marker("0"); -edit.insert("\r\n"); -verify.indentationIs(4); -goTo.marker("2"); -verify.currentLineContentIs(" b,"); -goTo.marker("3"); -verify.currentLineContentIs(" //comment"); -goTo.marker("4"); -verify.currentLineContentIs(" c"); -goTo.marker("1"); -edit.insert("\r\n"); -verify.indentationIs(4); -goTo.marker("5"); -verify.currentLineContentIs(" //comment"); -goTo.marker("6"); -verify.currentLineContentIs(" 1,"); -goTo.marker("7"); -verify.currentLineContentIs(" 2"); +/// + +////function foo(a, +//// /*2*/b,/*0*/ +//// //comment/*3*/ +//// /*4*/c +//// ) { +////}; +////var x = [ +//// /*5*///comment/*1*/ +//// 1,/*6*/ +//// 2/*7*/ +////] +goTo.marker("0"); +edit.insert("\r\n"); +verify.indentationIs(4); +goTo.marker("2"); +verify.currentLineContentIs(" b,"); +goTo.marker("3"); +verify.currentLineContentIs(" //comment"); +goTo.marker("4"); +verify.currentLineContentIs(" c"); +goTo.marker("1"); +edit.insert("\r\n"); +verify.indentationIs(4); +goTo.marker("5"); +verify.currentLineContentIs(" //comment"); +goTo.marker("6"); +verify.currentLineContentIs(" 1,"); +goTo.marker("7"); +verify.currentLineContentIs(" 2"); diff --git a/tests/cases/fourslash/smartIndentStartLineInLists.ts b/tests/cases/fourslash/smartIndentStartLineInLists.ts index 0150881ff34..3410b4012ee 100644 --- a/tests/cases/fourslash/smartIndentStartLineInLists.ts +++ b/tests/cases/fourslash/smartIndentStartLineInLists.ts @@ -2,7 +2,7 @@ ////foo(function () { ////}).then(function () {/*1*/ ////}) - -goTo.marker("1"); -edit.insert("\r\n"); + +goTo.marker("1"); +edit.insert("\r\n"); verify.indentationIs(4); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentStatementFor.ts b/tests/cases/fourslash/smartIndentStatementFor.ts index 0412fe66d4e..a3fc2a9a0ce 100644 --- a/tests/cases/fourslash/smartIndentStatementFor.ts +++ b/tests/cases/fourslash/smartIndentStatementFor.ts @@ -1,14 +1,14 @@ -/// - -////function Foo() { -//// for (var i = 0; i < 10; i++) { -//// /*insideStatement*/ -//// } -//// /*afterStatement*/ -////} - -goTo.marker('insideStatement'); -verify.indentationIs(8); - -goTo.marker('afterStatement'); -verify.indentationIs(4); +/// + +////function Foo() { +//// for (var i = 0; i < 10; i++) { +//// /*insideStatement*/ +//// } +//// /*afterStatement*/ +////} + +goTo.marker('insideStatement'); +verify.indentationIs(8); + +goTo.marker('afterStatement'); +verify.indentationIs(4); diff --git a/tests/cases/fourslash/smartIndentStatementForIn.ts b/tests/cases/fourslash/smartIndentStatementForIn.ts index 9e710758864..355f175b7df 100644 --- a/tests/cases/fourslash/smartIndentStatementForIn.ts +++ b/tests/cases/fourslash/smartIndentStatementForIn.ts @@ -1,15 +1,15 @@ -/// - -////function Foo() { -//// for (var i in []) -//// { -//// /*insideStatement*/ -//// } -//// /*afterStatement*/ -////} - -goTo.marker('insideStatement'); -verify.indentationIs(8); - -goTo.marker('afterStatement'); -verify.indentationIs(4); +/// + +////function Foo() { +//// for (var i in []) +//// { +//// /*insideStatement*/ +//// } +//// /*afterStatement*/ +////} + +goTo.marker('insideStatement'); +verify.indentationIs(8); + +goTo.marker('afterStatement'); +verify.indentationIs(4); diff --git a/tests/cases/fourslash/smartIndentStatementSwitch.ts b/tests/cases/fourslash/smartIndentStatementSwitch.ts index e8d2a02948d..c2c2d09fd45 100644 --- a/tests/cases/fourslash/smartIndentStatementSwitch.ts +++ b/tests/cases/fourslash/smartIndentStatementSwitch.ts @@ -1,21 +1,21 @@ -/// - -////function Foo() { -//// var x; -//// switch (x) { -//// {| "indentation": 8 |} -//// } -//// {| "indentation": 4 |} -//// switch (x) { -//// {| "indentation": 8 |} -//// case 1: -//// {| "indentation": 12 |} -//// break; -//// {| "indentation": 12 |} // content of case clauses is always indented relatively to case clause -//// } -//// {| "indentation": 4 |} -////} +/// + +////function Foo() { +//// var x; +//// switch (x) { +//// {| "indentation": 8 |} +//// } +//// {| "indentation": 4 |} +//// switch (x) { +//// {| "indentation": 8 |} +//// case 1: +//// {| "indentation": 12 |} +//// break; +//// {| "indentation": 12 |} // content of case clauses is always indented relatively to case clause +//// } +//// {| "indentation": 4 |} +////} test.markers().forEach((marker) => { - verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); }); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentStatementTryCatchFinally.ts b/tests/cases/fourslash/smartIndentStatementTryCatchFinally.ts index a3bcaf9ac4d..e671dd9dc51 100644 --- a/tests/cases/fourslash/smartIndentStatementTryCatchFinally.ts +++ b/tests/cases/fourslash/smartIndentStatementTryCatchFinally.ts @@ -1,45 +1,45 @@ -/// - -////function tryCatch() { -//// {| "indentation": 4 |} -//// try { -//// {| "indentation": 8 |} -//// } -//// {| "indentation": 4 |} -//// catch (err) { -//// {| "indentation": 8 |} -//// } -//// {| "indentation": 4 |} -////} -//// -////function tryFinally() { -//// {| "indentation": 4 |} -//// try { -//// {| "indentation": 8 |} -//// } -//// {| "indentation": 4 |} -//// finally { -//// {| "indentation": 8 |} -//// } -//// {| "indentation": 4 |} -////} -//// -////function tryCatchFinally() { -//// {| "indentation": 4 |} -//// try { -//// {| "indentation": 8 |} -//// } -//// {| "indentation": 4 |} -//// catch (err) { -//// {| "indentation": 8 |} -//// } -//// {| "indentation": 4 |} -//// finally { -//// {| "indentation": 8 |} -//// } -//// {| "indentation": 4 |} -////} +/// + +////function tryCatch() { +//// {| "indentation": 4 |} +//// try { +//// {| "indentation": 8 |} +//// } +//// {| "indentation": 4 |} +//// catch (err) { +//// {| "indentation": 8 |} +//// } +//// {| "indentation": 4 |} +////} +//// +////function tryFinally() { +//// {| "indentation": 4 |} +//// try { +//// {| "indentation": 8 |} +//// } +//// {| "indentation": 4 |} +//// finally { +//// {| "indentation": 8 |} +//// } +//// {| "indentation": 4 |} +////} +//// +////function tryCatchFinally() { +//// {| "indentation": 4 |} +//// try { +//// {| "indentation": 8 |} +//// } +//// {| "indentation": 4 |} +//// catch (err) { +//// {| "indentation": 8 |} +//// } +//// {| "indentation": 4 |} +//// finally { +//// {| "indentation": 8 |} +//// } +//// {| "indentation": 4 |} +////} test.markers().forEach((marker) => { - verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); + verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); }); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentStatementWith.ts b/tests/cases/fourslash/smartIndentStatementWith.ts index 799555b8724..311ecafbb3b 100644 --- a/tests/cases/fourslash/smartIndentStatementWith.ts +++ b/tests/cases/fourslash/smartIndentStatementWith.ts @@ -1,15 +1,15 @@ -/// - -////function Foo() { -//// var obj = { a: 'foo' }; -//// with (obj) { -//// /*insideStatement*/ -//// } -//// /*afterStatement*/ -////} - -goTo.marker('insideStatement'); -verify.indentationIs(8); - -goTo.marker('afterStatement'); -verify.indentationIs(4); +/// + +////function Foo() { +//// var obj = { a: 'foo' }; +//// with (obj) { +//// /*insideStatement*/ +//// } +//// /*afterStatement*/ +////} + +goTo.marker('insideStatement'); +verify.indentationIs(8); + +goTo.marker('afterStatement'); +verify.indentationIs(4); diff --git a/tests/cases/fourslash/spaceAfterReturn.ts b/tests/cases/fourslash/spaceAfterReturn.ts index 16b44d81024..b5d26ae9819 100644 --- a/tests/cases/fourslash/spaceAfterReturn.ts +++ b/tests/cases/fourslash/spaceAfterReturn.ts @@ -1,15 +1,15 @@ -/// - -////function f( ) { -////return 1;/*1*/ -////return[1];/*2*/ -////return ;/*3*/ -////} - -format.document(); -goTo.marker("1"); -verify.currentLineContentIs(" return 1;"); -goTo.marker("2"); -verify.currentLineContentIs(" return [1];"); -goTo.marker("3"); +/// + +////function f( ) { +////return 1;/*1*/ +////return[1];/*2*/ +////return ;/*3*/ +////} + +format.document(); +goTo.marker("1"); +verify.currentLineContentIs(" return 1;"); +goTo.marker("2"); +verify.currentLineContentIs(" return [1];"); +goTo.marker("3"); verify.currentLineContentIs(" return;"); \ No newline at end of file diff --git a/tests/cases/fourslash/squiggleFunctionExpression.ts b/tests/cases/fourslash/squiggleFunctionExpression.ts index 3477f31db3a..75cca339e9d 100644 --- a/tests/cases/fourslash/squiggleFunctionExpression.ts +++ b/tests/cases/fourslash/squiggleFunctionExpression.ts @@ -1,9 +1,9 @@ -/// - -////function takesCallback(callback: (n) => any) { } -////takesCallback(function inner(n) { var /*1*/k/*2*/: string = 10; }); - -verify.errorExistsBetweenMarkers("1", "2"); -verify.not.errorExistsBeforeMarker("1"); -verify.not.errorExistsAfterMarker("2"); -verify.numberOfErrorsInCurrentFile(1); +/// + +////function takesCallback(callback: (n) => any) { } +////takesCallback(function inner(n) { var /*1*/k/*2*/: string = 10; }); + +verify.errorExistsBetweenMarkers("1", "2"); +verify.not.errorExistsBeforeMarker("1"); +verify.not.errorExistsAfterMarker("2"); +verify.numberOfErrorsInCurrentFile(1); diff --git a/tests/cases/fourslash/squiggleIllegalClassExtension.ts b/tests/cases/fourslash/squiggleIllegalClassExtension.ts index 21919835a64..357b4ef9ac0 100644 --- a/tests/cases/fourslash/squiggleIllegalClassExtension.ts +++ b/tests/cases/fourslash/squiggleIllegalClassExtension.ts @@ -1,6 +1,6 @@ -/// - -////class Foo extends /*1*/Bar/*2*/ { } - -verify.errorExistsBetweenMarkers("1", "2"); -verify.numberOfErrorsInCurrentFile(1); +/// + +////class Foo extends /*1*/Bar/*2*/ { } + +verify.errorExistsBetweenMarkers("1", "2"); +verify.numberOfErrorsInCurrentFile(1); diff --git a/tests/cases/fourslash/squiggleIllegalInterfaceExtension.ts b/tests/cases/fourslash/squiggleIllegalInterfaceExtension.ts index 4946353360c..636ce23f686 100644 --- a/tests/cases/fourslash/squiggleIllegalInterfaceExtension.ts +++ b/tests/cases/fourslash/squiggleIllegalInterfaceExtension.ts @@ -1,8 +1,8 @@ -/// - -////var n = '';/**/ -////interface x extends /*1*/string/*2*/ {} - -verify.not.errorExistsBeforeMarker(); -verify.errorExistsBetweenMarkers("1", "2"); -verify.numberOfErrorsInCurrentFile(1); +/// + +////var n = '';/**/ +////interface x extends /*1*/string/*2*/ {} + +verify.not.errorExistsBeforeMarker(); +verify.errorExistsBetweenMarkers("1", "2"); +verify.numberOfErrorsInCurrentFile(1); diff --git a/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts b/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts index fe9774d7bf9..bb7b40fd259 100644 --- a/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts +++ b/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts @@ -1,12 +1,12 @@ -/// - -////class Foo { -//// public x: number; -////} -//// -////class /*1*/Bar/*2*/ extends Foo { -//// public x: string; -////} - -verify.errorExistsBetweenMarkers("1", "2"); +/// + +////class Foo { +//// public x: number; +////} +//// +////class /*1*/Bar/*2*/ extends Foo { +//// public x: string; +////} + +verify.errorExistsBetweenMarkers("1", "2"); verify.numberOfErrorsInCurrentFile(1); \ No newline at end of file diff --git a/tests/cases/fourslash/squiggleUnclosedStringLiteral.ts b/tests/cases/fourslash/squiggleUnclosedStringLiteral.ts index 3d2dca0303b..cf4dc19ffb6 100644 --- a/tests/cases/fourslash/squiggleUnclosedStringLiteral.ts +++ b/tests/cases/fourslash/squiggleUnclosedStringLiteral.ts @@ -1,11 +1,11 @@ -/// - -////var x = /*1*/"asd -/////*2*/var y = 2; -verify.errorExistsAfterMarker("1"); -verify.not.errorExistsAfterMarker("2"); -verify.numberOfErrorsInCurrentFile(1); - - - - +/// + +////var x = /*1*/"asd +/////*2*/var y = 2; +verify.errorExistsAfterMarker("1"); +verify.not.errorExistsAfterMarker("2"); +verify.numberOfErrorsInCurrentFile(1); + + + + diff --git a/tests/cases/fourslash/symbolNameAtUnparseableFunctionOverload.ts b/tests/cases/fourslash/symbolNameAtUnparseableFunctionOverload.ts index 2ad60dbb6bc..59c78b5e5d6 100644 --- a/tests/cases/fourslash/symbolNameAtUnparseableFunctionOverload.ts +++ b/tests/cases/fourslash/symbolNameAtUnparseableFunctionOverload.ts @@ -1,13 +1,13 @@ -/// - -//// class TestClass { -//// public function foo(x: string): void; -//// public function foo(): void; -//// foo(x: any): void { -//// this.bar(/**/x); // should not error -//// } -//// } -//// - -goTo.marker(); +/// + +//// class TestClass { +//// public function foo(x: string): void; +//// public function foo(): void; +//// foo(x: any): void { +//// this.bar(/**/x); // should not error +//// } +//// } +//// + +goTo.marker(); verify.quickInfoExists(); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassificationsObjectLiteral.ts b/tests/cases/fourslash/syntacticClassificationsObjectLiteral.ts index a7e8f7b7b07..59642468ce9 100644 --- a/tests/cases/fourslash/syntacticClassificationsObjectLiteral.ts +++ b/tests/cases/fourslash/syntacticClassificationsObjectLiteral.ts @@ -1,4 +1,4 @@ -/// +/// ////var v = 10e0; ////var x = { diff --git a/tests/cases/fourslash/syntacticClassificationsTemplates1.ts b/tests/cases/fourslash/syntacticClassificationsTemplates1.ts index 4c79c047c81..8ee48fb8a11 100644 --- a/tests/cases/fourslash/syntacticClassificationsTemplates1.ts +++ b/tests/cases/fourslash/syntacticClassificationsTemplates1.ts @@ -1,4 +1,4 @@ -/// +/// ////var v = 10e0; ////var x = { diff --git a/tests/cases/fourslash/syntacticClassificationsTemplates2.ts b/tests/cases/fourslash/syntacticClassificationsTemplates2.ts index 19bad4b54a8..913dc039012 100644 --- a/tests/cases/fourslash/syntacticClassificationsTemplates2.ts +++ b/tests/cases/fourslash/syntacticClassificationsTemplates2.ts @@ -1,4 +1,4 @@ -/// +/// ////var tiredOfCanonicalExamples = ////`goodbye "${ `hello world` }" diff --git a/tests/cases/fourslash/toggleDuplicateFunctionDeclaration.ts b/tests/cases/fourslash/toggleDuplicateFunctionDeclaration.ts index a68bc7f7d0a..b8ed3ea9e5f 100644 --- a/tests/cases/fourslash/toggleDuplicateFunctionDeclaration.ts +++ b/tests/cases/fourslash/toggleDuplicateFunctionDeclaration.ts @@ -1,12 +1,12 @@ -/// - -//// class D { } -//// D(); - -var funcDecl = 'declare function D();'; - -goTo.bof(); -edit.insert(funcDecl); - -goTo.bof(); -edit.deleteAtCaret(funcDecl.length); +/// + +//// class D { } +//// D(); + +var funcDecl = 'declare function D();'; + +goTo.bof(); +edit.insert(funcDecl); + +goTo.bof(); +edit.deleteAtCaret(funcDecl.length); diff --git a/tests/cases/fourslash/typeAboveNumberLiteralExpressionStatement.ts b/tests/cases/fourslash/typeAboveNumberLiteralExpressionStatement.ts index ece781cbcb0..c28f7e5cba6 100644 --- a/tests/cases/fourslash/typeAboveNumberLiteralExpressionStatement.ts +++ b/tests/cases/fourslash/typeAboveNumberLiteralExpressionStatement.ts @@ -1,9 +1,9 @@ -/// - -//// -//// // foo -//// 1; - - -goTo.bof(); -edit.insert("var x;\n"); +/// + +//// +//// // foo +//// 1; + + +goTo.bof(); +edit.insert("var x;\n"); diff --git a/tests/cases/fourslash/typeCheckAfterAddingGenericParameter.ts b/tests/cases/fourslash/typeCheckAfterAddingGenericParameter.ts index fa312f3c711..5f8d3ed9e3c 100644 --- a/tests/cases/fourslash/typeCheckAfterAddingGenericParameter.ts +++ b/tests/cases/fourslash/typeCheckAfterAddingGenericParameter.ts @@ -1,22 +1,22 @@ -/// - -//// function f() { } -//// function f2(b: X): X { return null; } -//// class C { -//// public f() {} -//// f2(b): X { return null; } -//// } -//// -//// interface I { -//// f(); -//// f2(/*addParam*/a: X): X; -//// } -//// - -goTo.marker('addParam'); - -edit.insert(", X"); - -goTo.marker('addTypeParam'); - -edit.insert(", X"); +/// + +//// function f() { } +//// function f2(b: X): X { return null; } +//// class C { +//// public f() {} +//// f2(b): X { return null; } +//// } +//// +//// interface I { +//// f(); +//// f2(/*addParam*/a: X): X; +//// } +//// + +goTo.marker('addParam'); + +edit.insert(", X"); + +goTo.marker('addTypeParam'); + +edit.insert(", X"); diff --git a/tests/cases/fourslash/typeCheckObjectInArrayLiteral.ts b/tests/cases/fourslash/typeCheckObjectInArrayLiteral.ts index 621fe111bfb..5e321ec6b56 100644 --- a/tests/cases/fourslash/typeCheckObjectInArrayLiteral.ts +++ b/tests/cases/fourslash/typeCheckObjectInArrayLiteral.ts @@ -1,7 +1,7 @@ -/// - -//// declare function create(initialValues); -//// create([{}]); - -goTo.position(0); -edit.insert(''); +/// + +//// declare function create(initialValues); +//// create([{}]); + +goTo.position(0); +edit.insert(''); diff --git a/tests/cases/fourslash/typeParameterListInQuickInfoAfterEdit.ts b/tests/cases/fourslash/typeParameterListInQuickInfoAfterEdit.ts index c5abd2e0279..57246938325 100644 --- a/tests/cases/fourslash/typeParameterListInQuickInfoAfterEdit.ts +++ b/tests/cases/fourslash/typeParameterListInQuickInfoAfterEdit.ts @@ -1,20 +1,20 @@ -/// - -//// class Dictionary { -//// } -//// -//// module Maps { -//// class C1 extends D/*1*/ictionary { } -//// /*2*/ -//// } -//// - -// Sanity check: type name here should include the type parameter -goTo.marker('1'); -verify.quickInfoIs('class Dictionary'); - -// Add a similar class -- name does not match -goTo.marker('2'); -edit.insert("class C2 extends Dictionary { }"); -edit.moveLeft('ictionary { }'.length); -verify.quickInfoIs('class Dictionary'); +/// + +//// class Dictionary { +//// } +//// +//// module Maps { +//// class C1 extends D/*1*/ictionary { } +//// /*2*/ +//// } +//// + +// Sanity check: type name here should include the type parameter +goTo.marker('1'); +verify.quickInfoIs('class Dictionary'); + +// Add a similar class -- name does not match +goTo.marker('2'); +edit.insert("class C2 extends Dictionary { }"); +edit.moveLeft('ictionary { }'.length); +verify.quickInfoIs('class Dictionary'); diff --git a/tests/cases/fourslash/unclosedArrayErrorRecovery.ts b/tests/cases/fourslash/unclosedArrayErrorRecovery.ts index 3741b33ec58..3d9e4acea53 100644 --- a/tests/cases/fourslash/unclosedArrayErrorRecovery.ts +++ b/tests/cases/fourslash/unclosedArrayErrorRecovery.ts @@ -1,6 +1,6 @@ -/// - -////var table: number[; -/////**/table.push(1) - +/// + +////var table: number[; +/////**/table.push(1) + verify.not.errorExistsAfterMarker(); \ No newline at end of file diff --git a/tests/cases/fourslash/unclosedCommentsInConstructor.ts b/tests/cases/fourslash/unclosedCommentsInConstructor.ts index 8bda1505baa..a81bfb1fbf2 100644 --- a/tests/cases/fourslash/unclosedCommentsInConstructor.ts +++ b/tests/cases/fourslash/unclosedCommentsInConstructor.ts @@ -1,8 +1,8 @@ -/// - -////class Foo { -//// constructor(/*/**/) { } -////} - -goTo.marker(); +/// + +////class Foo { +//// constructor(/*/**/) { } +////} + +goTo.marker(); // verify.completionListIsEmpty(); // TODO: difference between LS and FourSlash \ No newline at end of file diff --git a/tests/cases/fourslash/unclosedFunctionErrorRecovery.ts b/tests/cases/fourslash/unclosedFunctionErrorRecovery.ts index 0f5007da2df..790d9ea689a 100644 --- a/tests/cases/fourslash/unclosedFunctionErrorRecovery.ts +++ b/tests/cases/fourslash/unclosedFunctionErrorRecovery.ts @@ -1,8 +1,8 @@ -/// - -////function alpha() { -//// -////function beta() { /*1*/alpha()/*2*/; } -//// - +/// + +////function alpha() { +//// +////function beta() { /*1*/alpha()/*2*/; } +//// + verify.not.errorExistsBetweenMarkers("1", "2"); \ No newline at end of file diff --git a/tests/cases/fourslash/unclosedFunctionErrorRecovery3.ts b/tests/cases/fourslash/unclosedFunctionErrorRecovery3.ts index f9bfe7bdc1c..bcb79811a62 100644 --- a/tests/cases/fourslash/unclosedFunctionErrorRecovery3.ts +++ b/tests/cases/fourslash/unclosedFunctionErrorRecovery3.ts @@ -1,6 +1,6 @@ -/// - -//// class alpha { static beta() return 5; } } -//// /**/ var gamma = alpha.beta() * 5; - +/// + +//// class alpha { static beta() return 5; } } +//// /**/ var gamma = alpha.beta() * 5; + verify.not.errorExistsAfterMarker(); \ No newline at end of file diff --git a/tests/cases/fourslash/unclosedMultilineStringLiteralErrorRecovery.ts b/tests/cases/fourslash/unclosedMultilineStringLiteralErrorRecovery.ts index 357d419a927..cf3a51c9f0f 100644 --- a/tests/cases/fourslash/unclosedMultilineStringLiteralErrorRecovery.ts +++ b/tests/cases/fourslash/unclosedMultilineStringLiteralErrorRecovery.ts @@ -1,10 +1,10 @@ -/// - -////function alpha() { -//// var x = "x\ -//// -//// /**/ -//// var y = 1; -////} - +/// + +////function alpha() { +//// var x = "x\ +//// +//// /**/ +//// var y = 1; +////} + verify.not.errorExistsAfterMarker(); \ No newline at end of file diff --git a/tests/cases/fourslash/unclosedStringLiteralAutoformating.ts b/tests/cases/fourslash/unclosedStringLiteralAutoformating.ts index 3c3afd93548..2f3c0e7494b 100644 --- a/tests/cases/fourslash/unclosedStringLiteralAutoformating.ts +++ b/tests/cases/fourslash/unclosedStringLiteralAutoformating.ts @@ -1,10 +1,10 @@ -/// - -////var x = /*1*/"asd/*2*/ -////class Foo { -//// /**/ - -//verify.errorExistsBetweenMarkers("1", "2"); -goTo.marker(); -edit.insert("}"); +/// + +////var x = /*1*/"asd/*2*/ +////class Foo { +//// /**/ + +//verify.errorExistsBetweenMarkers("1", "2"); +goTo.marker(); +edit.insert("}"); verify.currentLineContentIs("}"); \ No newline at end of file diff --git a/tests/cases/fourslash/unclosedStringLiteralErrorRecovery2.ts b/tests/cases/fourslash/unclosedStringLiteralErrorRecovery2.ts index a6be78c6b5a..ccae2bd4a79 100644 --- a/tests/cases/fourslash/unclosedStringLiteralErrorRecovery2.ts +++ b/tests/cases/fourslash/unclosedStringLiteralErrorRecovery2.ts @@ -1,12 +1,12 @@ -/// - -////function alpha() { -//// -//// var x = "x\ -//// var y = 1; -//// function beta() { } -//// beta(; -//// /**/ -////} -verify.not.errorExistsAfterMarker(); - +/// + +////function alpha() { +//// +//// var x = "x\ +//// var y = 1; +//// function beta() { } +//// beta(; +//// /**/ +////} +verify.not.errorExistsAfterMarker(); + diff --git a/tests/cases/fourslash/unclosedStringLiteralErrorRecovery3.ts b/tests/cases/fourslash/unclosedStringLiteralErrorRecovery3.ts index a2d94e683aa..b1ef837a982 100644 --- a/tests/cases/fourslash/unclosedStringLiteralErrorRecovery3.ts +++ b/tests/cases/fourslash/unclosedStringLiteralErrorRecovery3.ts @@ -1,11 +1,11 @@ -/// - -////function alpha() { -//// -//// var x = "x\ -//// -//// /**/var y = 1; -//// -////} - +/// + +////function alpha() { +//// +//// var x = "x\ +//// +//// /**/var y = 1; +//// +////} + verify.not.errorExistsAfterMarker(); \ No newline at end of file diff --git a/tests/cases/fourslash/unclosedStringLiteralErrorRecovery4.ts b/tests/cases/fourslash/unclosedStringLiteralErrorRecovery4.ts index 48c49f5064c..4d849a15334 100644 --- a/tests/cases/fourslash/unclosedStringLiteralErrorRecovery4.ts +++ b/tests/cases/fourslash/unclosedStringLiteralErrorRecovery4.ts @@ -1,9 +1,9 @@ -/// - -////function alpha() { -//// var x = "x -/////**/var y = "y"; -////} - -goTo.marker(); +/// + +////function alpha() { +//// var x = "x +/////**/var y = "y"; +////} + +goTo.marker(); verify.not.errorExistsAfterMarker(); \ No newline at end of file diff --git a/tests/cases/fourslash/underscoreTyping1.ts b/tests/cases/fourslash/underscoreTyping1.ts index fddafe5e88e..be7d20427e2 100644 --- a/tests/cases/fourslash/underscoreTyping1.ts +++ b/tests/cases/fourslash/underscoreTyping1.ts @@ -1,6 +1,6 @@ /// - -// @module: CommonJS + +// @module: CommonJS //// interface Dictionary { //// [x: string]: T; diff --git a/tests/cases/fourslash/unknownVariableErrorRecovery.ts b/tests/cases/fourslash/unknownVariableErrorRecovery.ts index b2e6adba983..c10df493f38 100644 --- a/tests/cases/fourslash/unknownVariableErrorRecovery.ts +++ b/tests/cases/fourslash/unknownVariableErrorRecovery.ts @@ -1,9 +1,9 @@ -/// - -////var foo = [1, 2, 3]; -////for (var bar = 0; foo[bar] < 5; bear/**/++ ) { -//// foo[bar] = 0; -////} - -verify.not.errorExistsAfterMarker(); - +/// + +////var foo = [1, 2, 3]; +////for (var bar = 0; foo[bar] < 5; bear/**/++ ) { +//// foo[bar] = 0; +////} + +verify.not.errorExistsAfterMarker(); + diff --git a/tests/cases/fourslash/whiteSpaceTrimming.ts b/tests/cases/fourslash/whiteSpaceTrimming.ts index 3e842e5a3a4..a77726f3ec1 100644 --- a/tests/cases/fourslash/whiteSpaceTrimming.ts +++ b/tests/cases/fourslash/whiteSpaceTrimming.ts @@ -1,10 +1,10 @@ -/// +/// ////if (true) { -//// // -//// /*err*/} - -goTo.marker('err'); -edit.insert("\n"); - -verify.currentFileContentIs("if (true) { \n // \n\n}"); +//// // +//// /*err*/} + +goTo.marker('err'); +edit.insert("\n"); + +verify.currentFileContentIs("if (true) { \n // \n\n}"); From c8399fc6c55e35487400a486592074119fce877c Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 2 Mar 2015 14:46:15 -0800 Subject: [PATCH 96/96] Use CRLF not LF. --- src/harness/harnessLanguageService.ts | 2 +- src/services/signatureHelp.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index a9c28fb70bd..4206f16bab3 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 8b7dea13ead..5c35f87fb20 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -295,8 +295,8 @@ module ts.SignatureHelp { var tagExpression = templateExpression.parent; Debug.assert(templateExpression.kind === SyntaxKind.TemplateExpression); - // If we're just after a template tail, don't show signature help. - if (node.kind === SyntaxKind.TemplateTail && !isInsideTemplateLiteral(node, position)) { + // If we're just after a template tail, don't show signature help. + if (node.kind === SyntaxKind.TemplateTail && !isInsideTemplateLiteral(node, position)) { return undefined; }